mlx/tests/utils_tests.cpp
2023-11-29 10:52:08 -08:00

27 lines
575 B
C++

#include "doctest/doctest.h"
#include "mlx/mlx.h"
using namespace mlx::core;
TEST_CASE("test type promotion") {
for (auto t : {bool_, uint32, int32, int64, float32}) {
auto a = array(0, t);
CHECK_EQ(result_type({a}), t);
std::vector<array> arrs = {array(0, t), array(0, t)};
CHECK_EQ(result_type(arrs), t);
}
{
std::vector<array> arrs = {array(false), array(0, int32)};
CHECK_EQ(result_type(arrs), int32);
}
{
std::vector<array> arrs = {array(0, int32), array(false), array(0.0f)};
CHECK_EQ(result_type(arrs), float32);
}
}