Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
FusionBolt committed Aug 28, 2023
1 parent fdb1a94 commit 9344107
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ jobs:
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_basic.xml pytest tests/importer/tflite_/basic/ --doctest-modules --junitxml=test_results/tflite_basic.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_combine.xml pytest tests/importer/tflite_/combine/ --doctest-modules --junitxml=test_results/tflite_combine.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_model.xml pytest tests/importer/tflite_/model/ --doctest-modules --junitxml=test_results/tflite_model.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_model.xml pytest tests/other --doctest-modules --junitxml=test_results/tflite_model.xml
dotnet-coverage merge -o coverage.integration.xml -f cobertura -r coverage/*.xml
- name: Upload Coverage
Expand Down
27 changes: 27 additions & 0 deletions tests/other/test_compile_option_default_value.py
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'])

0 comments on commit 9344107

Please sign in to comment.