Extract output for given sample_id from the pipeline Expand the data based on the kinds parameter and optionally cast it into target type as numpy does types promotions a bit differently.
(pipe_out, sample_id, kinds, target_type)
| 471 | |
| 472 | |
| 473 | def extract_data(pipe_out, sample_id, kinds, target_type): |
| 474 | """ |
| 475 | Extract output for given sample_id from the pipeline |
| 476 | Expand the data based on the kinds parameter and optionally cast it into target type |
| 477 | as numpy does types promotions a bit differently. |
| 478 | """ |
| 479 | arity = len(kinds) |
| 480 | inputs = [] |
| 481 | for i in range(arity): |
| 482 | dali_in = np.array(pipe_out[i][sample_id].as_cpu()) |
| 483 | numpy_in = get_numpy_input( |
| 484 | dali_in, |
| 485 | kinds[i], |
| 486 | dali_in.dtype.type, |
| 487 | target_type if target_type is not None else dali_in.dtype.type, |
| 488 | ) |
| 489 | inputs.append(numpy_in) |
| 490 | out = np.array(pipe_out[arity][sample_id].as_cpu()) |
| 491 | return tuple(inputs) + (out,) |
| 492 | |
| 493 | |
| 494 | def check_unary_op(kind, type, op, shape, _): |
no test coverage detected