Feature request: Allow `-enzyme-auto-sparsity=1` to successfully compile if the Jacobian is null
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
The current behavior of `-enzyme-auto-sparsity=1` is to error out when the resulting Jacobian is null with the message:
```
Found no stores for sparsification
```
This is technically correct, but it leaves some automation on the table.
In GridKit, e.g. [PR 364](https://github.com/ORNL/GridKit/pull/364), we are having to specialize some Jacobian evaluations for models where we know which terms are null. However, this requires the adequate selection of the the specializations by the developers with some understanding of the equations implemented. This approach will not be sustainable long term as the complexity of the equations increases and the multivariate dependencies get less obvious. it would be great if Enzyme could return without error in those cases (perhaps with a warning).
Essentially, I would like the following to be able to compile `__enzyme_fwddiff` for the null $\frac{\partial f}{\partial y}$ with `-enzyme-auto-sparsity=1`
```cpp
void residual(size_t n, double* x, double* y, double * f)
{
for (size_t i = 0; i < n; ++i)
{
f[i] = some_sparse_expression(x); // no dependency on y
}
}
```
cc @pelesh @wsmoses
Contributor guide
Assessment
This issue has not been assessed yet.