samskalicky commented on a change in pull request #15872: Add a contrib 
operator for dynamic reshape
URL: https://github.com/apache/incubator-mxnet/pull/15872#discussion_r365455600
 
 

 ##########
 File path: src/operator/contrib/dynamic_shape_ops-inl.h
 ##########
 @@ -0,0 +1,85 @@
+/*
+ * 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) 2018 by Contributors
+ * \file dynamic_shape_ops-inl.h
+*/
+
+#ifndef MXNET_OPERATOR_CONTRIB_DYNAMIC_SHAPE_OPS_INL_H_
+#define MXNET_OPERATOR_CONTRIB_DYNAMIC_SHAPE_OPS_INL_H_
+
+#include <vector>
+#include "../mxnet_op.h"
+#include "../mshadow_op.h"
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+template<typename xpu>
+inline void DynamicReshapeForward(const nnvm::NodeAttrs& attrs,
+                            const OpContext &ctx,
+                            const std::vector<NDArray> &inputs,
+                            const std::vector<OpReqType> &req,
+                            const std::vector<NDArray> &outputs) {
+  CHECK_EQ(inputs.size(), 2U);
+  CHECK_EQ(outputs.size(), 1U);
+  const NDArray &out = outputs[0];
+  const NDArray &idx = inputs[1];
+  size_t idx_size = idx.shape()[0];
+  mxnet::TShape shapevalue = mxnet::TShape(idx_size, 0);
+  std::vector<int> shapev(idx_size, 0);
+  MSHADOW_TYPE_SWITCH(idx.dtype(), DType, {
+    DType* idx_dptr = idx.data().dptr<DType>();
+    for (size_t i = 0; i < idx_size; i++) {
+      shapev[i] = idx_dptr[i];
+    }
 
 Review comment:
   What is going on here? can you add some comments? 
   
   I read that the 2nd input is the new shape tuple, but what is special about 
the first index of the tuple for the idx_size variable?

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