Skip to content

Conversation

@zhaojinxi
Copy link
Contributor

node["attrs"] and node["shape"] may read incorrect node information due to incorrect indexing, especially nodes with multiple outputs in the graph.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 4, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@masahi
Copy link
Member

masahi commented Jan 5, 2023

Can you come up a test case for this?

@zhaojinxi
Copy link
Contributor Author

@masahi Try the code below, with the old wrong code, it will print "p0 has shape: [1, 3, 4, 16]", actually it should print "p0 has shape: [3, 3, 1, 1]"

import tvm
import numpy
from tvm import relay
from tvm.contrib.debugger.debug_executor import GraphModuleDebug

x = relay.var("x", shape=(1, 3, 48, 16), dtype="float32")
t = relay.split(x, [12, 16, 32], 2).astuple()
x0 = relay.TupleGetItem(t, 0)
x1 = relay.TupleGetItem(t, 1)
x2 = relay.TupleGetItem(t, 2)
x3 = relay.TupleGetItem(t, 3)
weight = relay.const(numpy.random.uniform(-1, 1, (3, 3, 1, 1)).astype("float32"))
y = relay.nn.conv2d(x2, weight, kernel_size=(1, 1), kernel_layout="OIHW", out_dtype="float32") + x3

func = relay.Function([x], relay.Tuple([x0, x1, y]))
mod = tvm.IRModule.from_expr(func)
mod = relay.transform.InferType()(mod)
target = tvm.target.Target("llvm")
device = tvm.cpu()
lib = relay.build(mod, target=target)
m = GraphModuleDebug(lib["debug_create"]("default", device), [device], lib.get_graph_json(), ".")
nodes = m.debug_datum.get_graph_nodes()
print(nodes[2]['name'],' has shape: ',nodes[2]['shape'])

@masahi
Copy link
Member

masahi commented Jan 5, 2023

I mean, can you add that as a test, probably in unittest/test_runtime_graph_debug.py.

@zhaojinxi
Copy link
Contributor Author

I mean, can you add that as a test, probably in unittest/test_runtime_graph_debug.py.

done

@masahi masahi merged commit 721f115 into apache:main Jan 5, 2023
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
* [BugFix][Runtime] Fix Incorrect node information

* 1

* 1
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