TEST(ADT_TENSOR_INDEX, copy)
{
- nncc::core::ADT::tensor::Index original;
-
- original.resize(4);
-
- uint32_t indices[4] = {3, 5, 2, 7};
-
- for (uint32_t axis = 0; axis < 4; ++axis)
- {
- original.at(axis) = indices[axis];
- }
-
+ const nncc::core::ADT::tensor::Index original{3, 5, 2, 7};
const nncc::core::ADT::tensor::Index copied{original};
ASSERT_EQ(original.rank(), copied.rank());
TEST(ADT_TENSOR_INDEX_RANGE, member_positive)
{
- nncc::core::ADT::tensor::Shape shape;
-
- shape.resize(1);
- shape.dim(0) = 3;
-
- nncc::core::ADT::tensor::Index index;
-
- index.resize(1);
- index.at(0) = 2;
+ const nncc::core::ADT::tensor::Shape shape{3};
+ const nncc::core::ADT::tensor::Index index{2};
ASSERT_TRUE(nncc::core::ADT::tensor::IndexRange{shape}.member(index));
}
TEST(ADT_TENSOR_INDEX_RANGE, member_negative_unmatched_rank)
{
- nncc::core::ADT::tensor::Shape shape;
-
- shape.resize(1);
- shape.dim(0) = 3;
-
- nncc::core::ADT::tensor::Index index;
-
- index.resize(2);
- index.at(0) = 2;
- index.at(1) = 3;
+ const nncc::core::ADT::tensor::Shape shape{3};
+ const nncc::core::ADT::tensor::Index index{2, 3};
ASSERT_FALSE(nncc::core::ADT::tensor::IndexRange{shape}.member(index));
}
TEST(ADT_TENSOR_INDEX_RANGE, member_negative_overflowed_dim)
{
- nncc::core::ADT::tensor::Shape shape;
-
- shape.resize(1);
- shape.dim(0) = 3;
-
- nncc::core::ADT::tensor::Index index;
-
- index.resize(1);
- index.at(0) = 4;
+ const nncc::core::ADT::tensor::Shape shape{3};
+ const nncc::core::ADT::tensor::Index index{4};
ASSERT_FALSE(nncc::core::ADT::tensor::IndexRange{shape}.member(index));
}
TEST(ADT_TENSOR_INDEX_RANGE, iterate_empty_range)
{
- nncc::core::ADT::tensor::Shape shape;
-
- shape.resize(1);
- shape.dim(0) = 0;
+ const nncc::core::ADT::tensor::Shape shape{0};
uint32_t count = 0;
TEST(ADT_TENSOR_INDEX_RANGE, iterate_full_range)
{
- nncc::core::ADT::tensor::Shape shape;
-
- shape.resize(2);
- shape.dim(0) = 3;
- shape.dim(1) = 4;
+ const nncc::core::ADT::tensor::Shape shape{3, 4};
std::array<uint32_t, 3 * 4> count;
TEST(ADT_TENSOR_SHAPE, copy)
{
- nncc::core::ADT::tensor::Shape original;
-
- original.resize(4);
-
- uint32_t dims[4] = {3, 5, 2, 7};
-
- for (uint32_t axis = 0; axis < 4; ++axis)
- {
- original.dim(axis) = dims[axis];
- }
-
+ const nncc::core::ADT::tensor::Shape original{3, 5, 2, 7};
const nncc::core::ADT::tensor::Shape copied{original};
ASSERT_EQ(original.rank(), copied.rank());
TEST(ADT_TENSOR_SHAPE, eq_negative_on_unmatched_rank)
{
- nncc::core::ADT::tensor::Shape left;
- nncc::core::ADT::tensor::Shape right;
-
- left.resize(3);
- right.resize(4);
+ const nncc::core::ADT::tensor::Shape left{1, 1, 1};
+ const nncc::core::ADT::tensor::Shape right{1, 1, 1, 1};
ASSERT_FALSE(left == right);
}
TEST(ADT_TENSOR_SHAPE, eq_negative_on_unmatched_dim)
{
- nncc::core::ADT::tensor::Shape left;
- nncc::core::ADT::tensor::Shape right;
-
- left.resize(2);
- left.dim(0) = 2;
- left.dim(1) = 3;
-
- right.resize(2);
- right.dim(0) = 2;
- right.dim(1) = 4;
+ const nncc::core::ADT::tensor::Shape left{2, 3};
+ const nncc::core::ADT::tensor::Shape right{2, 4};
ASSERT_FALSE(left == right);
}
TEST(ADT_TENSOR_SHAPE, eq_positive)
{
- nncc::core::ADT::tensor::Shape left;
- nncc::core::ADT::tensor::Shape right;
-
- left.resize(2);
- left.dim(0) = 2;
- left.dim(1) = 3;
-
- right.resize(2);
- right.dim(0) = 2;
- right.dim(1) = 3;
+ const nncc::core::ADT::tensor::Shape left{2, 3};
+ const nncc::core::ADT::tensor::Shape right{2, 3};
ASSERT_TRUE(left == right);
}