You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/05/23 00:53:35 UTC

[GitHub] [incubator-mxnet] nvchai commented on a change in pull request #15044: [WIP] Added fused slice sum operator

nvchai commented on a change in pull request #15044: [WIP] Added fused slice sum operator
URL: https://github.com/apache/incubator-mxnet/pull/15044#discussion_r286740697
 
 

 ##########
 File path: src/operator/tensor/slice_sum-inl.h
 ##########
 @@ -0,0 +1,203 @@
+/*
+ * 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.
+ */
+
+#ifndef MXNET_OPERATOR_TENSOR_SLICE_SUM_INL_H_
+#define MXNET_OPERATOR_TENSOR_SLICE_SUM_INL_H_
+
+#include <vector>
+#include <algorithm>
+#include <utility>
+#include "../mxnet_op.h"
+#include "./broadcast_reduce_op.h"
+#include "./init_op.h"
+#include "../../common/static_array.h"
+
+namespace mxnet {
+namespace op {
+
+struct SliceSumParam : public dmlc::Parameter<SliceSumParam> {
+  int begin, end, axis;
+  DMLC_DECLARE_PARAMETER(SliceSumParam) {
+    DMLC_DECLARE_FIELD(begin)
+    .describe("starting indices for the slice operation, supports negative indices.");
+    DMLC_DECLARE_FIELD(end)
+    .describe("ending indices for the slice operation, supports negative indices.");
+    DMLC_DECLARE_FIELD(axis)
+    .describe("axis for the slice operation, supports negative values.");
+  }
+  bool operator==(const SliceSumParam& other) const {
+    return this->begin == other.begin &&
+           this->end == other.end &&
+           this->axis == other.axis;
+  }
+};
+
+inline bool SliceSumOpShape(const nnvm::NodeAttrs& attrs,
+                         mxnet::ShapeVector* in_attrs,
+                         mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 2U);
+  CHECK_EQ(out_attrs->size(), 1U);
+  const mxnet::TShape& dshape = (*in_attrs)[0];
+  if (dshape.ndim() == 0) return false;
+  mxnet::TShape oshape = dshape;
+
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, oshape);
+  return !shape_is_none(dshape) && !shape_is_none(oshape);
 
 Review comment:
   Fixed in new commit.

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


With regards,
Apache Git Services