Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A tensor operation and automatic differentiation framework in C

NotificationsYou must be signed in to change notification settings

physical-computation/pascal

Repository files navigation

Pascal is a tensor operation and automatic differentiation framework written in C. It contains modules that can carry out operations on tensors, similar toNumPy Arrays,PyTorch Tensors, and other popular tools. Pascal can also carry out reverse-mode automatic differentiation using thepascal-autodiff module.

Requirements

Pascal can run using several backends. By default, Pascal usesclapack, which is included in this repository. Therefore you do not need any other requirements, other than a C compiler.

Pascal uses either acblas or alibgsl backend to carry out some operations. Thus, these should be installed. TheMakefile includes flags that should point to standard locations. If these don't work, please updated theINCLUDE_FLAGS,LDFLAGS andFRAMEWORK_FLAGS variables in theconfigs/default.conf as needed. Alternatively, you can create a new configuration file (.conf) in theconfigs folder and update theCONFIGURATION variable in theMakefile (note that if your new configuration isconfigs/new-config.conf,CONFIGURATION should be set tonew-config).

CBLAS and GSL on MacOS

On MacOS, these are included in theAccelerate framework. This is installed with the XCode command-line tools, by running:

xcode-select --install

Currently,default.conf assumes thatlibgsl is installed usinghomebrew by running:

brew install gsl

If you install it using other means, please update theINCLUDE_FLAGS andLDFLAGS in the correct if-else block.

CBLAS and GSL on Linux

To be written

Build

To use this package, simply clone this repository. This can be done as:

git clone --recursive https://github.com/physical-computation/pascal.git

Note

The--recursive is important since this repository uses submodules. This also means that if you use Pascal as a submodule to another repository, you need to run the following after adding the Pascal submodule.

git submodule update --init --recursive

Then you can build it using

make

This creates a library file inlibs/

To test, run:

make test

If everything worked well, this will print:

tests/load_data/test; tests/tensor_integration/test; tests/tensor/test; tests/tensor_random_sample/test; tests/tensor_utils/test; tests/autodiff/test; tests/autodiff_primitives/test; tests/tensor_broadcast/test; tests/tensor_iterate/test;Running testsin load_data:Completed:       3/3 passedin 596µsRunning testsin pascal_tensor_integrations:Completed:       15/15 passedin 192µsRunning testsin tensor:Completed:       48/48 passedin 372µsRunning testsin pascal_tensor_random_sample:Completed:       2/2 passedin 3µsRunning testsin pascal_tensor_utils:Completed:       8/8 passedin 10µsRunning testsin autodiff:Completed:       15/15 passedin 273µsRunning testsin autodiff_primitives:Completed:       19/19 passedin 106µsRunning testsin pascal_tensor_broadcast:Completed:       3/3 passedin 12µsRunning testsin pascal_tensor_iterate:Completed:       6/6 passedin 8µs

Examples and Benchmarks

Note

Currently, the Makefiles inexamples/ andbenchmarks/ are written to work withmacOS only.

A basic implementation of a tensor operation usingPascal is

The examples and benchmarks use Python to run some analyses and baselines. It is recommended that you use a virtual environment. Install the required packages using

pip install -r requirements.txt

Please see theexamples/ folder. It includes a few simple examples of using the functionality that Pascal offers. TheMakefiles in these folders currently only supportmacOS. However, they should be a useful guide for other platforms: you can think of them as compiling your application while includinglibpascal.a (which gets created when you runmake).

Running examples

All examples can be executed by running the following from the root directory of this project:

make examples

Individual examples can be executed using the following syntax:

make eg-<example>

<example> can be replaced by the names of the folders inside ofexamples/, such asnn-simple andbnn-simple.

Running benchmarks

We currently compare some of our tensor operations againstNumPy. To run these benchmarks, run

make benchmarks

Documentation

There is a set of incomplete documentation indocs/. If you loaddocs/html/index.html locally, you can navigate this documentation on your browser.

Furthermore, documentation comments can be found on some of the function ininclude/pascal.h.

About

A tensor operation and automatic differentiation framework in C

Resources

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp