Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/ttl/bits/std_shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ N product(Iterator begin, Iterator end)
};

template <size_t off, typename T, size_t r, size_t... Is>
constexpr std::array<T, r - 1> shift_idx(const std::array<T, r> &a,
std::index_sequence<Is...>)
constexpr std::array<T, r - off> shift_idx(const std::array<T, r> &a,
std::index_sequence<Is...>)
{
return std::array<T, r - 1>({std::get<Is + off>(a)...});
return std::array<T, r - off>({std::get<Is + off>(a)...});
}

using rank_t = uint8_t;
Expand Down
11 changes: 10 additions & 1 deletion tests/test_shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ TEST(shape_test, test_flatten)
ASSERT_EQ(s8, ttl::shape<1>(720));
}

struct S {
struct Test_constexpr {
static constexpr auto shape = ttl::make_shape(2, 3);
};

Expand All @@ -195,3 +195,12 @@ TEST(shape_test, test_batch_vectorize)
auto vs1 = ttl::vectorize(shape);
ASSERT_EQ(vs1, ttl::make_shape(2, 3, 1));
}

TEST(shape_test, test_subshape)
{
auto s = ttl::make_shape(1, 2, 3, 4);
auto t1 = s.subshape(); // (2, 3, 4)
ASSERT_EQ(t1.size(), 24);
auto t2 = s.subshape<2>(); // (3, 4)
ASSERT_EQ(t2.size(), 12);
}