spcl / spcl/dace

f32 is not infered on basic mult

Open
#1,493 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
593
Forks
163
Avg merge
2d 23h
Merged PRs (30d)
60

Description

Consider this snippet:
```
import numpy as np
import dace

@dace.program
def dace_float_cast(A, B, timestep: dace.float32):
dt2: dace.float32 = 2 * timestep
A[:] = B[:] * dt2

A = np.zeros(10, dtype=np.float32)
B = np.zeros(10, dtype=np.float32)
t = np.float32(250.0)

dace_float_cast(A, B, t)
```

SDFG & code generated (below) show `dt2` is consider a 64-bit float, despite the cast.

```
...
double dt2;
{
float __in2 = timestep;
double __out;

///////////////////
// Tasklet code (_Mult_)
__out = (dace::float64(2) * dace::float64(__in2));
///////////////////

dt2 = __out;
}
...
```

SDFG (not a real zip, just going around GitHub) [program.sdfg.zip](https://github.com/spcl/dace/files/13814316/program.sdfg.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the provided dace_float_cast example and inspecting program.sdfg.zip alongside the generated code. Trace how the annotated timestep and the multiplication by 2 are typed, then verify that the generated dt2 and its arithmetic use float32 rather than float64.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.