diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index fc547759c..8dafe413a 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -27,6 +27,7 @@ jobs: export VK_ICD_FILENAMES=/swiftshader/vk_swiftshader_icd.json pytest -v python/test/test_array_multiplication.py pytest -v python/test/test_kompute.py -k "test_opmult" + pytest -v python/test/test_kompute.py -k "test_tensor_rebuild_backwards_compat" pytest -v python/test/test_logistic_regression.py diff --git a/python/src/main.cpp b/python/src/main.cpp index 176b6e4e0..98609e5cd 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -177,6 +177,13 @@ PYBIND11_MODULE(kp, m) { py::arg("sequenceName"), DOC(kp, Manager, destroy, 5)) .def("destroy", py::overload_cast&>(&kp::Manager::destroy), py::arg("sequenceNames"), DOC(kp, Manager, destroy, 6)) + // temporary backwards compatibility + .def("eval_tensor_create_def",[](kp::Manager& self, std::vector> tensors, bool syncDataToGPU) -> void { + kp_error("IMPORTANT: eval_tensor_create_def is depricated! Please use Manager.rebuild instead as function will be removed soon."); + self.rebuild(tensors, syncDataToGPU); + }, + py::arg("tensors"), py::arg("syncDataToGPU") = true, + "Temporary backwards compatibility for tensor creation function which will be removed in the next version.") // Await functions .def("eval_await", &kp::Manager::evalOpAwait, diff --git a/python/test/test_kompute.py b/python/test/test_kompute.py index e2cbb72c9..6ce5d88b0 100644 --- a/python/test/test_kompute.py +++ b/python/test/test_kompute.py @@ -169,3 +169,25 @@ def test_workgroup(): assert tensor_a.is_init() == False assert tensor_b.is_init() == False + +def test_tensor_rebuild_backwards_compat(): + """ + Test basic OpMult operation + """ + + tensor_in_a = kp.Tensor([2, 2, 2]) + tensor_in_b = kp.Tensor([1, 2, 3]) + tensor_out = kp.Tensor([0, 0, 0]) + + mgr = kp.Manager() + + mgr.eval_tensor_create_def([tensor_in_a, tensor_in_b, tensor_out]) + + mgr.eval_algo_mult_def([tensor_in_a, tensor_in_b, tensor_out]) + + mgr.eval_tensor_sync_local_def([tensor_out]) + + assert tensor_out.data() == [2.0, 4.0, 6.0] + assert np.all(tensor_out.numpy() == [2.0, 4.0, 6.0]) + +