Implement FTVMCompute for Operator _max_pool2d_grad

Hi, I’m new to tvm and trying to compile the gradient of the operator max_pool2d, and it throws an error like “Attribute FTVMCompute has not been registered for Operator _max_pool2d_grad”.
How to add the missing computation method?

I see in topi/include/topi/nn/pooling.h, it use tvm::max to compute max_pool2d, and according to this discussion, we should find the position of the max element (which sounds like argmax).

Is it a good idea to add an operator like argmax in src/lang/ir_operator.cc? Or any other suggestions on how to implement _max_pool2d_grad.

Hi,

Usually we add backward for operator through FGradient attribute. Here is an example for conv2d:https://github.com/dmlc/tvm/blob/master/nnvm/src/top/nn/convolution.cc#L221

If the backward operator is complicate, we may want to define a separate operator to deal with it, just like gradient of conv2d. If the backward logic is simple, we can directly implement it inside FGradient, such as dense: https://github.com/dmlc/tvm/blob/master/nnvm/src/top/nn/nn.cc#L91