TODO(yichengfan): write more tests that exercise the details of the op, such as lookup errors and variable input shapes.
| 101 | // TODO(yichengfan): write more tests that exercise the details of the op, |
| 102 | // such as lookup errors and variable input shapes. |
| 103 | TEST(HashtableLookupOpTest, Test2DInput) { |
| 104 | HashtableLookupOpModel m({4}, {3}, {3, 2}, TensorType_FLOAT32); |
| 105 | |
| 106 | m.SetLookup({1234, -292, -11, 0}); |
| 107 | m.SetHashtableKey({-11, 0, 1234}); |
| 108 | m.SetHashtableValue([](int i, int j) { return i + j / 10.0f; }); |
| 109 | |
| 110 | m.Invoke(); |
| 111 | |
| 112 | EXPECT_THAT(m.GetOutput(), ElementsAreArray(ArrayFloatNear({ |
| 113 | 2.0, 2.1, // 2-nd item |
| 114 | 0, 0, // Not found |
| 115 | 0.0, 0.1, // 0-th item |
| 116 | 1.0, 1.1, // 1-st item |
| 117 | }))); |
| 118 | EXPECT_THAT(m.GetHit(), ElementsAreArray({ |
| 119 | 1, |
| 120 | 0, |
| 121 | 1, |
| 122 | 1, |
| 123 | })); |
| 124 | } |
| 125 | |
| 126 | TEST(HashtableLookupOpTest, Test1DInput) { |
| 127 | HashtableLookupOpModel m({4}, {3}, {3}, TensorType_FLOAT32); |
nothing calls this directly
no test coverage detected