From 86efd70946504c3f7ac72d44caa7c7e89b4aabd1 Mon Sep 17 00:00:00 2001 From: Kamil Tokarski Date: Sun, 29 May 2022 22:42:08 +0200 Subject: [PATCH] Make tensorview over a whole list first, not over each particular tensorvector Signed-off-by: Kamil Tokarski --- dali/operators/image/color/brightness_contrast.cc | 7 ++++--- dali/operators/image/color/color_twist.cc | 6 +++--- dali/pipeline/data/sequence_utils.h | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dali/operators/image/color/brightness_contrast.cc b/dali/operators/image/color/brightness_contrast.cc index 8b1583d0048..bc4b09018b9 100644 --- a/dali/operators/image/color/brightness_contrast.cc +++ b/dali/operators/image/color/brightness_contrast.cc @@ -107,14 +107,15 @@ void BrightnessContrastCpu::RunImplHelper(workspace_t &ws) { using Kernel = kernels::MultiplyAddCpu; kernel_manager_.template Resize(1); + auto in_view = view(input); + auto out_view = view(output); for (int sample_id = 0; sample_id < num_samples; sample_id++) { float add, mul; OpArgsToKernelArgs(add, mul, brightness_[sample_id], brightness_shift_[sample_id], contrast_[sample_id], contrast_center[sample_id]); - auto in_view = view(input[sample_id]); - auto out_view = view(output[sample_id]); - auto planes_range = sequence_utils::unfolded_views_range(out_view, in_view); + auto planes_range = + sequence_utils::unfolded_views_range(out_view[sample_id], in_view[sample_id]); const auto &in_range = planes_range.template get<1>(); for (auto &&views : planes_range) { tp.AddWork([&, views, add, mul](int thread_id) { diff --git a/dali/operators/image/color/color_twist.cc b/dali/operators/image/color/color_twist.cc index fe20f3b94c3..a4eb3167642 100644 --- a/dali/operators/image/color/color_twist.cc +++ b/dali/operators/image/color/color_twist.cc @@ -146,10 +146,10 @@ void ColorTwistCpu::RunImplHelper(workspace_t &ws) { using Kernel = kernels::LinearTransformationCpu; int num_samples = input.num_samples(); kernel_manager_.template Resize(num_samples); + auto in_view = view(input); + auto out_view = view(output); for (int i = 0; i < num_samples; i++) { - auto in_view = view(input[i]); - auto out_view = view(output[i]); - auto planes_range = sequence_utils::unfolded_views_range(out_view, in_view); + auto planes_range = sequence_utils::unfolded_views_range(out_view[i], in_view[i]); const auto &in_range = planes_range.template get<1>(); for (auto &&views : planes_range) { tp.AddWork( diff --git a/dali/pipeline/data/sequence_utils.h b/dali/pipeline/data/sequence_utils.h index 77cc220bf60..aaeca63967e 100644 --- a/dali/pipeline/data/sequence_utils.h +++ b/dali/pipeline/data/sequence_utils.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef DALI_PIPELINE_OPERATOR_SEQUENCE_UTILS_H_ -#define DALI_PIPELINE_OPERATOR_SEQUENCE_UTILS_H_ +#ifndef DALI_PIPELINE_DATA_SEQUENCE_UTILS_H_ +#define DALI_PIPELINE_DATA_SEQUENCE_UTILS_H_ #include #include @@ -190,4 +190,4 @@ CombinedRange...> unfold } // namespace dali -#endif // DALI_PIPELINE_OPERATOR_SEQUENCE_UTILS_H_ +#endif // DALI_PIPELINE_DATA_SEQUENCE_UTILS_H_