You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/08/22 23:56:27 UTC

[GitHub] samskalicky commented on a change in pull request #12284: [MXNET-853] Fix for smooth_l1 operator scalar default value

samskalicky commented on a change in pull request #12284: [MXNET-853] Fix for smooth_l1 operator scalar default value
URL: https://github.com/apache/incubator-mxnet/pull/12284#discussion_r212146515
 
 

 ##########
 File path: src/operator/tensor/elemwise_binary_scalar_op_extended.cc
 ##########
 @@ -98,17 +98,37 @@ where :math:`x` is an element of the tensor *lhs* and :math:`\sigma` is the scal
 
 Example::
 
+  smooth_l1([1, 2, 3, 4]) = [0.5, 1.5, 2.5, 3.5]
   smooth_l1([1, 2, 3, 4], scalar=1) = [0.5, 1.5, 2.5, 3.5]
 
 )code" ADD_FILELINE)
-.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<
-  cpu, mshadow_op::smooth_l1_loss>)
+.set_num_inputs(1)
+.set_num_outputs(1)
+.set_attr_parser([](NodeAttrs* attrs) {
+    if(attrs->dict.find("scalar") != attrs->dict.end())
+      attrs->parsed = std::stod(attrs->dict["scalar"]);
+    else
+      attrs->parsed = 1.0;
+  })
+.set_attr<nnvm::FInferShape>("FInferShape", ElemwiseShape<1, 1>)
+.set_attr<nnvm::FInferType>("FInferType", ElemwiseType<1, 1>)
+.set_attr<nnvm::FInplaceOption>("FInplaceOption",
+				[](const NodeAttrs& attrs){
+				  return std::vector<std::pair<int, int> >{{0, 0}};
+				})
 
 Review comment:
   sorry, new editor not setup properly....

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services