25
25
#include " tensorflow/lite/experimental/litert/cc/litert_macros.h"
26
26
#include " tensorflow/lite/experimental/litert/core/model/model.h"
27
27
#include " tensorflow/lite/experimental/litert/test/common.h"
28
- #include " tensorflow/lite/experimental/litert/test/matchers.h"
29
28
#include " tensorflow/lite/experimental/litert/test/test_models.h"
30
29
#include " tensorflow/lite/experimental/litert/vendors/c/litert_compiler_plugin.h"
31
30
#include " tensorflow/lite/experimental/litert/vendors/cc/litert_compiler_plugin.h"
@@ -43,18 +42,24 @@ const auto kSupportedOps = Values(
43
42
// clang-format on
44
43
45
44
TEST (TestQnnPlugin, GetConfigInfo) {
45
+ #ifndef __ANDROID__
46
+ GTEST_SKIP () << " Loading shared lib not currently supported on linux." ;
47
+ #endif // __ANDROID__
48
+
46
49
EXPECT_STREQ (LiteRtGetCompilerPluginSocManufacturer (), " MediaTek" );
47
50
48
51
auto plugin = CreatePlugin ();
49
52
50
53
LiteRtParamIndex num_supported_soc_models;
51
- LITERT_ASSERT_OK (LiteRtGetNumCompilerPluginSupportedSocModels (
52
- plugin.get (), &num_supported_soc_models));
54
+ ASSERT_EQ (LiteRtGetNumCompilerPluginSupportedSocModels (
55
+ plugin.get (), &num_supported_soc_models),
56
+ kLiteRtStatusOk );
53
57
ASSERT_EQ (num_supported_soc_models, 12 );
54
58
55
59
const char * config_id;
56
- LITERT_ASSERT_OK (
57
- LiteRtGetCompilerPluginSupportedSocModel (plugin.get (), 0 , &config_id));
60
+ ASSERT_EQ (
61
+ LiteRtGetCompilerPluginSupportedSocModel (plugin.get (), 0 , &config_id),
62
+ kLiteRtStatusOk );
58
63
EXPECT_STREQ (config_id, " mt6853" );
59
64
}
60
65
@@ -63,8 +68,9 @@ TEST(TestQnnPlugin, PartitionAdd) {
63
68
auto model = testing::LoadTestFileModel (" add_simple.tflite" );
64
69
65
70
LiteRtOpListT selected_op_list;
66
- LITERT_ASSERT_OK (LiteRtCompilerPluginPartition (
67
- plugin.get (), model.Subgraph (0 )->Get (), &selected_op_list));
71
+ ASSERT_EQ (LiteRtCompilerPluginPartition (
72
+ plugin.get (), model.Subgraph (0 )->Get (), &selected_op_list),
73
+ kLiteRtStatusOk );
68
74
const auto selected_ops = selected_op_list.Vec ();
69
75
70
76
ASSERT_EQ (selected_ops.size (), 1 );
@@ -77,27 +83,30 @@ class MtkPluginOpCompatibilityTest
77
83
: public ::testing::TestWithParam<std::string> {};
78
84
79
85
TEST_P (MtkPluginOpCompatibilityTest, SupportedOpsTest) {
86
+ #ifndef __ANDROID__
87
+ GTEST_SKIP () << " Loading shared lib not currently supported on linux." ;
88
+ #endif // __ANDROID__
89
+
80
90
LITERT_LOG (LITERT_INFO, " Testing TFLite model: %s" , GetParam ().c_str ());
81
91
auto plugin = CreatePlugin ();
82
92
auto model = testing::LoadTestFileModel (GetParam ());
83
93
84
- const auto subgraph = model.MainSubgraph ();
85
- LiteRtSubgraph litert_subgraph = subgraph->Get ();
86
-
87
94
LiteRtCompiledResult compiled;
88
- LITERT_ASSERT_OK (LiteRtCompilerPluginCompile (
89
- plugin.get (), /* soc_model=*/ nullptr , &litert_subgraph, 1 , &compiled));
95
+ ASSERT_EQ (LiteRtCompilerPluginCompile (plugin.get (), /* soc_model=*/ nullptr ,
96
+ model.Get (), &compiled),
97
+ kLiteRtStatusOk );
90
98
91
99
LiteRtParamIndex num_byte_code;
92
- LITERT_ASSERT_OK (
93
- LiteRtCompiledResultNumByteCodeModules (compiled, &num_byte_code) );
100
+ ASSERT_EQ ( LiteRtCompiledResultNumByteCodeModules (compiled, &num_byte_code),
101
+ kLiteRtStatusOk );
94
102
ASSERT_EQ (num_byte_code, 1 );
95
103
96
104
const void * byte_code;
97
105
size_t byte_code_size;
98
106
99
- LITERT_ASSERT_OK (LiteRtGetCompiledResultByteCode (
100
- compiled, /* byte_code_idx=*/ 0 , &byte_code, &byte_code_size));
107
+ ASSERT_EQ (LiteRtGetCompiledResultByteCode (compiled, /* byte_code_idx=*/ 0 ,
108
+ &byte_code, &byte_code_size),
109
+ kLiteRtStatusOk );
101
110
102
111
absl::string_view byte_code_string (reinterpret_cast <const char *>(byte_code),
103
112
byte_code_size);
@@ -107,8 +116,9 @@ TEST_P(MtkPluginOpCompatibilityTest, SupportedOpsTest) {
107
116
size_t op_data_size;
108
117
LiteRtParamIndex byte_code_idx;
109
118
110
- LITERT_ASSERT_OK (LiteRtGetCompiledResultCallInfo (
111
- compiled, /* call_idx=*/ 0 , &op_data, &op_data_size, &byte_code_idx));
119
+ ASSERT_EQ (LiteRtGetCompiledResultCallInfo (compiled, /* call_idx=*/ 0 , &op_data,
120
+ &op_data_size, &byte_code_idx),
121
+ kLiteRtStatusOk );
112
122
113
123
EXPECT_EQ (byte_code_idx, 0 );
114
124
0 commit comments