Views
No views yet
.pb model doing1# setup environment
2python3.10 -m venv pytf
3source pytf/bin/activate
4
5# install latest officially compatible versions
6pip install tensorflow==2.15.1 tf2onnx==1.16.1
7
8# use most recent opset officially supported
9python -m tf2onnx.convert \
10 --saved-model <path/to/dir> \
11 --output converted_ds_cnn.onnx --opset 181import onnx
2import onnxruntime
3
4import aidge_core as ai
5import aidge_onnx
6
7model_onnx = onnx.load_model("converted_ds_cnn.onnx")
8model_onnx_clean_nhwc = aidge_onnx.onnx_cleaner.clean_onnx(
9 model_onnx, {"input_1": [[1, 49, 10, 1]]}, "test_clean", opset_version=18
10)
11model = aidge_onnx.convert_onnx_to_aidge(model_onnx_clean_nhwc)
12
13to_replace: set[ai.Node] = set(
14 [
15 model.get_node("StatefulPartitionedCall_functional_1_conv2d_BiasAdd__6"),
16 model.get_node("new_shape__103_out0"),
17 ]
18)
19
20model.replace(to_replace, set())
21model.set_mandatory_inputs_first()
22
23model.forward_dims(dims=[[1, 1, 49, 10]], allow_data_dependency=True)
24model_onnx_clean_nchw = aidge_onnx.convert_aidge_to_onnx(model, "ds_cnn", opset=18)
25onnx.save_model(model_onnx_clean_nchw, "ds_cnn.onnx")Note: We tested this network for the following features. If you encounter any error please open an issue. Features not tested in CI may not be functional.
| Feature | Tested in CI |
|---|---|
| ONNX import | ✔️ |
| Runtime CPU | ✔️ |
| Runtime CUDA | ✔️ |
| Export CPU | ✔️ |