About compute, schedule, pattern

hi,

I am confused by compute, schedule and pattern, these three are all nnvm::Op. What’s difference between these three type ops?

Thanks

my question is how net/graph is mapping to pattern/compute/schedule?
for example net, params = from_mxnet(sym, arg_params, aux_params), how is net converted into pattern/compute/schedule in compiler.build? Because a lot of pattern have same name as schedule.

Thanks

First mxnet symbol is mapped to nnvm symbol (operator), each nnvm operator has its FCompute function registered. We can use TVM compute to define FCompute, e.g., for conv2d, it’s

conv = tvm.compute(oshape, lambda n, oc, oh, ow:
  tvm.sum(A[n, ic, oh*stride+kh, ow*stride+kw] * W[oc, ic, kh, kw], axis=[ic, kh, kw]))

TVM schedule is for optimizing the computing, e.g., reorder the loops, split axis, define cache read/write, etc.

TVM compute and schedule together defines how to calculate, in this case, conv2d operator.

Regarding the “pattern”, do you mean OpPattern? or something else?

Yes, pattern mean OpPattern. @yzhliu

OpPattern can be viewed as an attribute of an operator. Operators with same pattern can have same strategy of fusion, schedules, etc. For example, schedules element-wise operators on cpu can be pretty simple - just do parallel on the first several axes.