Fix assigning bool to float16/bfloat16 (#3229)
Co-authored-by: KD2YCU <me@kd2ycu.com> Co-authored-by: Angelos Katharopoulos <a_katharopoulos@apple.com>
This commit is contained in:
@@ -105,6 +105,16 @@ TEST_CASE("test array basics") {
|
||||
CHECK_EQ(x.dtype(), bool_);
|
||||
CHECK(array_equal(x, array({false, true, false, true})).item<bool>());
|
||||
}
|
||||
|
||||
// Regression: vector<bool>::reference to fp16/bf16 stored raw bits
|
||||
{
|
||||
std::vector<bool> data = {true, false, true};
|
||||
auto bf = array(data.begin(), {3}, bfloat16);
|
||||
CHECK(array_equal(bf, array({1.0f, 0.0f, 1.0f}, bfloat16)).item<bool>());
|
||||
|
||||
auto fp = array(data.begin(), {3}, float16);
|
||||
CHECK(array_equal(fp, array({1.0f, 0.0f, 1.0f}, float16)).item<bool>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("test array types") {
|
||||
|
||||
Reference in New Issue
Block a user