This Python API is experimental yet. It can be changed later.
Use the nnpackage examples to run tutorial code.
Please see nnfw python api for installing nnfw python api.
- Initialize nnfw_session
# Create session and load nnpackage
# operations is optional to assign a specific backends to each operation.
# The default value of backends is "cpu".
if operations:
session = nnfw_session(nnpackage_path, backends, operations)
else:
session = nnfw_session(nnpackage_path, backends)
- Prepare Input
# Prepare input. Here we just allocate dummy input arrays.
input_size = session.input_size()
session.set_inputs(input_size)
- Inference
# Do inference
outputs = session.inference()
reference app : minimal-python app
$ python3 minimal.py path_to_nnpackage_directory