Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Joaquin Anton Guirao <[email protected]>
  • Loading branch information
jantonguirao committed Dec 24, 2024
1 parent 4867508 commit 93248e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dali/python/backend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ void ExposeTensor(py::module &m) {
.def("as_cpu", [](Tensor<CPUBackend> &t) -> Tensor<CPUBackend>& {
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<CPUBackend> &t, py::object p) {
Expand Down
14 changes: 7 additions & 7 deletions dali/test/python/operator_1/test_coord_flip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 6 additions & 5 deletions dali/test/python/operator_1/test_crop_mirror_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 93248e8

Please sign in to comment.