How to schedule a model layer by layer

The tutorials give examples of how to scheduling models created by tvm code, like the following:

n = tvm.var(“n”)
A = tvm.placeholder((n,), name=‘A’)
B = tvm.placeholder((n,), name=‘B’)
C = tvm.compute(A.shape, lambda i: A[i] + B[i], name=“C”)
s = tvm.create_schedule(C.op)

But models are usually imported from mxnet, tensorflow etc. Like the following:

from mxnet.gluon.model_zoo.vision import get_model
block = get_model(‘resnet18_v1’, pretrained=True)
shape_dict = {‘data’: x.shape}
func, params = relay.frontend.from_mxnet(block, shape_dict)

I want to schedule the model layer by layer differently, for example different layer with different split. But the func is not a ComputeOp object needed by tvm.create_schedule(). How to do this layer by layer schedule?

Take a look at the autotvm tutorials (the ones that say “network” in the title).

I found the schedule in subdirectories of path /topi/python/topi for many backends, the schedules seem very complex and need further delve into.

Another question:
The function define_split() will enumerate only factors of axis’s length. If I need enumerate not only factors, how to do it?

Thanks a lot!

You can create arbitrary options by using candidates instead:
https://docs.tvm.ai/api/python/autotvm.html#tvm.autotvm.task.space.ConfigSpace.define_split

Thanks! I’m just a new learner :grinning: