From 08fe5693312fe0fb2102afeae8f49d0700979c95 Mon Sep 17 00:00:00 2001 From: Kamil Tokarski Date: Fri, 3 Jun 2022 17:24:02 +0200 Subject: [PATCH 1/2] Fix fn.coord_transform handling of default matrix in variable batch case Signed-off-by: Kamil Tokarski --- dali/operators/geometry/mt_transform_attr.cc | 12 ++++++------ dali/test/python/test_dali_variable_batch_size.py | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dali/operators/geometry/mt_transform_attr.cc b/dali/operators/geometry/mt_transform_attr.cc index d5cc15057d5..c668f8a65f0 100644 --- a/dali/operators/geometry/mt_transform_attr.cc +++ b/dali/operators/geometry/mt_transform_attr.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2020-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -127,11 +127,11 @@ void MTTransformAttr::ProcessMatrixArg(const OpSpec &spec, const ArgumentWorkspa if (static_cast(mtx_.size()) != output_pt_dim_ * input_pt_dim_) { mtx_.resize(output_pt_dim_ * input_pt_dim_, 0); MakeDiagonalMatrix(mtx_, 1); - Repeat(per_sample_mtx_, mtx_, N); - if (is_fused) { - translation_.resize(output_pt_dim_, 0); - Repeat(per_sample_translation_, translation_, N); - } + } + Repeat(per_sample_mtx_, mtx_, N); + if (is_fused) { + translation_.resize(output_pt_dim_, 0); + Repeat(per_sample_translation_, translation_, N); } } } diff --git a/dali/test/python/test_dali_variable_batch_size.py b/dali/test/python/test_dali_variable_batch_size.py index bef5d7f10f5..3f66c885b6a 100644 --- a/dali/test/python/test_dali_variable_batch_size.py +++ b/dali/test/python/test_dali_variable_batch_size.py @@ -291,6 +291,8 @@ def numba_setup_out_shape(out_shape, in_shape): (fn.cast, {'dtype': types.INT32}), (fn.color_space_conversion, {'image_type': types.BGR, 'output_type': types.RGB}), (fn.coord_transform, {'M': .5, 'T': 2}), + (fn.coord_transform, {'T': 2}), + (fn.coord_transform, {'M': .5}), (fn.crop, {'crop': (5, 5)}), (fn.erase, {'anchor': [0.3], 'axis_names': "H", 'normalized_anchor': True, 'shape': [0.1], 'normalized_shape': True}), From b5917dca143f50f78b6b18ed435e589b24f4fcf6 Mon Sep 17 00:00:00 2001 From: Kamil Tokarski Date: Fri, 17 Jun 2022 16:20:31 +0200 Subject: [PATCH 2/2] Avoid unnecessary repeat for 0 translation Signed-off-by: Kamil Tokarski --- dali/operators/geometry/mt_transform_attr.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dali/operators/geometry/mt_transform_attr.cc b/dali/operators/geometry/mt_transform_attr.cc index c668f8a65f0..4c58ae002b0 100644 --- a/dali/operators/geometry/mt_transform_attr.cc +++ b/dali/operators/geometry/mt_transform_attr.cc @@ -130,8 +130,7 @@ void MTTransformAttr::ProcessMatrixArg(const OpSpec &spec, const ArgumentWorkspa } Repeat(per_sample_mtx_, mtx_, N); if (is_fused) { - translation_.resize(output_pt_dim_, 0); - Repeat(per_sample_translation_, translation_, N); + per_sample_translation_.resize(output_pt_dim_ * N, 0); } } }