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 2018/09/18 16:32:48 UTC

[GitHub] marcoabreu closed pull request #12355: [MXNET-860] Reduce redundant copies, check for regressions with clang-tidy

marcoabreu closed pull request #12355: [MXNET-860] Reduce redundant copies, check for regressions with clang-tidy
URL: https://github.com/apache/incubator-mxnet/pull/12355
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.clang-tidy b/.clang-tidy
index 993656e1276..c84ba323b60 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -54,7 +54,7 @@ Checks: >
 
 # In order to trigger an error, you must have a rule defined both in checks and in this section.
 WarningsAsErrors: >
-    cppcoreguidelines-no-malloc
+    cppcoreguidelines-no-malloc, performance-unnecessary-copy-initialization
 
 # Todo: define a better regex match that includes most project headers, but excludes third party
 # code.
diff --git a/src/ndarray/ndarray.cc b/src/ndarray/ndarray.cc
index 853838a87f4..ddffa28cfd3 100644
--- a/src/ndarray/ndarray.cc
+++ b/src/ndarray/ndarray.cc
@@ -1031,7 +1031,7 @@ inline void CopyFromToRspImpl(const NDArray& from, const NDArray& to, RunContext
     op::FillZerosRspImpl(s, to);
     return;
   }
-  auto aux_shape = from.aux_shape(rowsparse::kIdx);
+  const auto& aux_shape = from.aux_shape(rowsparse::kIdx);
   to.CheckAndAlloc({aux_shape});
   TBlob val = to.data();
   TBlob idx = to.aux_data(rowsparse::kIdx);
@@ -1122,7 +1122,7 @@ void CopyFromToImpl(const NDArray& from, const NDArray& to,
     if (from_stype == to_stype) {
       casted_nd = from;  // same stype, no need to cast from
     } else {  // different stypes on different ctx needs an temporary casted_nd
-      TShape shape = from.shape();
+      const TShape& shape = from.shape();
       if (to_stype == kDefaultStorage) {
         casted_nd = NDArray(shape, from_ctx);
       } else {
diff --git a/src/operator/contrib/roi_align.cc b/src/operator/contrib/roi_align.cc
index 22611273cf5..7e548481980 100644
--- a/src/operator/contrib/roi_align.cc
+++ b/src/operator/contrib/roi_align.cc
@@ -422,7 +422,7 @@ void ROIAlignForwardCompute(const nnvm::NodeAttrs& attrs,
   CHECK_EQ(out_data.size(), expected_out);
   CHECK_EQ(out_data[roialign::kOut].shape_[0], in_data[roialign::kBox].shape_[0]);
 
-  const ROIAlignParam param = nnvm::get<ROIAlignParam>(attrs.parsed);
+  const ROIAlignParam& param = nnvm::get<ROIAlignParam>(attrs.parsed);
 
   const int count = out_data[roialign::kOut].Size();
   // const int num_rois = in_data[roialign::kBox].size(0);
@@ -466,7 +466,7 @@ void ROIAlignBackwardCompute(const nnvm::NodeAttrs& attrs,
   CHECK_NE(req[1], kWriteInplace) <<
     "ROIAlign: Backward doesn't support kWriteInplace.";
 
-  const ROIAlignParam param = nnvm::get<ROIAlignParam>(attrs.parsed);
+  const ROIAlignParam& param = nnvm::get<ROIAlignParam>(attrs.parsed);
 
   const int count = out_grad[0].Size();
   const int num_rois = in_data[0].size(0);
@@ -534,7 +534,7 @@ He, Kaiming, et al. "Mask R-CNN." ICCV, 2017
 .set_attr<nnvm::FInferShape>("FInferShape", [](const nnvm::NodeAttrs& attrs,
       std::vector<TShape> *in_shape, std::vector<TShape> *out_shape){
   using namespace mshadow;
-  const ROIAlignParam param = nnvm::get<ROIAlignParam>(attrs.parsed);
+  const ROIAlignParam& param = nnvm::get<ROIAlignParam>(attrs.parsed);
   CHECK_EQ(in_shape->size(), 2) << "Input:[data, rois]";
   // data: [batch_size, c, h, w]
   TShape dshape = in_shape->at(roialign::kData);


 

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


With regards,
Apache Git Services