Merge pull request #148 from EthicalML/147_python_compat
Added temporary backwards compatibility for eval_tensor_create_def function
This commit is contained in:
commit
ec04dc65df
3 changed files with 30 additions and 0 deletions
1
.github/workflows/python_tests.yml
vendored
1
.github/workflows/python_tests.yml
vendored
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -177,6 +177,13 @@ PYBIND11_MODULE(kp, m) {
|
|||
py::arg("sequenceName"), DOC(kp, Manager, destroy, 5))
|
||||
.def("destroy", py::overload_cast<const std::vector<std::string>&>(&kp::Manager::destroy),
|
||||
py::arg("sequenceNames"), DOC(kp, Manager, destroy, 6))
|
||||
// temporary backwards compatibility
|
||||
.def("eval_tensor_create_def",[](kp::Manager& self, std::vector<std::shared_ptr<kp::Tensor>> 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,
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue