From 93248e82410e768c866d88050a8d8dfd100fde43 Mon Sep 17 00:00:00 2001 From: Joaquin Anton Guirao Date: Tue, 24 Dec 2024 10:00:11 +0100 Subject: [PATCH] Fix Signed-off-by: Joaquin Anton Guirao --- dali/python/backend_impl.cc | 2 +- dali/test/python/operator_1/test_coord_flip.py | 14 +++++++------- .../operator_1/test_crop_mirror_normalize.py | 11 ++++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dali/python/backend_impl.cc b/dali/python/backend_impl.cc index 84d3f330d6..e731cae4be 100644 --- a/dali/python/backend_impl.cc +++ b/dali/python/backend_impl.cc @@ -721,7 +721,7 @@ void ExposeTensor(py::module &m) { .def("as_cpu", [](Tensor &t) -> Tensor& { return t; }, - R"code(Bypass, since the object is already an instance of `TensorCPU`.)code", + R"code(Passthrough, since the object is already an instance of `TensorCPU`.)code", py::return_value_policy::reference_internal) .def("copy_to_external", [](Tensor &t, py::object p) { diff --git a/dali/test/python/operator_1/test_coord_flip.py b/dali/test/python/operator_1/test_coord_flip.py index 91d42fd435..948cd4be3b 100644 --- a/dali/test/python/operator_1/test_coord_flip.py +++ b/dali/test/python/operator_1/test_coord_flip.py @@ -64,21 +64,21 @@ def define_graph(self): def check_operator_coord_flip(device, batch_size, layout, shape, center_x, center_y, center_z): eii1 = RandomDataIterator(batch_size, shape=shape, dtype=np.float32) pipe = CoordFlipPipeline(device, batch_size, iter(eii1), layout, center_x, center_y, center_z) - for i in range(30): - outputs0, outputs1, outputs2, outputs3, outputs4 = pipe.run() + for _ in range(30): + outputs = tuple(out.as_cpu() for out in pipe.run()) outputs1 = outputs1.as_cpu() for sample in range(batch_size): - in_coords = outputs0.at(sample) - out_coords = outputs1.at(sample) + in_coords = outputs[0].at(sample) + out_coords = outputs[1].at(sample) if in_coords.shape == () or in_coords.shape[0] == 0: assert out_coords.shape == () or out_coords.shape[0] == 0 continue - flip_x = outputs2.at(sample) - flip_y = outputs3.at(sample) + flip_x = outputs[2].at(sample) + flip_y = outputs[3].at(sample) flip_z = None if len(layout) == 3: - flip_z = outputs4.at(sample) + flip_z = outputs[4].at(sample) _, ndim = in_coords.shape flip_dim = [flip_x, flip_y] diff --git a/dali/test/python/operator_1/test_crop_mirror_normalize.py b/dali/test/python/operator_1/test_crop_mirror_normalize.py index d41502d072..90931f977b 100644 --- a/dali/test/python/operator_1/test_crop_mirror_normalize.py +++ b/dali/test/python/operator_1/test_crop_mirror_normalize.py @@ -894,13 +894,14 @@ def pipe(): batch_size = 10 p = pipe(batch_size=batch_size) + ref_scale = scale or 1.0 + ref_shift = shift or 0.0 for _ in range(3): - out, image_like, mean, std = tuple(out.as_cpu() for out in p.run()) - ref_scale = scale or 1.0 - ref_shift = shift or 0.0 - ref_out = ref_scale * (image_like - mean) / std + ref_shift + outs = tuple(np.array(out.as_cpu()) for out in p.run()) for s in range(batch_size): - np.testing.assert_allclose(out.at(s), ref_out.at(s), atol=ref_scale * 1e-6) + out, image_like, mean, std = tuple(np.array(o[s]) for o in outs) + ref_out = ref_scale * (image_like - mean) / std + ref_shift + np.testing.assert_allclose(out, ref_out, atol=ref_scale * 1e-6) def test_per_sample_norm_args():