| 88 | } |
| 89 | |
| 90 | void check_border_element(const IAccessor &tensor, |
| 91 | const Coordinates &id, |
| 92 | const BorderMode &border_mode, |
| 93 | const void *border_value, |
| 94 | int64_t &num_elements, |
| 95 | int64_t &num_mismatches) |
| 96 | { |
| 97 | const size_t channel_size = element_size_from_data_type(tensor.data_type()); |
| 98 | const auto ptr = static_cast<const uint8_t *>(tensor(id)); |
| 99 | |
| 100 | if (border_mode == BorderMode::REPLICATE) |
| 101 | { |
| 102 | Coordinates border_id{id}; |
| 103 | |
| 104 | if (id.x() < 0) |
| 105 | { |
| 106 | border_id.set(0, 0); |
| 107 | } |
| 108 | else if (static_cast<size_t>(id.x()) >= tensor.shape().x()) |
| 109 | { |
| 110 | border_id.set(0, tensor.shape().x() - 1); |
| 111 | } |
| 112 | |
| 113 | if (id.y() < 0) |
| 114 | { |
| 115 | border_id.set(1, 0); |
| 116 | } |
| 117 | else if (static_cast<size_t>(id.y()) >= tensor.shape().y()) |
| 118 | { |
| 119 | border_id.set(1, tensor.shape().y() - 1); |
| 120 | } |
| 121 | |
| 122 | border_value = tensor(border_id); |
| 123 | } |
| 124 | |
| 125 | // Iterate over all channels within one element |
| 126 | for (int channel = 0; channel < tensor.num_channels(); ++channel) |
| 127 | { |
| 128 | const size_t channel_offset = channel * channel_size; |
| 129 | const double target = get_double_data(ptr + channel_offset, tensor.data_type()); |
| 130 | const double reference = |
| 131 | get_double_data(static_cast<const uint8_t *>(border_value) + channel_offset, tensor.data_type()); |
| 132 | |
| 133 | if (!compare<AbsoluteTolerance<double>>(target, reference)) |
| 134 | { |
| 135 | ARM_COMPUTE_TEST_INFO("id = " << id); |
| 136 | ARM_COMPUTE_TEST_INFO("channel = " << channel); |
| 137 | ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); |
| 138 | ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); |
| 139 | ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); |
| 140 | |
| 141 | ++num_mismatches; |
| 142 | } |
| 143 | |
| 144 | ++num_elements; |
| 145 | } |
| 146 | } |
| 147 | } // namespace |
no test coverage detected