Added base capabilities for tensor in python
This commit is contained in:
parent
9559c79eee
commit
0e9ba00b71
4 changed files with 35 additions and 9 deletions
|
|
@ -1,4 +1,11 @@
|
|||
|
||||
add_subdirectory(pybind11)
|
||||
pybind11_add_module(cmake_example src/main.cpp)
|
||||
pybind11_add_module(komputepy src/main.cpp)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/single_include/)
|
||||
|
||||
target_link_libraries(
|
||||
komputepy PRIVATE
|
||||
kompute::kompute)
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
10
setup.py
10
setup.py
|
|
@ -51,6 +51,7 @@ class CMakeBuild(build_ext):
|
|||
cmake_args += ['-A', 'x64']
|
||||
build_args += ['--', '/m']
|
||||
else:
|
||||
cmake_args += ['-DKOMPUTE_EXTRA_CXX_FLAGS="-fPIC"']
|
||||
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
|
||||
build_args += ['--', '-j2']
|
||||
|
||||
|
|
@ -64,13 +65,12 @@ class CMakeBuild(build_ext):
|
|||
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
|
||||
|
||||
setup(
|
||||
name='cmake_example',
|
||||
name='komputepy',
|
||||
version='0.0.1',
|
||||
author='Dean Moldovan',
|
||||
author_email='dean0x7d@gmail.com',
|
||||
description='A test project using pybind11 and CMake',
|
||||
author='Alejandro Saucedo',
|
||||
description='Blazing fast, mobile-enabled, asynchronous, and optimized for advanced GPU processing usecases.',
|
||||
long_description='',
|
||||
ext_modules=[CMakeExtension('cmake_example')],
|
||||
ext_modules=[CMakeExtension('komputepy')],
|
||||
cmdclass=dict(build_ext=CMakeBuild),
|
||||
zip_safe=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ if(KOMPUTE_OPT_ANDOID_BUILD)
|
|||
${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp)
|
||||
endif()
|
||||
|
||||
add_library(kompute
|
||||
add_library(
|
||||
kompute STATIC
|
||||
${kompute_CPP})
|
||||
|
||||
target_include_directories(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue