Integer type support
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 22
Description
Are integer types supported? I only get the expected answer for floats or doubles.
Correct answer with type 'float':
```c
#include
#include
#define DTYPE float
extern DTYPE __enzyme_autodiff(void*, DTYPE);
DTYPE square(DTYPE x) {
return x * x;
}
DTYPE dsquare(DTYPE x) {
return __enzyme_autodiff(square, x);
}
int main() {
for(DTYPE i=1; i<5; i++)
printf("square(%f)=%f, dsquare(%f)=%f\n", (float) i, (float) square(i), (float) i, (float) dsquare(i));
}
```
```
square(1.000000)=1.000000, dsquare(1.000000)=2.000000
square(2.000000)=4.000000, dsquare(2.000000)=4.000000
square(3.000000)=9.000000, dsquare(3.000000)=6.000000
square(4.000000)=16.000000, dsquare(4.000000)=8.000000
```
Incorrect answer with type `int':
```c
#include
#include
#define DTYPE int
extern DTYPE __enzyme_autodiff(void*, DTYPE);
DTYPE square(DTYPE x) {
return x * x;
}
DTYPE dsquare(DTYPE x) {
return __enzyme_autodiff(square, x);
}
int main() {
for(DTYPE i=1; i<5; i++)
printf("square(%f)=%f, dsquare(%f)=%f\n", (float) i, (float) square(i), (float) i, (float) dsquare(i));
}
```
```
square(1.000000)=1.000000, dsquare(1.000000)=0.000000
square(2.000000)=4.000000, dsquare(2.000000)=0.000000
square(3.000000)=9.000000, dsquare(3.000000)=0.000000
square(4.000000)=16.000000, dsquare(4.000000)=0.000000
```
Contributor guide
Assessment
This issue has not been assessed yet.