Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TensorLib

About


TensorLib is a C library that is capable of doing linear algebra operations on N-dimension tensors, without memory copies. It does this by using strides and broadcasting, resulting in shared data but different tensor interpretations. TensorLib is heavily inspired by other libraries, and aims to achieve similar results to NumPy.

How to Build (Library)


Prerequisites

Build steps

  1. Clone the repo by using the following command in the terminal
git clone https://github.com/Daschle-Newberry/TensorLib
cd TensorLib
  1. Generate library
make
  1. Optionally run test executable
make run

Example

#inlcude "tensor.h"

void main(){
    Tensor out;
    Tensor a;
    Tensor b;
    
    //Intialize tensor a
    tensor_from_data(&a, (float[]){1,2,3,4}, (int[]){2,2},2);
    
    //Intialize tensor b
    tensor_from_data(&b, (float[]){1,2}, (int[]){1,2},2);
    
    //Compute the matrix multiplication of a and b
    tensor_mat_mul(&out, &a, &b);
    
    //Print the result
    char* buff = tensor_to_string(&out);
    printf("%s\n", buff); 

    //free memory
    free(buff);
    tensor_destroy(&a);
    tensor_destroy(&b);
    tensor_destroy(&out);
}

Features


Tensor Handling

  • Variety of initialization tools, including from data, empty, zeros, ones, or fill.
  • Tensor view tools such as column promotion, expand, ect.
  • Debug and visualization tools such as metadata to string or tensor to string.
  • Type generic tensors

Tensor Operations

  • Elementwise broadcasting
  • Matrix broadcasting
  • Elementwise addition, subtraction, multiplication, and division.
  • Matrix multiplication
  • Matrix transpose
  • Scalar multiplication
  • Type generic operations

Optimizations

  • SIMD
  • GPU acceleration
  • BLAS

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages