mirror of
https://github.com/nomic-ai/kompute.git
synced 2026-05-24 06:54:40 +00:00
Added base capabilities for tensor in python
This commit is contained in:
@@ -1,9 +1,27 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
PYBIND11_MODULE(cmake_example, m) {
|
||||
PYBIND11_MODULE(komputepy, m) {
|
||||
|
||||
py::enum_<kp::Tensor::TensorTypes>(m, "TensorTypes")
|
||||
.value("eDevice", kp::Tensor::TensorTypes::eDevice)
|
||||
.value("eStaging", kp::Tensor::TensorTypes::eStaging)
|
||||
.value("eStorage", kp::Tensor::TensorTypes::eStorage)
|
||||
.export_values();
|
||||
|
||||
py::class_<kp::Tensor>(m, "Tensor")
|
||||
.def(py::init(
|
||||
[](const std::vector<float>& data) {
|
||||
return std::unique_ptr<kp::Tensor>(new kp::Tensor(data));
|
||||
}))
|
||||
.def(py::init(
|
||||
[](const std::vector<float>& data, kp::Tensor::TensorTypes tensorTypes) {
|
||||
return std::unique_ptr<kp::Tensor>(new kp::Tensor(data, tensorTypes));
|
||||
}));
|
||||
|
||||
#ifdef VERSION_INFO
|
||||
m.attr("__version__") = VERSION_INFO;
|
||||
|
||||
Reference in New Issue
Block a user