MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/lite/kernels/hashtable_lookup_test.cc:103–124  ·  view source on GitHub ↗

TODO(yichengfan): write more tests that exercise the details of the op, such as lookup errors and variable input shapes.

Source from the content-addressed store, hash-verified

101// TODO(yichengfan): write more tests that exercise the details of the op,
102// such as lookup errors and variable input shapes.
103TEST(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
126TEST(HashtableLookupOpTest, Test1DInput) {
127 HashtableLookupOpModel m({4}, {3}, {3}, TensorType_FLOAT32);

Callers

nothing calls this directly

Calls 8

ArrayFloatNearFunction · 0.70
SetLookupMethod · 0.45
SetHashtableKeyMethod · 0.45
SetHashtableValueMethod · 0.45
InvokeMethod · 0.45
GetOutputMethod · 0.45
GetHitMethod · 0.45
GetStringOutputMethod · 0.45

Tested by

no test coverage detected