[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for np.sum, np.std, np.var and np.average

2020-04-01 Thread GitBox
haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for 
np.sum, np.std, np.var and np.average
URL: https://github.com/apache/incubator-mxnet/pull/17866#discussion_r402010664
 
 

 ##
 File path: python/mxnet/ndarray/numpy/_op.py
 ##
 @@ -1734,13 +1734,13 @@ def histogram(a, bins=10, range=None, normed=None, 
weights=None, density=None):
 if isinstance(bins, numeric_types):
 if range is None:
 raise NotImplementedError("automatic range is not supported 
yet...")
-return _npi.histogram(a, bin_cnt=bins, range=range)
+return _api_internal.histogram(a, None, bins, range)
 
 Review comment:
   Done


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for np.sum, np.std, np.var and np.average

2020-04-01 Thread GitBox
haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for 
np.sum, np.std, np.var and np.average
URL: https://github.com/apache/incubator-mxnet/pull/17866#discussion_r402010277
 
 

 ##
 File path: src/api/operator/numpy/np_histogram_op.cc
 ##
 @@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_histogram_op.cc
+ * \brief Implementation of the API of functions in 
src/operator/tensor/histogram.cc
+ */
+
+#include 
+#include 
+#include "../utils.h"
+#include "../../../operator/tensor/histogram-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.histogram")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  nnvm::NodeAttrs attrs;
+  const nnvm::Op* op = Op::Get("_npi_histogram");
+  op::HistogramParam param;
+  // parse bin_cnt
+  if (args[2].type_code() == kNull) {
+param.bin_cnt = dmlc::nullopt;
+  } else {
+param.bin_cnt = args[2].operator int();
+  }
+
+  // parse range
+  if (args[3].type_code() == kNull) {
+param.range = dmlc::nullopt;
+  } else {
+param.range = Tuple(args[3].operator ObjectRef());
+  }
+
+  attrs.parsed = std::move(param);
+  attrs.op = op;
+  SetAttrDict();
+
+  std::vector inputs_vec;
+  int num_inputs = 0;
+
+  if (param.bin_cnt.has_value()) {
 
 Review comment:
   Done


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for np.sum, np.std, np.var and np.average

2020-04-01 Thread GitBox
haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for 
np.sum, np.std, np.var and np.average
URL: https://github.com/apache/incubator-mxnet/pull/17866#discussion_r402010064
 
 

 ##
 File path: python/mxnet/ndarray/numpy/_op.py
 ##
 @@ -1734,13 +1734,13 @@ def histogram(a, bins=10, range=None, normed=None, 
weights=None, density=None):
 if isinstance(bins, numeric_types):
 if range is None:
 raise NotImplementedError("automatic range is not supported 
yet...")
-return _npi.histogram(a, bin_cnt=bins, range=range)
+return _api_internal.histogram(a, None, bins, range)
 if isinstance(bins, (list, tuple)):
 raise NotImplementedError("array_like bins is not supported yet...")
 if isinstance(bins, str):
 raise NotImplementedError("string bins is not supported yet...")
 if isinstance(bins, NDArray):
-return _npi.histogram(a, bins=bins)
+return _npi.histogram(a, bins, None, None)
 
 Review comment:
   Good catch, done


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for np.sum, np.std, np.var and np.average

2020-04-01 Thread GitBox
haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for 
np.sum, np.std, np.var and np.average
URL: https://github.com/apache/incubator-mxnet/pull/17866#discussion_r402010010
 
 

 ##
 File path: include/mxnet/runtime/ffi_helper.h
 ##
 @@ -99,6 +99,24 @@ class Integer: public ObjectRef {
   MXNET_DEFINE_OBJECT_REF_METHODS(Integer, ObjectRef, IntegerObj)
 };
 
+class FloatObj: public Object {
+ public:
+  double value;
+  static constexpr const uint32_t _type_index = TypeIndex::kFloat;
+  static constexpr const char* _type_key = "MXNet.Float";
+  MXNET_DECLARE_FINAL_OBJECT_INFO(FloatObj, Object)
+};
+
+class Float: public ObjectRef {
+ public:
+  explicit Float(double value,
+ ObjectPtr&& data = make_object()) {
 
 Review comment:
   Done


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:
us...@infra.apache.org


With regards,
Apache Git Services