samskalicky commented on issue #17069: fix for number of inputs/outputs for backward custom ops URL: https://github.com/apache/incubator-mxnet/pull/17069#issuecomment-565735956 > Hi. What is `inputs` and `outpus`? Do they have the same meaning in forward and backward? In the forward pass, an operator takes its inputs and produces its outputs. In the backward pass, an operator receives an input gradient for each of its outputs and produces an output gradient for each of its inputs. The picture looks something like this:  In the forward pass the inputs are: A,B and the outputs are: C In the backward pass the inputs are: dC, A, B, C and the outputs are: dA, dB In MXNet you can specify which inputs/outputs from the forward function you want to keep for the backward pass. To simplify the first commit of custom op we just made it so that every possible input/output was available during the backward pass. Heres the code where we tell MXNet that we want to have all inputs/outputs available for the backward function: https://github.com/apache/incubator-mxnet/blob/bbdc1c3627ad5254c049c2bb871ecb4527d7dc14/src/c_api/c_api.cc#L498-L512 grad_reg is an input when registering the FGradient attribute on the forward function: https://github.com/apache/incubator-mxnet/blob/bbdc1c3627ad5254c049c2bb871ecb4527d7dc14/src/c_api/c_api.cc#L666 So the fix here is to correctly tell MXNet how many inputs and outputs we have for the backward pass. Previously MXNet wasnt checking or erroring out when the numbers didnt match. But @ptrendx is implementing a new feature to check #17049 so this fix will help him continue.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
