| 676 | constexpr std::array<float, 5> NearComparator<NativeT>::kErrorBucketBounds; |
| 677 | |
| 678 | Status EqualHelper(const LiteralSlice& expected, const LiteralSlice& actual, |
| 679 | const ShapeIndex& shape_index, |
| 680 | const MiscompareCallback& miscompare_callback) { |
| 681 | TF_RETURN_IF_ERROR(EqualShapes(expected.shape(), actual.shape())); |
| 682 | |
| 683 | Status result; |
| 684 | if (expected.shape().IsTuple()) { |
| 685 | ShapeIndex next_index = shape_index; |
| 686 | for (int i = 0; i < ShapeUtil::TupleElementCount(expected.shape()); ++i) { |
| 687 | next_index.push_back(i); |
| 688 | Status tuple_result = |
| 689 | EqualHelper(LiteralSlice(expected, {i}), LiteralSlice(actual, {i}), |
| 690 | next_index, miscompare_callback); |
| 691 | if (miscompare_callback) { |
| 692 | result.Update(tuple_result); |
| 693 | } else { |
| 694 | TF_RETURN_IF_ERROR(tuple_result); |
| 695 | } |
| 696 | next_index.pop_back(); |
| 697 | } |
| 698 | } else { |
| 699 | std::vector<int64> multi_index(expected.shape().dimensions_size(), 0); |
| 700 | auto index = absl::MakeSpan(multi_index); |
| 701 | |
| 702 | Shape unequal_shape = ShapeUtil::MakeShape(PrimitiveType::PRED, |
| 703 | expected.shape().dimensions()); |
| 704 | Literal miscompared(unequal_shape); |
| 705 | Literal* miscompared_ptr = |
| 706 | (miscompare_callback == nullptr ? nullptr : &miscompared); |
| 707 | |
| 708 | switch (expected.shape().element_type()) { |
| 709 | case PRED: |
| 710 | result = Equal<bool>(expected, actual, index, 0, miscompared_ptr); |
| 711 | break; |
| 712 | case S8: |
| 713 | result = Equal<int8>(expected, actual, index, 0, miscompared_ptr); |
| 714 | break; |
| 715 | case S16: |
| 716 | result = Equal<int16>(expected, actual, index, 0, miscompared_ptr); |
| 717 | break; |
| 718 | case S32: |
| 719 | result = Equal<int32>(expected, actual, index, 0, miscompared_ptr); |
| 720 | break; |
| 721 | case S64: |
| 722 | result = Equal<int64>(expected, actual, index, 0, miscompared_ptr); |
| 723 | break; |
| 724 | case U8: |
| 725 | result = Equal<uint8>(expected, actual, index, 0, miscompared_ptr); |
| 726 | break; |
| 727 | case U16: |
| 728 | result = Equal<uint16>(expected, actual, index, 0, miscompared_ptr); |
| 729 | break; |
| 730 | case U32: |
| 731 | result = Equal<uint32>(expected, actual, index, 0, miscompared_ptr); |
| 732 | break; |
| 733 | case U64: |
| 734 | result = Equal<uint64>(expected, actual, index, 0, miscompared_ptr); |
| 735 | break; |
no test coverage detected