The create_test_dir helper can create the input and output pb files in various ways.
Often a support request will only provide a problematic model and no input data. create_test_dir can be used to create input to allow the model to be debugged more easily. Random input can be generated if not provided. If expected output is not provided, the model will be run with the input, and the output from that will be saved as the expected output.
To execute the test once the directory is created you can use the onnx_test_runner or onnxruntime_perf_test executables if you have built onnxruntime from source, or the run_test_dir helper. Input can be either the test directory, or the model in case there are multiple in the test directory.
```python
def run_test_dir(model_or_dir):
"""
Run the test/s from a directory in ONNX test format.
All subdirectories with a prefix of 'test' are considered test input for one test run.
:param model_or_dir: Path to onnx model in test directory,
or the test directory name if the directory only contains one .onnx model.
--channels_last Transpose image from channels first to channels last.
--add_batch_dim Prepend a batch dimension with value of 1 to the shape. i.e. convert from CHW to NCHW
random_to_pb:
random_to_pb specific options
--shape SHAPE Provide the shape as comma separated values e.g. --shape 200,200
--datatype DATATYPE numpy dtype value for the data type. e.g. f4=float32, i8=int64. See: https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html
--min_value MIN_VALUE
Limit the generated values to this minimum.
--max_value MAX_VALUE
Limit the generated values to this maximum.
--seed SEED seed to use for the random values so they're deterministic.
```
## dump_subgraphs.py
If you're investigating a model with control flow nodes (Scan/Loop/If) the subgraphs won't be displayed in Netron. Run dump_subgraphs to dump the subgraphs as .onnx files that can be viewed individually.
```
usage: dump_subgraphs.py [-h] -m MODEL [-o OUT]
Dump all subgraphs from an ONNX model into separate onnx files.
optional arguments:
-h, --help show this help message and exit
-m MODEL, --model MODEL model file
-o OUT, --out OUT output directory (default: <currentdire)