mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-24 01:17:26 +08:00
27 lines
575 B
C++
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);
|
|
}
|
|
}
|