@tvm.hybrid.script
def outer_product(a, b, c):
c = output_tensor((100, 99), ‘float32’)
for i in range(a.shape[0]):
for j in range(b.shape[0]):
c[i, j] = a[i] * b[j]
return c
a = numpy.random.randn(100)
b = numpy.random.randn(99)
c = outer_product(a, b)
i, j = c.op.axis
sch = tvm.create_schedule(op)
jo, ji = sch.split(j, 4)
sch.vectorize(ji)
The clear point is that Hybrid script support schedule primitives and tvm extern don’t,How about the other differences?
They are pretty much different thing. tvm.extern basically allows you plug-in anything as long as they are packed function, while hybrid script is like yet another way to build tvm’s low-level ir.
Thanks!
I meet with another question,i use hybrid script and bind in/out tensor with decl_buffer specified with strides, then build error occurred:
File “/home/zhoujian/TVM/tvm_github/tvm/src/pass/storage_flatten.cc”, line 429
TVMError: Check failed: slice->strides.size() == 0U (2 vs. 0) : Trying to bind compact buffer to strided one strides=[VA0,
Refer to “tvm/python/hybrid/runtime.py”, the hybrid output_tensor is realized with numpy array that don’t support strides.
In contrast, tvm.extern support binding input and output with decl_buffer using strides.
Will the hybrid support strides buffer in the future? @were