Skip to content

[TOPI] Fix nn.lrn result dtype on fp16 - #11032

Merged
junrushao merged 1 commit into
apache:mainfrom
wrongtest-intellif:fix_lrn_f16
Apr 19, 2022
Merged

junrushao merged 1 commit into
apache:mainfrom
wrongtest-intellif:fix_lrn_f16

Conversation

@wrongtest-intellif

@wrongtest-intellif wrongtest-intellif commented Apr 17, 2022

Copy link
Copy Markdown
Contributor

The buggy script as below:

import tvm
from tvm import relay
from tvm.contrib import graph_executor
x = relay.var("x", shape=[1, 3, 224, 224], dtype="float16")
y = relay.nn.lrn(x)
mod = tvm.IRModule.from_expr(relay.Function([x], y))
lib = relay.build(mod, target="llvm")
f = graph_executor.GraphModule(lib["default"](tvm.cpu()))
f.run()

The error I get is

Check failed: ret == 0 (-1 vs. 0) : Assert fail: (((tir.tvm_struct_get(arg.T_divide, 0, 5) == (uint8)2) && (tir.tvm_struct_get(arg.T_divide, 0, 6) == (uint8)32)) && (tir.tvm_struct_get(arg.T_divide, 0, 7) == (uint16)1)), arg.T_divide.dtype is expected to be float32

@MasterJH5574 MasterJH5574 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! The code example you provided can run successfully on my machine. Looks like you should use float16 to reproduce the error 👀.

Besides that I have one minor question. Would be great if you can have a look, thanks!

Comment thread tests/python/topi/python/test_topi_lrn.py

@MasterJH5574 MasterJH5574 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@junrushao
junrushao merged commit b78e44e into apache:main Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants