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

[Bug] Wrong results of cast<int32>( cast<bool>(-1i64) ) #13048

Closed
ganler opened this issue Oct 11, 2022 · 0 comments · Fixed by #13056
Closed

[Bug] Wrong results of cast<int32>( cast<bool>(-1i64) ) #13048

ganler opened this issue Oct 11, 2022 · 0 comments · Fixed by #13056
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@ganler
Copy link
Contributor

ganler commented Oct 11, 2022

Expected behavior

cast<int32>( cast<bool>(-1i64) ) should be 1.

Actual behavior

cast<int32>( cast<bool>(-1i64) ) returns wrong results (i.e., -1) in optimized graph runtime.

Environment

fa17da2 on Ubuntu 20.04.

Steps to reproduce

Preferably a minimal script to cause the issue to occur.

import tvm
from tvm import relay
import numpy as np

i0 = relay.var("i0", shape=(1,), dtype="int64")
cast_bool = relay.cast(i0, "bool")
cast_int32 = relay.cast(cast_bool, "int32")

f = relay.Function([i0], cast_int32)
input = np.array([-1], dtype="int64")
opt_res = relay.create_executor("graph", device=tvm.cpu()).evaluate(f)(input)
debug_res = relay.create_executor("debug", device=tvm.cpu()).evaluate(f)(input)
print(f"debug_res: \t{debug_res}") # [-1]
print(f"opt_res: \t{opt_res}")     # [1]

Triage

Please refer to the list of label tags linked above to find the relevant tags and add them here in a bullet format (example below).

  • needs-triage
@ganler ganler added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant