From 01c3c0e87fec8b7fd76fb23486059f7e25574010 Mon Sep 17 00:00:00 2001 From: Wiktor Adamski Date: Thu, 21 Feb 2019 12:03:47 +0100 Subject: [PATCH] Code style changes. --- mace/ops/one_hot.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mace/ops/one_hot.cc b/mace/ops/one_hot.cc index 38f42893..2077c686 100644 --- a/mace/ops/one_hot.cc +++ b/mace/ops/one_hot.cc @@ -57,7 +57,7 @@ class OneHotOp : public OneHotOpBase { const std::vector &input_shape = input->shape(); std::vector output_shape(input_shape.size() + 1); - MACE_CHECK(input->dim_size() < 100); // prevents too deep recursion + MACE_CHECK(input->dim_size() < 100); // prevents too deep recursion MACE_CHECK(axis >= 0 && axis <= input->dim_size()); for (size_t in = 0, out = 0; out < output_shape.size(); ++out) { @@ -98,34 +98,33 @@ class OneHotOp : public OneHotOpBase { } } } else { - run(input, input_ptr, output_ptr, axis, 0, 0, input_shape.size(), 0); + run(input, &input_ptr, &output_ptr, axis, 0, 0, input_shape.size(), 0); } return MaceStatus::MACE_SUCCESS; } private: - void run(const Tensor *input, const T *&input_ptr, - T *&output_ptr, const index_t axis, + void run(const Tensor *input, const T **input_ptr, + T **output_ptr, const index_t axis, const index_t current_in, const index_t current_out, const index_t left, const index_t test) const { - if (current_out == axis) { const index_t length = depth_; if (left == 0) { for (index_t i = 0; i < length; ++i) { - *output_ptr = *input_ptr == i ? on_value_ : off_value_; - ++output_ptr; + **output_ptr = **input_ptr == i ? on_value_ : off_value_; + ++(*output_ptr); } - ++input_ptr; + ++(*input_ptr); } else { - const T *in = input_ptr; + const T *in = *input_ptr; for (index_t i = 0; i < length; ++i) { - input_ptr = in; + *input_ptr = in; run(input, input_ptr, output_ptr, axis, current_in, current_out + 1, left - 1, i); } @@ -135,9 +134,9 @@ class OneHotOp : public OneHotOpBase { if (left == 0) { for (index_t i = 0; i < length; ++i) { - *output_ptr = *input_ptr == test ? on_value_ : off_value_; - ++output_ptr; - ++input_ptr; + **output_ptr = **input_ptr == test ? on_value_ : off_value_; + ++(*output_ptr); + ++(*input_ptr); } } else { for (index_t i = 0; i < length; ++i) { -- GitLab