| 519 | namespace detail |
| 520 | { |
| 521 | inline void |
| 522 | validate_npy_header(std::ifstream &stream, const std::string &expect_typestr, const TensorShape &expect_shape) |
| 523 | { |
| 524 | ARM_COMPUTE_UNUSED(expect_typestr); |
| 525 | ARM_COMPUTE_UNUSED(expect_shape); |
| 526 | |
| 527 | std::string header_s = npy::read_header(stream); |
| 528 | |
| 529 | // Parse header |
| 530 | npy::header_t header = npy::parse_header(header_s); |
| 531 | |
| 532 | std::vector<unsigned long> shape = header.shape; |
| 533 | bool fortran_order = header.fortran_order; |
| 534 | std::string typestr = header.dtype.str(); |
| 535 | |
| 536 | // Check if the typestring matches the given one |
| 537 | ARM_COMPUTE_ERROR_ON_MSG(typestr != expect_typestr, "Typestrings mismatch"); |
| 538 | |
| 539 | // Validate tensor shape |
| 540 | ARM_COMPUTE_ERROR_ON_MSG(shape.size() != expect_shape.num_dimensions(), "Tensor ranks mismatch"); |
| 541 | if (fortran_order) |
| 542 | { |
| 543 | for (size_t i = 0; i < shape.size(); ++i) |
| 544 | { |
| 545 | ARM_COMPUTE_ERROR_ON_MSG(expect_shape[i] != shape[i], "Tensor dimensions mismatch"); |
| 546 | } |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | for (size_t i = 0; i < shape.size(); ++i) |
| 551 | { |
| 552 | ARM_COMPUTE_ERROR_ON_MSG(expect_shape[i] != shape[shape.size() - i - 1], "Tensor dimensions mismatch"); |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | } // namespace detail |
| 557 | } // namespace test |
| 558 | } // namespace arm_compute |
no test coverage detected