- Notifications
You must be signed in to change notification settings - Fork1
physical-computation/pascal
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
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.
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).
On MacOS, these are included in theAccelerate framework. This is installed with the XCode command-line tools, by running:
xcode-select --installCurrently,default.conf assumes thatlibgsl is installed usinghomebrew by running:
brew install gslIf you install it using other means, please update theINCLUDE_FLAGS andLDFLAGS in the correct if-else block.
To be written
To use this package, simply clone this repository. This can be done as:
git clone --recursive https://github.com/physical-computation/pascal.gitNote
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 --recursiveThen you can build it using
makeThis creates a library file inlibs/
To test, run:
make testIf 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
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.txtPlease 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).
All examples can be executed by running the following from the root directory of this project:
make examplesIndividual 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.
We currently compare some of our tensor operations againstNumPy. To run these benchmarks, run
make benchmarksThere 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
Uh oh!
There was an error while loading.Please reload this page.