[Solved] Hybrid Frontend Passing Var error


#1
import tvm

@tvm.hybrid.script
def test(a, b, val):
    for i in range(a.shape[0]):
        b[i] = a[i] * val
    return b


if __name__ == '__main__':
    a_plc = tvm.placeholder((5,))
    b_plc = tvm.placeholder((5,))
    val_v = tvm.const(0.5, dtype="float32")
    c = test(a_plc, b_plc, val_v)
    print(c)

returns following error:

Traceback (most recent call last):
  File "test_tvm_ssd.py", line 20, in <module>
    c = test(a_plc, b_plc, val_v)
  File "<decorator-gen-130>", line 2, in test
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tvm-0.5.dev0-py3.6-macosx-10.11-x86_64.egg/tvm/hybrid/api.py", line 25, in wrapped_func
    if _is_tvm_arg_types(args):
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tvm-0.5.dev0-py3.6-macosx-10.11-x86_64.egg/tvm/hybrid/util.py", line 54, in _is_tvm_arg_types
    raise ValueError("Expect a Var or Tensor instance but % get!" % str(type(elem)))
TypeError: must be real number, not str

@were


#2

OK. I know the problem now.
So far only var and tensors are supported.
Thus, the correct way to invoke this function is

val_v = tvm.var(dtype='float32')

c = test(a, b, v)
#after compilation you can pass a const
#like this!
module(nd_a, nd_b, 1.5)

#3

OK. I think for ssd op, we need to support passing values.


#4

new pr has supported this requirement…


#5

Check this commit out, #2257.