Skip to content

khaledkee/Cunder

Repository files navigation

Cunder ⚡ ⚡

Experimental C binding for LibTorch

Quick start

Usage

see playground/main.cpp

#include <cunder/c_libtorch.h>
#include <iostream>

int main()
{
	// create tensor
	float tensor_data[] = {1, 9, 1};
	int tensor_data_shape[] = {3};
	auto cunder_data_tensor = cunder_tensor_from_data_wrap(1, tensor_data_shape, tensor_data, Cunder_DType::Cunder_Float32);
	
	// print the tensor
	printf("Cunder Tensor external data: \n");
	cunder_tensor_print(cunder_data_tensor);
	cunder_tensor_print_attributes(cunder_data_tensor);

	// access tensor data
	auto *tensor_accessor = cunder_tensor_accessor_f32(cunder_data_tensor);
	for (size_t i = 0; i < 3; i++)
		std::cout << tensor_accessor[i] << ',';
	std::cout << std::endl;

	// free the tensor
	cunder_tensor_free(cunder_data_tensor);
	return 0;
}

Structure

NOTE: add LibTorch dlls and include files in external folder OR use CMake find(torch) and add argument DCMAKE_PREFIX_PATH

Roadmap

  • torch::version()
  • Create tensor from data
    • given shape create zero tensor
    • given some data (pointer) with shape create tensor
      • wrapping the data
      • cloning the data
    • Supported types:
      • bool
      • uint8
      • int8
      • int32 (int)
      • int64 (long)
      • float32
      • float64
    • access tensor data
  • Torch script jit model
    • Module struct torch::jit::Module
    • load Module torch::jit::load()
    • call eval() on Module
    • run Module on cpu (call forward() with tensors)
  • Add support to external libraries:
    • torch_sparse
    • torch_scatter

About

Experimental C binding for LibTorch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors