-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdb1a94
commit 9344107
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import nncase | ||
|
||
def read_model_file(model_file): | ||
with open(model_file, 'rb') as f: | ||
model_content = f.read() | ||
return model_content | ||
|
||
def compile_kmodel(model_path): | ||
import_options = nncase.ImportOptions() | ||
compile_options = nncase.CompileOptions() | ||
compile_options.target = "cpu" | ||
compiler = nncase.Compiler(compile_options) | ||
model_content = read_model_file(model_path) | ||
if model_path.split(".")[-1] == "onnx": | ||
compiler.import_onnx(model_content, import_options) | ||
elif model_path.split(".")[-1] == "tflite": | ||
compiler.import_tflite(model_content, import_options) | ||
compiler.compile() | ||
compiler.gencode_tobytes() | ||
|
||
# test failed when the conf in toml but do not set the default value of compile option | ||
def test_compile_option_default_value(): | ||
model_path = "../../examples/user_guide/test.onnx" | ||
kmodel_path = compile_kmodel(model_path) | ||
|
||
if __name__ == "__main__": | ||
pytest.main(['-vv', 'test_compile_option_default_value']) |