apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.75k stars 3.47k forks source link

[Bug][Parser] Uable to parse 'broadcast_to' operator #12536

Open HaoKang-Timmy opened 2 years ago

HaoKang-Timmy commented 2 years ago

Hi, I want to use tvm.parse.parse_expr. But it can not parse operator 'broadcast_to'. Here is the code.


import tvm
from tvm import relay, auto_scheduler
from tvm.relay import data_dep_optimization as ddo
import tvm.relay.testing
from tvm.contrib import graph_executor
from tvm.contrib.utils import tempdir

a = relay.var("a", shape=[1, 10])
out = relay.broadcast_to(a, shape=[1,10])
func = relay.Function([a], out)

SEMVER = '#[version = "0.0.5"]\n'
code = str(func)
expr = tvm.parser.parse_expr(SEMVER + code)
print(expr)

'''
error: unable to determine the 'attrs_type_key' with which to represent the call attributes for this operator
 --> string:3:3
   |  
 3 |    broadcast_to(%a, shape=[1, 10])
   |    ^^^^^^^^^^^^                   
'''

Is there any way to avoid this problem?

HaoKang-Timmy commented 2 years ago

@mbs-octoml Hi, would it be possible for you to look at this problem? Thanks

HaoKang-Timmy commented 2 years ago

Could you please look at this problem, please? @jroesch

AIYoungcino commented 2 years ago

Could you please look at this problem, please?@mbs-octoml

cery999 commented 2 years ago

@mbs-octoml Hi, would it be possible for you to look at this problem? Thanks

x = relay.var("x", relay.TensorType(shape, "float32")) y = relay.var("y", relay.TensorType(broadcast_shape, "float32")) z = relay.broadcast_to(x, shape=relay.shape_of(y))

maybe this help? broadcast must determinate the tensor type. weather in your case, the dtype is unknown