haojin2 commented on a change in pull request #15837: Numpy add numpy op indices
URL: https://github.com/apache/incubator-mxnet/pull/15837#discussion_r314470471
 
 

 ##########
 File path: src/operator/numpy/np_init_op.h
 ##########
 @@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+/*!
+ *  Copyright (c) 2019 by Contributors
+ * \file np_init_op.h
+ * \brief CPU Implementation of numpy init op
+ */
+#ifndef MXNET_OPERATOR_NUMPY_NP_INIT_OP_H_
+#define MXNET_OPERATOR_NUMPY_NP_INIT_OP_H_
+
+#include <vector>
+#include <string>
+#include "../tensor/init_op.h"
+#include "../tensor/elemwise_unary_op.h"
+
+
+namespace mxnet {
+namespace op {
+
+
+struct IndicesOpParam : public dmlc::Parameter<IndicesOpParam> {
+  mxnet::TShape dimensions;
+  int dtype;
+  std::string ctx;
+  DMLC_DECLARE_PARAMETER(IndicesOpParam) {
+    DMLC_DECLARE_FIELD(dimensions)
+    .describe("The shape of the grid.");
+    DMLC_DECLARE_FIELD(dtype).set_default(mshadow::kInt32)
+      MXNET_ADD_ALL_TYPES
+      .describe("Target data type.");
+    DMLC_DECLARE_FIELD(ctx)
+    .set_default("")
+    .describe("Context of output, in format [cpu|gpu|cpu_pinned](n)."
+              "Only used for imperative calls.");
+  }
+};
+
+inline bool NumpyIndicesShape(const nnvm::NodeAttrs& attrs,
+                              mxnet::ShapeVector* in_shapes,
+                              mxnet::ShapeVector* out_shapes) {
+  const IndicesOpParam& param = nnvm::get<IndicesOpParam>(attrs.parsed);
+  CHECK_EQ(in_shapes->size(), 0U);
+  CHECK_EQ(out_shapes->size(), 1U);
+  CHECK_GE(param.dimensions.ndim(), 0)
+    << "_npi_indices dimensions the number of dim must not be less than  0";
+  mxnet::TShape param_dim = param.dimensions;
+  if (!shape_is_known(param_dim)) return false;
+  for (int i = 0; i < param_dim.ndim(); ++i) {
+    CHECK_GE(param_dim[i], 0) << "_npi_indices dimensions must be 
non-negative";
 
 Review comment:
   "all sizes of dims of dimensions param must be non-negative"

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

Reply via email to