This is an automated email from the ASF dual-hosted git repository.
wangwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-singa.git
The following commit(s) were added to refs/heads/master by this push:
new 175e187 SINGA-491 Use const reference when we use CopyData and
ResetLike from tensor input
new acabafb Merge pull request #543 from chrishkchris/SINGA-491_3
175e187 is described below
commit 175e187007b4a35d9a888ae0cfebcbe2ccb4273a
Author: chrishkchris <[email protected]>
AuthorDate: Thu Oct 3 03:43:37 2019 +0000
SINGA-491 Use const reference when we use CopyData and ResetLike from
tensor input
---
src/model/layer/batchnorm.h | 8 ++++----
src/model/layer/convolution.h | 4 ++--
src/model/layer/dense.h | 4 ++--
src/model/layer/prelu.h | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/model/layer/batchnorm.h b/src/model/layer/batchnorm.h
index c44962b..8b2e295 100644
--- a/src/model/layer/batchnorm.h
+++ b/src/model/layer/batchnorm.h
@@ -56,19 +56,19 @@ class BatchNorm : public Layer {
size_t channels() const { return channels_; }
size_t height() const { return height_; }
size_t width() const { return width_; }
- void set_bnScale(Tensor x) {
+ void set_bnScale(const Tensor& x) {
bnScale_.ResetLike(x);
bnScale_.CopyData(x);
}
- void set_bnBias(Tensor x) {
+ void set_bnBias(const Tensor& x) {
bnBias_.ResetLike(x);
bnBias_.CopyData(x);
}
- void set_runningMean(Tensor x) {
+ void set_runningMean(const Tensor& x) {
runningMean_.ResetLike(x);
runningMean_.CopyData(x);
}
- void set_runningVariance(Tensor x) {
+ void set_runningVariance(const Tensor& x) {
runningVariance_.ResetLike(x);
runningVariance_.CopyData(x);
}
diff --git a/src/model/layer/convolution.h b/src/model/layer/convolution.h
index d11cdeb..cb1b1d3 100755
--- a/src/model/layer/convolution.h
+++ b/src/model/layer/convolution.h
@@ -67,11 +67,11 @@ class Convolution : public Layer {
const Tensor& weight() const { return weight_; }
const Tensor& bias() const { return bias_; }
- void set_weight(Tensor w) {
+ void set_weight(const Tensor& w) {
weight_.ResetLike(w);
weight_.CopyData(w);
}
- void set_bias(Tensor b) {
+ void set_bias(const Tensor& b) {
bias_.ResetLike(b);
bias_.CopyData(b);
}
diff --git a/src/model/layer/dense.h b/src/model/layer/dense.h
index 8f53699..e55a49a 100644
--- a/src/model/layer/dense.h
+++ b/src/model/layer/dense.h
@@ -57,11 +57,11 @@ class Dense : public Layer {
const Tensor& weight() const { return weight_; }
const Tensor& bias() const { return bias_; }
- void set_weight(Tensor w) {
+ void set_weight(const Tensor& w) {
weight_.ResetLike(w);
weight_.CopyData(w);
}
- void set_bias(Tensor b) {
+ void set_bias(const Tensor& b) {
bias_.ResetLike(b);
bias_.CopyData(b);
}
diff --git a/src/model/layer/prelu.h b/src/model/layer/prelu.h
index 674e8fb..eca6a23 100644
--- a/src/model/layer/prelu.h
+++ b/src/model/layer/prelu.h
@@ -50,7 +50,7 @@ class PReLU : public Layer {
const Tensor A() const { return a_; }
const std::string Format() const { return format_; }
- void Set_a(Tensor a) {
+ void Set_a(const Tensor& a) {
a_.ResetLike(a);
a_.CopyData(a);
}