Updated to add separate bytes load and str load functions

This commit is contained in:
Alejandro Saucedo
2020-11-08 11:20:12 +00:00
parent a4523338be
commit 6c61329422

View File

@@ -72,7 +72,17 @@ PYBIND11_MODULE(kp, m) {
"Records operation to run multiplication compute shader to two input tensors and an output tensor")
.def("record_algo_file", &kp::Sequence::record<kp::OpAlgoBase, std::string>,
"Records an operation using a custom shader provided from a shader path")
.def("record_algo_data", &kp::Sequence::record<kp::OpAlgoBase, py::bytes>,
.def("record_algo_data", [](kp::Sequence &self,
std::vector<std::shared_ptr<kp::Tensor>> tensors,
py::bytes &bytes) {
// Bytes have to be converted into std::vector
py::buffer_info info(py::buffer(bytes).request());
const char *data = reinterpret_cast<const char *>(info.ptr);
size_t length = static_cast<size_t>(info.size);
self.record<kp::OpAlgoBase>(
tensors,
std::vector<char>(data, data + length));
},
"Records an operation using a custom shader provided as raw string or spirv bytes")
.def("record_algo_lro", &kp::Sequence::record<kp::OpAlgoLhsRhsOut>,
"Records operation to run left right out operation with custom shader");
@@ -112,8 +122,20 @@ PYBIND11_MODULE(kp, m) {
"Evaluates operation to run multiplication compute shader to two input tensors and an output tensor with new anonymous Sequence")
.def("eval_algo_file_def", &kp::Manager::evalOpDefault<kp::OpAlgoBase, std::string>,
"Evaluates an operation using a custom shader provided from a shader path with new anonymous Sequence")
.def("eval_algo_data_def", &kp::Manager::evalOpDefault<kp::OpAlgoBase, py::bytes>,
"Evaluates an operation using a custom shader provided as raw string or spirv bytes with new anonymous Sequence")
.def("eval_algo_str_def", &kp::Manager::evalOpDefault<kp::OpAlgoBase, std::vector<char>>,
"Evaluates an operation using a custom shader provided as string provided as list of characters with new anonymous Sequence")
.def("eval_algo_data_def", [](kp::Manager &self,
std::vector<std::shared_ptr<kp::Tensor>> tensors,
py::bytes &bytes) {
// Bytes have to be converted into std::vector
py::buffer_info info(py::buffer(bytes).request());
const char *data = reinterpret_cast<const char *>(info.ptr);
size_t length = static_cast<size_t>(info.size);
self.evalOpDefault<kp::OpAlgoBase>(
tensors,
std::vector<char>(data, data + length));
},
"Evaluates an operation using a custom shader provided as spirv bytes with new anonymous Sequence")
.def("eval_algo_lro_def", &kp::Manager::evalOpDefault<kp::OpAlgoLhsRhsOut>,
"Evaluates operation to run left right out operation with custom shader with new anonymous Sequence")
// eval
@@ -129,8 +151,22 @@ PYBIND11_MODULE(kp, m) {
"Evaluates operation to run multiplication compute shader to two input tensors and an output tensor with explicitly named Sequence")
.def("eval_algo_file", &kp::Manager::evalOp<kp::OpAlgoBase, std::string>,
"Evaluates an operation using a custom shader provided from a shader path with explicitly named Sequence")
.def("eval_algo_data", &kp::Manager::evalOp<kp::OpAlgoBase, py::bytes>,
"Evaluates an operation using a custom shader provided as raw string or spirv bytes with explicitly named Sequence")
.def("eval_algo_str", &kp::Manager::evalOp<kp::OpAlgoBase, std::vector<char>>,
"Evaluates an operation using a custom shader provided as string provided as list of characters with explicitly named Sequence")
.def("eval_algo_data", [](kp::Manager &self,
std::vector<std::shared_ptr<kp::Tensor>> tensors,
std::string sequenceName,
py::bytes &bytes) {
// Bytes have to be converted into std::vector
py::buffer_info info(py::buffer(bytes).request());
const char *data = reinterpret_cast<const char *>(info.ptr);
size_t length = static_cast<size_t>(info.size);
self.evalOp<kp::OpAlgoBase>(
tensors,
sequenceName,
std::vector<char>(data, data + length));
},
"Evaluates an operation using a custom shader provided as spirv bytes with explicitly named Sequence")
.def("eval_algo_lro", &kp::Manager::evalOp<kp::OpAlgoLhsRhsOut>,
"Evaluates operation to run left right out operation with custom shader with explicitly named Sequence")
// eval async default
@@ -146,7 +182,19 @@ PYBIND11_MODULE(kp, m) {
"Evaluates asynchronously operation to run multiplication compute shader to two input tensors and an output tensor with anonymous Sequence")
.def("eval_async_algo_file_def", &kp::Manager::evalOpAsyncDefault<kp::OpAlgoBase, std::string>,
"Evaluates asynchronously an operation using a custom shader provided from a shader path with anonymous Sequence")
.def("eval_async_algo_data_def", &kp::Manager::evalOpAsyncDefault<kp::OpAlgoBase, py::bytes>,
.def("eval_async_algo_str_def", &kp::Manager::evalOpAsyncDefault<kp::OpAlgoBase, std::vector<char>>,
"Evaluates Asynchronously an operation using a custom shader provided as string provided as list of characters with new anonymous Sequence")
.def("eval_async_algo_data_def", [](kp::Manager &self,
std::vector<std::shared_ptr<kp::Tensor>> tensors,
py::bytes &bytes) {
// Bytes have to be converted into std::vector
py::buffer_info info(py::buffer(bytes).request());
const char *data = reinterpret_cast<const char *>(info.ptr);
size_t length = static_cast<size_t>(info.size);
self.evalOpAsyncDefault<kp::OpAlgoBase>(
tensors,
std::vector<char>(data, data + length));
},
"Evaluates asynchronously an operation using a custom shader provided as raw string or spirv bytes with anonymous Sequence")
.def("eval_async_algo_lro_def", &kp::Manager::evalOpAsyncDefault<kp::OpAlgoLhsRhsOut>,
"Evaluates asynchronously operation to run left right out operation with custom shader with anonymous Sequence")
@@ -163,7 +211,21 @@ PYBIND11_MODULE(kp, m) {
"Evaluates asynchronously operation to run multiplication compute shader to two input tensors and an output tensor with explicitly named Sequence")
.def("eval_async_algo_file", &kp::Manager::evalOpAsync<kp::OpAlgoBase, std::string>,
"Evaluates asynchronously an operation using a custom shader provided from a shader path with explicitly named Sequence")
.def("eval_async_algo_data", &kp::Manager::evalOpAsync<kp::OpAlgoBase, py::bytes>,
.def("eval_async_algo_str", &kp::Manager::evalOpAsync<kp::OpAlgoBase, std::vector<char>>,
"Evaluates Asynchronous an operation using a custom shader provided as string provided as list of characters with explicitly named Sequence")
.def("eval_async_algo_data", [](kp::Manager &self,
std::vector<std::shared_ptr<kp::Tensor>> tensors,
std::string sequenceName,
py::bytes &bytes) {
// Bytes have to be converted into std::vector
py::buffer_info info(py::buffer(bytes).request());
const char *data = reinterpret_cast<const char *>(info.ptr);
size_t length = static_cast<size_t>(info.size);
self.evalOpAsync<kp::OpAlgoBase>(
tensors,
sequenceName,
std::vector<char>(data, data + length));
},
"Evaluates asynchronously an operation using a custom shader provided as raw string or spirv bytes with explicitly named Sequence")
.def("eval_async_algo_lro", &kp::Manager::evalOpAsync<kp::OpAlgoLhsRhsOut>,
"Evaluates asynchronously operation to run left right out operation with custom shader with explicitly named Sequence");