ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Index.cpp File Reference
#include <gtest/gtest.h>
#include "mir/Shape.h"
#include "mir/Index.h"

Go to the source code of this file.

Functions

 TEST (Shape, Base)
 
 TEST (Index, Base)
 

Function Documentation

◆ TEST() [1/2]

TEST ( Index  ,
Base   
)

Definition at line 49 of file Index.cpp.

50{
51 Index idx{3, 2};
52 ASSERT_EQ(idx.rank(), 2);
53 ASSERT_EQ(idx.at(0), 3);
54 ASSERT_EQ(idx.at(1), 2);
55 ASSERT_EQ(idx.at(-1), 2);
56 ASSERT_EQ(idx.at(-2), 3);
57
58 idx.at(1) = 4;
59 ASSERT_EQ(idx.at(1), 4);
60
61 idx.resize(1);
62 ASSERT_EQ(idx.rank(), 1);
63}

◆ TEST() [2/2]

TEST ( Shape  ,
Base   
)

Definition at line 24 of file Index.cpp.

25{
26 Shape s1{3, 2};
27 ASSERT_EQ(s1.rank(), 2);
28 ASSERT_EQ(s1.dim(0), 3);
29 ASSERT_EQ(s1.dim(1), 2);
30 ASSERT_EQ(s1.dim(-1), 2);
31 ASSERT_EQ(s1.dim(-2), 3);
32 ASSERT_EQ(s1.numElements(), 6);
33
34 s1.dim(1) = 4;
35 ASSERT_EQ(s1.dim(1), 4);
36 ASSERT_EQ(s1.numElements(), 12);
37
38 Shape s2 = s1;
39 ASSERT_EQ(s1, s2);
40
41 s2.resize(1);
42 ASSERT_NE(s1, s2);
43
44 s2.resize(2);
45 s2.dim(1) = s1.dim(1);
46 ASSERT_EQ(s1, s2);
47}
Definition Shape.h:28