Both tvm extern and hybrid script can define python function by userself, like below:
(1) tvm extern
@tvm.register_func(“tvm.contrib.my_tvm_addone”)
def my_tvm_addone(x, y):
print(“my_tvm_addone signatures: %s, %s” % (type(x), type(y)))
tvm.nd.array(x.asnumpy() + 1).copyto(y)A = tvm.placeholder((n,), name=‘A’)
B = tvm.extern(A.shape, [A], lambda ins, outs: tvm.call_packed( “tvm.contrib.my_tvm_addone”, ins[0], outs[0]), name=“C”)
s = tvm.create_schedule(B.op)
(2) hybrid script
@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 ca = 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?