ONNX¶
- class tract.onnx.Onnx[source]¶
Represent the ONNX context in tract.
It essentially allows to load ONNX models. Note that an ONNX model is loaded as an
InferenceModeland not as aModel: many ONNX models come with partial shape and element type information, while tract’sModelassume full shape and element type knownledge. In this case, it is generally sufficient to inform tract about the input shape and type, then let tract infer the rest of the missing shape information before converting theInferenceModelto a regularModel.# load the model as an InferenceModel model = tract.onnx().load("./mobilenetv2-7.onnx") # set the shape and type of its first and only input model.set_input_fact(0, "1,3,224,224,f32") # get ready to run the model model = model.into_model().into_runnable()
- load(path: str | Path) InferenceModel[source]¶
Load an ONNX file as an InferenceModel