EnzymeAD / EnzymeAD/Enzyme

Compiler returned -1 when std::vector<double> is involved

Open
#2,119 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
LLVM
Stars
1.7k
Forks
188
Avg merge
1d 22h
Merged PRs (30d)
26

Description

Start to try Enzyme in Enzyme explorer. I found it does not compile when a runtime size container is involved, e.g. std::vector, as in the following example,

double dprod(const std::vector& v) {
double r = 1;
for (int i = 0; i < v.size(); i++) {
r *= v[i];
}
return r;
}

double g(double x) {
std::vector v;
v.push_back(x);
v.push_back(x*x);
return dprod(v);
}

int main() {
double x = 3;
double d_x = __enzyme_autodiff((void*)g, enzyme_out, x);
printf("d_x = %g\n", d_x);
}

This is critical for us, because we need to use Eigen::MatrixXd and Eigen::VectorXd with their sizes determined at runtime. Their elements are functions of some physical design variables.

Thanks for your help!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.