ZhennanQin commented on a change in pull request #14056: A better split-2D(SliceChannel) op forward kernel for CPU URL: https://github.com/apache/incubator-mxnet/pull/14056#discussion_r253262215
########## File path: src/operator/channel_op_common.h ########## @@ -101,6 +101,42 @@ void Split(const mshadow::Tensor<xpu, dim, DType> &input, split_helper<xpu, dim, dim-1>(input, output, dimension, req); } } + +template<typename cpu, int dim, typename DType> +void Split_2D(const mshadow::Tensor<cpu, dim, DType> &input, + std::vector<mshadow::Tensor<cpu, dim, DType> > *output, + const int dimension, const std::vector<OpReqType> &req) { + if (dimension != 1) { + LOG(FATAL) << "dimension (" << dimension << ") must == 1"; + } + if (dim != 3) { + LOG(FATAL) << "dimension (" << dim << ") must == 3"; + } else { + std::vector<mshadow::Tensor<cpu, dim, DType> > out = *output; + size_t size = out.size(); + std::vector<int>slice_len; + std::vector<int>begin_pos; + begin_pos.push_back(0); + + for (index_t i = 0; i < size; ++i) { + slice_len.push_back(out[i].size(dimension)); + begin_pos.push_back(begin_pos[i] + out[i].size(dimension)); + } +#pragma omp parallel for num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount()) + for (int i = 0; i < input.shape_[0]; i++) { + int iRow = i*input.shape_[1]; + for (int j = 0; j < size; j++) { + int jRow = i*slice_len[j]; Review comment: Add blank before and after operator. Please clean up all code style issue. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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