Question on How to manual schedule and optimize the front model?

If I import the pytorch model, in the function relay.build, How can I manual optimze the model besides the relay pass?

Hmm so there are different levels of representation for the operations in the model. Relay which is graph level representation, it is like your standard dataflow graph, e.g. in tensorflow or onnx.

These get lowered down to TIR eventually which is something that looks like actual code with for loops. I’m guessing you are looking to optimize TIR level stuff?

If I use the function “relay.build”, it will transform the relay module to actucal machine code, did I understand right? How can I do something to optimize the TIR in the function “relay.build”?

“relay.build” will transfer relay IR to lower IR(TIR) first then codegen to machine code, you can optimize the TIR in your tvm pass.

1 Like

I’m confused with the tvm pass and the schedule, can you tell me the difference between tvm pass and the schedule?

“Schedule” includes some Primitives and generates IR at last, “Pass” can be understood as a function which can modify the IR.

Thank you very much. I want to continue to confirm whether the primitive functions are Tensor Expressions.

No. As I know, primitive functions is a Relay Function which CallNode’s op is OpNode not FunctionNode.

I’m sorry to disturb you again, does that mean relay.build won’t get the Tensor Expression, it will directly make the Relay IR → Relay Primitives->TIR?