mirror of
https://github.com/ml-explore/mlx.git
synced 2025-10-20 01:18:12 +08:00
Use int64 stride everywhere (#1671)
* use int64 stride everywhere * fix ext * fix ext * more shape + cleanup * one more * few more
This commit is contained in:
@@ -37,46 +37,9 @@ TEST_CASE("test normalize axis") {
|
||||
{0, 3, 0}, {1, 3, 1}, {2, 3, 2}, {-1, 3, 2}, {-2, 3, 1}, {-3, 3, 0}};
|
||||
|
||||
for (const auto& tc : testCases) {
|
||||
CHECK_EQ(normalize_axis(tc.axis, tc.ndim), tc.expected);
|
||||
CHECK_EQ(normalize_axis_index(tc.axis, tc.ndim), tc.expected);
|
||||
}
|
||||
|
||||
CHECK_THROWS(normalize_axis(3, 3));
|
||||
CHECK_THROWS(normalize_axis(-4, 3));
|
||||
}
|
||||
|
||||
TEST_CASE("test is same size and shape") {
|
||||
struct TestCase {
|
||||
std::vector<array> a;
|
||||
bool expected;
|
||||
};
|
||||
|
||||
std::vector<TestCase> testCases = {
|
||||
{{array({}), array({})}, true},
|
||||
{{array({1}), array({1})}, true},
|
||||
{{array({1, 2, 3}), array({1, 2, 4})}, true},
|
||||
{{array({1, 2, 3}), array({1, 2})}, false}};
|
||||
|
||||
for (const auto& tc : testCases) {
|
||||
CHECK_EQ(is_same_shape(tc.a), tc.expected);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("test check shape dimension") {
|
||||
int dim_min = std::numeric_limits<int>::min();
|
||||
int dim_max = std::numeric_limits<int>::max();
|
||||
CHECK_EQ(check_shape_dim(-4), -4);
|
||||
CHECK_EQ(check_shape_dim(0), 0);
|
||||
CHECK_EQ(check_shape_dim(12), 12);
|
||||
CHECK_EQ(check_shape_dim(static_cast<int64_t>(dim_min)), dim_min);
|
||||
CHECK_EQ(check_shape_dim(static_cast<int64_t>(dim_max)), dim_max);
|
||||
CHECK_EQ(check_shape_dim(static_cast<size_t>(0)), 0);
|
||||
CHECK_EQ(check_shape_dim(static_cast<size_t>(dim_max)), dim_max);
|
||||
CHECK_THROWS_AS(
|
||||
check_shape_dim(static_cast<int64_t>(dim_min) - 1),
|
||||
std::invalid_argument);
|
||||
CHECK_THROWS_AS(
|
||||
check_shape_dim(static_cast<int64_t>(dim_max) + 1),
|
||||
std::invalid_argument);
|
||||
CHECK_THROWS_AS(
|
||||
check_shape_dim(static_cast<size_t>(dim_max) + 1), std::invalid_argument);
|
||||
CHECK_THROWS(normalize_axis_index(3, 3));
|
||||
CHECK_THROWS(normalize_axis_index(-4, 3));
|
||||
}
|
||||
|
Reference in New Issue
Block a user