-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathaot_compile_test.py
More file actions
57 lines (48 loc) · 1.96 KB
/
aot_compile_test.py
File metadata and controls
57 lines (48 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2025 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
from absl.testing import absltest as googletest
from litert.python.aot import aot_compile as aot_compile_lib
from litert.python.aot.core import aot_types
from litert.python.aot.core import test_common
from litert.python.aot.vendors.mediatek import target as mtk_target
from litert.python.aot.vendors.qualcomm import target as qnn_target
class AotCompileTest(test_common.TestWithTfliteModels):
def test_compile(self):
sm8450_target = qnn_target.Target(qnn_target.SocModel.SM8450)
mt6989_target = mtk_target.Target(mtk_target.SocModel.MT6989)
results = []
for path in self.get_model_paths():
results.append(
aot_compile_lib.aot_compile(
aot_types.Model.create_from_path(path),
output_dir=self.output_dir(),
target=[sm8450_target, mt6989_target],
keep_going=True,
)
)
failed_backends = []
models = []
for result in results:
if result.failed_backends:
failed_backends.extend(result.failed_backends)
for model in result.models:
model.load()
models.append(model)
self.assertEmpty(failed_backends)
self.assertNotEmpty(models)
for model in models:
self.assertIn("DISPATCH_OP", str(model.model_bytes))
if __name__ == "__main__":
googletest.main()