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 2020/05/22 05:51:19 UTC
[GitHub] [incubator-mxnet] sxjscience commented on a change in pull request #18089: Add npx op 'index_add'
sxjscience commented on a change in pull request #18089:
URL: https://github.com/apache/incubator-mxnet/pull/18089#discussion_r429054854
##########
File path: src/operator/tensor/index_add_backward.cu
##########
@@ -0,0 +1,119 @@
+/*
+ * 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 index_add.cu
+ * \brief GPU implementation of index_add operator
+ */
+
+#include <cub/cub.cuh>
+#include "./index_add-inl.h"
+#include "../tensor/util/tensor_util-inl.cuh"
+#include "../tensor/util/tensor_util-inl.h"
+
+namespace mxnet {
+namespace op {
+
+template<typename xpu, typename DType>
+void IndexAddOpBackwardACalc(mshadow::Stream<xpu> *s,
+ DType* grad_a, const DType* ograd,
+ const size_t* stride,
+ const size_t tail_size, const int ind_num,
+ const int ind_ndim, const int32_t* ind_vec,
+ const int req, const int out_ndim) {
+ using namespace mxnet_op;
+ using namespace mshadow;
+ size_t* d_stride;
+ size_t shape_size = sizeof(size_t) * out_ndim;
+ cudaMalloc(reinterpret_cast<void**>(&d_stride), shape_size);
Review comment:
We may not use cudaMalloc here. Allocate additional temporary storage to do this.
----------------------------------------------------------------
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