From 6772190f8ba6589c37b6729e1b5ab9c6bbc4d044 Mon Sep 17 00:00:00 2001 From: liuqi Date: Wed, 6 Sep 2017 18:18:49 +0800 Subject: [PATCH] Optimize a computation of batch_norm kernel and ops' BUILD file. --- mace/kernels/batch_norm.h | 2 +- mace/kernels/neon/batch_norm_neon.cc | 2 +- mace/ops/BUILD | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mace/kernels/batch_norm.h b/mace/kernels/batch_norm.h index d81fdae9..136163f9 100644 --- a/mace/kernels/batch_norm.h +++ b/mace/kernels/batch_norm.h @@ -47,7 +47,7 @@ struct BatchNormFunctor : public BatchNormFunctorBase { new_offset = offset[c] - mean[c] * new_scale; for (TIndex i = 0; i < n; ++i) { - TIndex pos = i * channel * sample_size + c * sample_size; + TIndex pos = (i * channel + c) * sample_size; const T* input_sample_ptr = input + pos; T* output_sample_ptr = output + pos; for (TIndex j = 0; j < sample_size; ++j) { diff --git a/mace/kernels/neon/batch_norm_neon.cc b/mace/kernels/neon/batch_norm_neon.cc index d307173f..7121c23d 100644 --- a/mace/kernels/neon/batch_norm_neon.cc +++ b/mace/kernels/neon/batch_norm_neon.cc @@ -41,7 +41,7 @@ struct BatchNormFunctor : public BatchNormFunctorBase