|
42 | 42 |
|
43 | 43 | namespace py = pybind11;
|
44 | 44 |
|
45 |
| -static dpctl::tensor::detail::usm_ndarray_types array_types; |
46 |
| - |
47 | 45 | namespace
|
48 | 46 | {
|
49 | 47 |
|
@@ -301,6 +299,7 @@ copy_usm_ndarray_into_usm_ndarray(dpctl::tensor::usm_ndarray src,
|
301 | 299 | int src_typenum = src.get_typenum();
|
302 | 300 | int dst_typenum = dst.get_typenum();
|
303 | 301 |
|
| 302 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
304 | 303 | int src_type_id = array_types.typenum_to_lookup_id(src_typenum);
|
305 | 304 | int dst_type_id = array_types.typenum_to_lookup_id(dst_typenum);
|
306 | 305 |
|
@@ -545,6 +544,7 @@ copy_usm_ndarray_for_reshape(dpctl::tensor::usm_ndarray src,
|
545 | 544 | const py::ssize_t *src_shape = src.get_shape_raw();
|
546 | 545 | const py::ssize_t *dst_shape = dst.get_shape_raw();
|
547 | 546 |
|
| 547 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
548 | 548 | int type_id = array_types.typenum_to_lookup_id(src_typenum);
|
549 | 549 |
|
550 | 550 | auto fn = copy_for_reshape_generic_dispatch_vector[type_id];
|
@@ -729,6 +729,7 @@ void copy_numpy_ndarray_into_usm_ndarray(
|
729 | 729 | py::detail::array_descriptor_proxy(npy_src.dtype().ptr())->type_num;
|
730 | 730 | int dst_typenum = dst.get_typenum();
|
731 | 731 |
|
| 732 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
732 | 733 | int src_type_id = array_types.typenum_to_lookup_id(src_typenum);
|
733 | 734 | int dst_type_id = array_types.typenum_to_lookup_id(dst_typenum);
|
734 | 735 |
|
@@ -909,6 +910,7 @@ usm_ndarray_linear_sequence_step(py::object start,
|
909 | 910 | "Execution queue is not compatible with the allocation queue");
|
910 | 911 | }
|
911 | 912 |
|
| 913 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
912 | 914 | int dst_typenum = dst.get_typenum();
|
913 | 915 | int dst_typeid = array_types.typenum_to_lookup_id(dst_typenum);
|
914 | 916 |
|
@@ -957,6 +959,7 @@ usm_ndarray_linear_sequence_affine(py::object start,
|
957 | 959 | "Execution queue context is not the same as allocation context");
|
958 | 960 | }
|
959 | 961 |
|
| 962 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
960 | 963 | int dst_typenum = dst.get_typenum();
|
961 | 964 | int dst_typeid = array_types.typenum_to_lookup_id(dst_typenum);
|
962 | 965 |
|
@@ -1006,6 +1009,7 @@ usm_ndarray_full(py::object py_value,
|
1006 | 1009 | "Execution queue is not compatible with the allocation queue");
|
1007 | 1010 | }
|
1008 | 1011 |
|
| 1012 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
1009 | 1013 | int dst_typenum = dst.get_typenum();
|
1010 | 1014 | int dst_typeid = array_types.typenum_to_lookup_id(dst_typenum);
|
1011 | 1015 |
|
@@ -1054,6 +1058,7 @@ eye(py::ssize_t k,
|
1054 | 1058 | "allocation queue");
|
1055 | 1059 | }
|
1056 | 1060 |
|
| 1061 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
1057 | 1062 | int dst_typenum = dst.get_typenum();
|
1058 | 1063 | int dst_typeid = array_types.typenum_to_lookup_id(dst_typenum);
|
1059 | 1064 |
|
@@ -1168,6 +1173,8 @@ tri(sycl::queue &exec_q,
|
1168 | 1173 | throw py::value_error("Arrays index overlapping segments of memory");
|
1169 | 1174 | }
|
1170 | 1175 |
|
| 1176 | + auto array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
| 1177 | + |
1171 | 1178 | int src_typenum = src.get_typenum();
|
1172 | 1179 | int dst_typenum = dst.get_typenum();
|
1173 | 1180 | int src_typeid = array_types.typenum_to_lookup_id(src_typenum);
|
@@ -1441,9 +1448,6 @@ PYBIND11_MODULE(_tensor_impl, m)
|
1441 | 1448 | init_copy_for_reshape_dispatch_vector();
|
1442 | 1449 | import_dpctl();
|
1443 | 1450 |
|
1444 |
| - // populate types constants for type dispatching functions |
1445 |
| - array_types = dpctl::tensor::detail::usm_ndarray_types::get(); |
1446 |
| - |
1447 | 1451 | m.def(
|
1448 | 1452 | "_contract_iter", &contract_iter,
|
1449 | 1453 | "Simplifies iteration of array of given shape & stride. Returns "
|
|
0 commit comments