haojin2 commented on a change in pull request #17084: [numpy] add op median
URL: https://github.com/apache/incubator-mxnet/pull/17084#discussion_r359132590
 
 

 ##########
 File path: src/operator/numpy/np_broadcast_reduce_op_value.cc
 ##########
 @@ -320,6 +321,36 @@ NNVM_REGISTER_OP(_backward_np_average)
     return std::vector<ResourceRequest>{ResourceRequest::kTempSpace};
 });
 
+inline bool NumpyMedianType(const nnvm::NodeAttrs& attrs,
+                              std::vector<int> *in_attrs,
+                              std::vector<int> *out_attrs) {
+  CHECK_EQ(in_attrs->size(), 1U);
+  CHECK_EQ(out_attrs->size(), 1U);
+
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, mshadow::kFloat32);
+  return out_attrs->at(0) != -1 && in_attrs->at(0) != -1;
+}
+
+NNVM_REGISTER_OP(_npi_median)
+.set_num_inputs(1)
+.set_num_outputs(1)
+.set_attr_parser(ParamParser<NumpyMedianParam>)
+.set_attr<mxnet::FInferShape>("FInferShape", NumpyMedianShape)
+.set_attr<nnvm::FInferType>("FInferType", NumpyMedianType)
+.set_attr<nnvm::FListInputNames>("FListInputNames",
+  [](const NodeAttrs& attrs) {
+    return std::vector<std::string>{"a"};
+  })
+.add_argument("a", "NDArray-or-Symbol", "The input")
+.add_arguments(NumpyMedianParam::__FIELDS__())
+.set_attr<FCompute>("FCompute<cpu>", NumpyMedianForward<cpu>)
+.set_attr<FResourceRequest>("FResourceRequest",
+  [](const NodeAttrs& attrs) {
+    return std::vector<ResourceRequest>{ResourceRequest::kTempSpace};
+  })
+// .set_attr<THasDeterministicOutput>("THasDeterministicOutput", true)
 
 Review comment:
   get rid of unused code

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

Reply via email to