Giter Site home page Giter Site logo

tensor's Introduction

A fast c++ tensor library

Tensor

Tensor is a c++ tensor expression library. It is designed with both speed and clarity of expression in mind. It it thus intended to provide high levels of performance but allow operations on tensors in the code to appear exactly as they do mathematically.

Template metaprogramming is used to 'offload' any work which can be computed at compile time, to the compiler and expression templates are used to achieve the translation of the mathematically expressed code to high performance code.

Tests have been written using the Boost Test library to verify the 'correctness' of all the implemented components. The tests also help to illustrate the usage of the various components of the library.

The long term goal is to develop something along the lines of the tensor library in the python theano libray, but with support for any rank tensors with both CPU and GPU functionality.

Documentation

Please see Tensor Documentation for documentation and usage examples.

Current Status

Currently the library is CPU only and is single-threaded as the development process has just begun. However, the library will be extended to include GPU functionality (with CUDA and probably also OpenCL) and multi-threading (and therefore multi-core CPU - probably with OpenMP and MPI).

There is quite a lot of functionality which is working at present, however, the first iteration of the development used vectors as the data containers. I feel that a lot of performance improvement can be achieved by using static containers and the properties of the tensor which come with knowing the sizes of the dimensions when the tensor is created.

I did some tests with comparing static vs dynamic tensors and the static tensors were up to 20x faster than dynamic tensors, and even faster than std::array for element access as the static tensors do the mapping using the dimension sizes at compile time.

I thus decided to completely redesign the interface, allowing a selection between the static and dynamic tensors, as well as a selection between CPU and GPU implementations.

Dependencies

  • nano : A template metaprogramming library, is used to offload some of the work to the compiler, for example things like index mapping for slicing and multiplication.
  • boost unit : For the unit testing component of the library. This is not necessary of you aren't running the tests.

Building

Nano

You can get the nano library from here - nano - it is a header only library. By default it is installed to usr/include. If you install it somewhere else make sure that it is on your path so that tensor can find it.

Boost

You can get the Boost test library from here - Boost - and follow the Getting Started Guide to install the libraries.

Note: You only need the test library, but it is dynamically linked in the tensor tests provided with the tensor library, so you should install it to allow dynamic linking (i.e install the test library and not just the .hpp file.)

CUDA

GPU functionality is not currently implemented so nothing to be done here.

Compiling

Tensor has been tested with the following compilers

  • g++ (4.9.1)
  • clang++ (3.6.1)

Since tensor is (currently) a header-only library, there is nothing to install if you would just like to use it in your own application. However, tests are provided with tensor so ensure that everything is working as expected as well as to provide examples of the usage of tensor.

To compile the tests, cd into tests/, at which point you are provided with a few options:

  • Make all the tests
  • Make an individual tests

All tests

To make all the tests, simply issue

make all (or make -jN all -- to make in parallel with N processes)

Individual tests

The following individual test components are provided

  • tensor : tests related to tensors specifically
  • traits : tests for the tensor traits
  • container : tests for the tensor containers
  • operations : tests for the operations (addition, subtraction etc...)

To make an individual tests, issuse

make <test_name>

with the appropriate test name, for example make container

Cleaning

To clean the tests, issue

make clean

tensor's People

Contributors

robclu avatar

Stargazers

Nick Firoozye avatar  avatar mnh avatar  avatar Charles Zu avatar Sreekumar Thaithara Balan avatar  avatar harold avatar  avatar Dhairya Malhotra avatar Yiran Wang avatar

Watchers

James Cloos avatar  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.