haojin2 commented on a change in pull request #15349: Numpy Tensordot Operator 
URL: https://github.com/apache/incubator-mxnet/pull/15349#discussion_r302265188
 
 

 ##########
 File path: src/operator/numpy/np_tensordot_int_axes_op-inl.h
 ##########
 @@ -0,0 +1,213 @@
+/*
+ * 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_tensordot_int_axes_op-inl.h
+ * \brief Implementation of numpy-compatible tensordot_int_axes
+ */
+#ifndef MXNET_OPERATOR_NUMPY_NP_TENSORDOT_INT_AXES_OP_INL_H_
+#define MXNET_OPERATOR_NUMPY_NP_TENSORDOT_INT_AXES_OP_INL_H_
+
+#include <vector>
+#include "np_tensordot_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+using namespace mxnet;
+using namespace mshadow;
+
+struct TensordotIntAxesParam : public dmlc::Parameter<TensordotIntAxesParam> {
+  int axes;
+  DMLC_DECLARE_PARAMETER(TensordotIntAxesParam) {
+    DMLC_DECLARE_FIELD(axes);
+  }
+};
+
+/**
+ * gets summed axes of a and b from parameter axes.
+ */
+inline void GetSummedAxes(
+    mxnet::Tuple<int>* a_axes_summed_ptr,
+    mxnet::Tuple<int>* b_axes_summed_ptr,
+    const int axes,
+    const mxnet::TShape& a_shape) {
+  std::vector<int> a_axes_summed_vector;
+  for (int i = 0; i < axes; i++) {
+    a_axes_summed_vector.push_back(a_shape.ndim() - axes + i);
+  }
+  *a_axes_summed_ptr = mxnet::Tuple<int>(a_axes_summed_vector);
+
+  std::vector<int> b_axes_summed_vector;
+  for (int i = 0; i < axes; i++) {
+    b_axes_summed_vector.push_back(i);
+  }
+  *b_axes_summed_ptr = mxnet::Tuple<int>(b_axes_summed_vector);
+}
+
+/**
+ * Calculates tensordot.
+ */
+template<typename xpu>
+void TensordotIntAxesImpl(
 
 Review comment:
   I don't think you need line breaks for this signature:
   ```c++
   void TensordotIntAxesImpl(const int axes,
                             const OpContext& ctx,
                             const TBlob& a,
                             const TBlob& b,
                             const TBlob& out,
                             const std::vector<OpReqType>& req) {
   ```
   BTW `req` here only contains 1 element, so maybe you want to change the 
signature to:
   ```c++
   void TensordotIntAxesImpl(const int axes,
                             const OpContext& ctx,
                             const TBlob& a,
                             const TBlob& b,
                             const TBlob& out,
                             const OpReqType& req) {
   ```

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