-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add differentiable support #10
Comments
This repo contains a build script to compile gmp@5.1.1, mpfr@3.1.1 and boost@1.49.0 emscripten. |
After following the instructions above I compiled the following test: #include <emscripten.h>
#include <vector>
#include <iostream>
#include <audi/gdual.hpp>
#include <dcgp/wrapped_functions.hpp>
extern "C"
{
double EMSCRIPTEN_KEEPALIVE my_calc()
{
std::vector<audi::gdual<double>> my_vect;
my_vect.emplace_back(1.1, "x", 1);
my_vect.emplace_back(1.2, "y", 1);
auto result = dcgp::my_sum<audi::gdual<double>>(my_vect);
return result.constant_cf();
}
void EMSCRIPTEN_KEEPALIVE gdual_evaluation()
{
gdual<double> x1(1., "x1", 2);
gdual<double> x2(1., "x2", 2);
auto f = x1 * x1 + x2;
std::cout << f.evaluate({{"dx1", 1.}, {"dx2", 1.}}) << "\n";
}
} Which for Compiling was done with the following steps: emcc wrapped_functions_test.cpp -o wrapped_functions_test.bc -I/usr/local/include -I/usr/include/eigen3 -std=c++11
emcc wrapped_functions_test.bc /usr/local/lib/libmpfr.a /usr/local/lib/libgmpxx.a /usr/local/lib/libgmp.a -o wrapped_functions_test.html Note: when running the commands above it gave an error saying that asm2wasm was not found. This was because it was searching in the 64 bit binaryen folder instead of in the installed 32 bit binaryen folder. Simply copying the 32 bit folder and naming it the 64 bit folder resolved this error. cp -a ~/emsdk/binaryen/tag-1.38.27_32bit_binaryen/. ~/emsdk/binaryen/tag-1.38.27_64bit_binaryen/ |
Enabling the The compiling steps became: emcc wrapped_functions_test.cpp -o wrapped_functions_test.bc -I/usr/local/include -I/usr/include/eigen3 -std=c++11 -s USE_PTHREADS=1
emcc wrapped_functions_test.bc /usr/local/lib/libmpfr.a /usr/local/lib/libgmpxx.a /usr/local/lib/libgmp.a -o wrapped_functions_test.html -s USE_PTHREADS=1 |
Add differentiable support by compiling with AuDi.
Dependencies
Requirements
i386/ubuntu:latest
.m4
,build-essentials
,gcc-multilib
,git
,cmake
,curl
,node.js
andpython
. I use the following command to install the dependencies:Note: the command
ln /usr/bin/python3.6 /usr/bin/python
is needed to accesspython
on the comand line instead of using Python withpython3.6
.Compilation steps
Boost
Eigen
gmp
mpfr
mp++
piranha
audi
dcgp
Resources
The following links might be helpful for figuring out how to compile all the necessary libraries correctly.
The text was updated successfully, but these errors were encountered: