MoisesHer commented on a change in pull request #19460:
URL: https://github.com/apache/incubator-mxnet/pull/19460#discussion_r527472773



##########
File path: src/operator/nn/softmax.cc
##########
@@ -187,5 +188,54 @@ NNVM_REGISTER_OP(_backward_softmax)
 #endif
 .set_attr<FCompute>("FCompute<cpu>", SoftmaxGradCompute<cpu, 
op::mshadow_op::mul,
                                                         
mxnet_op::softmax_bwd>);
+
+NNVM_REGISTER_OP(masked_softmax)
+.add_alias("_npx_masked_softmax")
+.describe(R"code(Applies the softmax function masking elements according to 
the mask provided)code" ADD_FILELINE)
+.set_attr_parser(ParamParser<MaskedSoftmaxParam>)
+.set_attr<nnvm::FListOutputNames>("FListInputNames",
+    [](const NodeAttrs& attrs){
+    return std::vector<std::string>{"data", "mask"};
+})
+.set_attr<nnvm::FListOutputNames>("FListOutputNames",
+    [](const NodeAttrs& attrs) {
+    return std::vector<std::string>{"output"};
+})
+.set_attr<FCompute>("FCompute<cpu>", MaskedSoftmaxCompute<cpu, 
mxnet_op::softmax_fwd>)
+.set_attr<nnvm::FGradient>("FGradient", 
ElemwiseGradUseInOut{"_backward_masked_softmax"})

Review comment:
       is this not equivalent to 
https://github.com/apache/incubator-mxnet/blob/95a8d41bf48c7716df361c117aeef65fb120c79c/src/operator/nn/softmax-inl.h#L1642-L1646
 
   ?




----------------------------------------------------------------
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]


Reply via email to