From 9e5535f31642a9536911e7a339ca5146d83663b2 Mon Sep 17 00:00:00 2001 From: alexander-g <3867427+alexander-g@users.noreply.github.com> Date: Mon, 28 Dec 2020 10:59:55 +0100 Subject: [PATCH] string parameter for eval_algo methods --- README.md | 2 +- python/src/main.cpp | 30 ++++++++++++++++++++++++++++++ python/test/test_kompute.py | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1cf1ef595..790cf686f 100644 --- a/README.md +++ b/README.md @@ -354,7 +354,7 @@ mgr.eval_algo_data_def( # Alternatively can pass raw string/bytes: # shaderFileData = """ shader code here... """ -# mgr.eval_algo_data_def([tensor_in_a, tensor_in_b, tensor_out], list(shaderFileData)) +# mgr.eval_algo_data_def([tensor_in_a, tensor_in_b, tensor_out], shaderFileData) mgr.eval_await_def() diff --git a/python/src/main.cpp b/python/src/main.cpp index 871354a3c..77924581e 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -164,6 +164,13 @@ PYBIND11_MODULE(kp, m) { "Evaluates an operation using a custom shader provided from a shader path with new anonymous Sequence") .def("eval_algo_str_def", &kp::Manager::evalOpDefault>, "Evaluates an operation using a custom shader provided as string provided as list of characters with new anonymous Sequence") + .def("eval_algo_str_def", [](kp::Manager &self, + std::vector> tensors, + const std::string& shader_str){ + const std::vector shader_vec(shader_str.begin(), shader_str.end()); + self.evalOpDefault(tensors, shader_vec); + }, + "Evaluates an operation using a custom shader provided as string with a new anonymous Sequence") .def("eval_algo_data_def", [](kp::Manager &self, std::vector> tensors, py::bytes &bytes) { @@ -193,6 +200,14 @@ PYBIND11_MODULE(kp, m) { "Evaluates an operation using a custom shader provided from a shader path with explicitly named Sequence") .def("eval_algo_str", &kp::Manager::evalOp>, "Evaluates an operation using a custom shader provided as string provided as list of characters with explicitly named Sequence") + .def("eval_algo_str", [](kp::Manager &self, + std::vector> tensors, + const std::string& sequenceName, + const std::string& shader_str) { + const std::vector shader_vec(shader_str.begin(), shader_str.end()); + self.evalOp(tensors, sequenceName, shader_vec); + }, + "Evaluates an operation using a custom shader provided as string with explicitly named Sequence") .def("eval_algo_data", [](kp::Manager &self, std::vector> tensors, std::string sequenceName, @@ -224,6 +239,13 @@ PYBIND11_MODULE(kp, m) { "Evaluates asynchronously an operation using a custom shader provided from a shader path with anonymous Sequence") .def("eval_async_algo_str_def", &kp::Manager::evalOpAsyncDefault>, "Evaluates Asynchronously an operation using a custom shader provided as string provided as list of characters with new anonymous Sequence") + .def("eval_async_algo_str_def", [](kp::Manager &self, + std::vector> tensors, + const std::string& shader_str) { + const std::vector shader_vec(shader_str.begin(), shader_str.end()); + self.evalOpAsyncDefault(tensors, shader_vec); + }, + "Evaluates Asynchronously an operation using a custom shader provided as string with new anonymous Sequence") .def("eval_async_algo_data_def", [](kp::Manager &self, std::vector> tensors, py::bytes &bytes) { @@ -253,6 +275,14 @@ PYBIND11_MODULE(kp, m) { "Evaluates asynchronously an operation using a custom shader provided from a shader path with explicitly named Sequence") .def("eval_async_algo_str", &kp::Manager::evalOpAsync>, "Evaluates Asynchronous an operation using a custom shader provided as string provided as list of characters with explicitly named Sequence") + .def("eval_async_algo_str", [](kp::Manager &self, + std::vector> tensors, + const std::string& sequenceName, + const std::string& shader_str) { + const std::vector shader_vec(shader_str.begin(), shader_str.end()); + self.evalOpAsync(tensors, sequenceName, shader_vec); + }, + "Evaluates Asynchronous an operation using a custom shader provided as string with explicitly named Sequence") .def("eval_async_algo_data", [](kp::Manager &self, std::vector> tensors, std::string sequenceName, diff --git a/python/test/test_kompute.py b/python/test/test_kompute.py index 597a9d8a3..2232beae8 100644 --- a/python/test/test_kompute.py +++ b/python/test/test_kompute.py @@ -54,7 +54,7 @@ def test_opalgobase_data(): mgr.eval_tensor_create_def([tensor_in_a, tensor_in_b, tensor_out]) - mgr.eval_algo_str_def([tensor_in_a, tensor_in_b, tensor_out], list(shaderData)) + mgr.eval_algo_str_def([tensor_in_a, tensor_in_b, tensor_out], shaderData) mgr.eval_tensor_sync_local_def([tensor_out])