(layout, interp, dtype, w, h)
| 138 | |
| 139 | |
| 140 | def _test_resize(layout, interp, dtype, w, h): |
| 141 | channel_first = layout == "FCHW" |
| 142 | pipe_dali = create_dali_pipe(channel_first, 8, interp, dtype, w, h) |
| 143 | pipe_ref = create_ref_pipe(channel_first, 8, interp, dtype, w, h) |
| 144 | eps = 1e-2 |
| 145 | max_err = 6 |
| 146 | for iter in range(4): |
| 147 | out_dali = pipe_dali.run() |
| 148 | out_ref = pipe_ref.run()[0] |
| 149 | dali_cpu = out_dali[0] |
| 150 | dali_gpu = out_dali[1] |
| 151 | if interp == types.INTERP_LANCZOS3: |
| 152 | # PIL can't resize float data. Lanczos resampling generates overshoot which we have |
| 153 | # to get rid of for the comparison to succeed. |
| 154 | dali_cpu = [np.array(x).clip(0, 255) for x in dali_cpu] |
| 155 | dali_gpu = [np.array(x).clip(0, 255) for x in dali_gpu.as_cpu()] |
| 156 | else: |
| 157 | dali_cpu = [np.array(x) for x in dali_cpu] |
| 158 | dali_gpu = [np.array(x) for x in dali_gpu.as_cpu()] |
| 159 | if channel_first: |
| 160 | out_ref = [np.array(x)[:, :, 1:-1, 1:-1] for x in out_ref] |
| 161 | dali_gpu = [x[:, :, 1:-1, 1:-1] for x in dali_gpu] |
| 162 | dali_cpu = [x[:, :, 1:-1, 1:-1] for x in dali_cpu] |
| 163 | else: |
| 164 | out_ref = [np.array(x)[:, 1:-1, 1:-1, :] for x in out_ref] |
| 165 | dali_gpu = [x[:, 1:-1, 1:-1, :] for x in dali_gpu] |
| 166 | dali_cpu = [x[:, 1:-1, 1:-1, :] for x in dali_cpu] |
| 167 | check_batch(dali_cpu, out_ref, 2, eps=eps, max_allowed_error=max_err) |
| 168 | check_batch(dali_gpu, out_ref, 2, eps=eps, max_allowed_error=max_err) |
| 169 | ext_size = out_dali[2] |
| 170 | size_cpu = out_dali[3] |
| 171 | size_gpu = out_dali[4] |
| 172 | check_batch(ext_size, size_cpu, 2) |
| 173 | check_batch(ext_size, size_gpu, 2) |
| 174 | |
| 175 | |
| 176 | def test_resize(): |
nothing calls this directly
no test coverage detected