Skip to content

Commit b300cb2

Browse files
committed
Pin the other direction of the moved overflow boundary
The vendored range check moved in both directions, and only the direction that starts refusing values had a test. Cover the quiet one: filling an int8 tensor with 127.5 used to be refused and now stores 127. Test Plan: Compiled the real header from before and after this change into the same probe and ran both. Before: 127.5 into int8 and 255.5 into uint8 both report overflow, and 2^63 into int64 is accepted. After: the first two are accepted and 2^63 overflows. So the boundary moved both ways, and the case added here fails against the previous header rather than passing either way. Placed in this file rather than the shared macro because the macro expands into eight suites, and several of them reach the scalar through a path that rejects a fractional value before any range check, where the case would not measure what it claims.
1 parent d53ec66 commit b300cb2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎kernels/test/op_full_test.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ ET_FORALL_REALHBF16_TYPES(GENERATE_TEST)
8484

8585
GENERATE_SCALAR_OVERFLOW_TESTS(OpFullOutTest)
8686

87+
// The other half of the boundary change: 127.5 used to be refused for an int8
88+
// tensor and now truncates to 127.
89+
TEST_F(OpFullOutTest, CharTensorFractionalScalarTruncates) {
90+
TensorFactory<ScalarType::Char> tf;
91+
std::vector<int32_t> sizes = {2, 2};
92+
std::vector<int64_t> sizes_int64_t(sizes.begin(), sizes.end());
93+
auto aref = IntArrayRef(sizes_int64_t.data(), sizes_int64_t.size());
94+
Tensor out = tf.zeros(sizes);
95+
96+
op_full_out(aref, 127.5, out);
97+
EXPECT_TENSOR_EQ(out, tf.full(sizes, 127));
98+
}
99+
87100
TEST_F(OpFullOutTest, HalfSupport) {
88101
TensorFactory<ScalarType::Half> tf;
89102

0 commit comments

Comments
 (0)