Skip to content
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

Printed code for Python's fd.ops.full is incorrect #133

Closed
IvanYashchuk opened this issue Apr 5, 2023 · 1 comment · Fixed by #593
Closed

Printed code for Python's fd.ops.full is incorrect #133

IvanYashchuk opened this issue Apr 5, 2023 · 1 comment · Fixed by #593
Assignees
Labels
bug Something isn't working

Comments

@IvanYashchuk
Copy link
Collaborator

from nvfuser import FusionDefinition, DataType
import torch

def nvfuser_fusion_id3(fd : FusionDefinition) -> None :
    C0 = fd.define_constant(0, dtype=DataType.Int)
    T1 = fd.ops.full([4, 4], C0, dtype=DataType.Double)
    fd.add_output(T1)

with FusionDefinition() as fd:
    nvfuser_fusion_id3(fd)

out = fd.execute([])

print(fd) gives:

def nvfuser_fusion_id3(fd : FusionDefinition) -> None :
    S0 = fd.define_constant(0, dtype=DataType.Int)
    T1 = fd.ops.full(S0, shape=[4, 4], dtype=DataType.Double)
    fd.add_output(T1)

Above code is invalid because full's signature is full(size, fill_value, dtype).

@kevinstephano
Copy link
Collaborator

I think the fix needs to wait for Jie's python number support work. I thought about adding a temporary solution that only works for float values but Jie already has some PR's created in the old devel fork.

kevinstephano added a commit that referenced this issue Aug 8, 2023
Fixes #133.

Example from the issue:
```py
from nvfuser import FusionDefinition, DataType
import torch

def nvfuser_fusion_id3(fd : FusionDefinition) -> None :
    C0 = fd.define_constant(0, dtype=DataType.Int)
    T1 = fd.ops.full([4, 4], C0, dtype=DataType.Double)
    fd.add_output(T1)

with FusionDefinition() as fd:
    nvfuser_fusion_id3(fd)

out = fd.execute([])
```
now prints as:
```py
def nvfuser_fusion_id1(fd : FusionDefinition) -> None :
    S0 = fd.define_scalar(0, dtype=DataType.Int)
    T1 = fd.ops.full(fill_value=S0, shape=[4, 4], dtype=DataType.Double)
    fd.add_output(T1)
```
which uses a valid function signature:
```py
n [3]: fd.ops.full??
Docstring: full(self: nvfuser._C._FusionDefinition.Operators, shape: List[int], fill_value: nvfuser._C.Scalar, dtype: nvfuser._C.DataType) -> nvfuser._C.Tensor
Type:      method
```

---------

Co-authored-by: Kevin Stephano <kevin.stephano@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants