GithubHelp home page GithubHelp logo

thompsonhe / onetensordev Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matrix97317/onetensor

0.0 0.0 0.0 2.09 MB

This is a simple and easy-to-use Tensor Library.

C++ 16.66% Python 2.23% Cuda 77.46% CMake 3.66%

onetensordev's Introduction

OneTensor

This is a simple and easy-to-use Tensor Library.

1. Installation

$ cd one_tensor
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install

2. Usage

#include <one_tensor.h>

OneTensor<int8_t> a(Shape(8,16));
OneTensor<int8_t> b(Shape(8,16));
OneTensor<int32_t> c(Shape(8,8));
OneTensor<int32_t> d(Shape(8,8));
c.FillHostData(0);
d.FillHostData(0);
for(int i=0; i<a.shape.d0; i++){
    for(int j=0; j<a.shape.d1; j++){
        int index = i*a.shape.d1+j;
        a.SetHostData(j,index);
        b.SetHostData(j,index);
    }
}
a.HostDataView();

a.sync_device();
b.sync_device();
c.sync_device();
d.sync_device(); // Send Host Data to Device
d.sync_device(false); // Send Device Data to Host

int8_t *  ptr = a.deviceData<int8_t>();

// Measure your kernel time.
cudaStream_t stream;
cudaStreamCreate(&stream);
int iter_nums = 100;
GPU_Time((your_func)), stream, iter_nums);

// Load .npy or npz file from numpy
OneTensor<float> npz_file("./test_data.npz","data");
std::cout<<npz_file.shape<<std::endl;
npz_file.HostDataView();

OneTensor<float> npy_file("./test_data.npy");
std::cout<<npy_file.shape<<std::endl;
npy_file.HostDataView();

onetensordev's People

Contributors

matrix97317 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.