Inspecting the Float Model - 3.0 English

Vitis AI User Guide (UG1414)

Document ID
UG1414
Release Date
2023-02-24
Version
3.0 English
VitisInspector is an experimental new feature introduced in Vitis AI 2.5 to inspect a float model and show partition results for a given DPU target architecture, together with some indications on why the layers are not mapped to DPU. Without target, you can only show some general, target-independent inspection results. Assign target to get more detailed inspect results for it.
Note: This feature in only available for default pof2s quantize strategy due to DPU limitations. This feature is experimental, please contact us if you encounter any bugs or problems.
The following codes show how to inspect a model.

model = tf.keras.models.load_model(‘float_model.h5’)
from tensorflow_model_optimization.quantization.keras import vitis_inspect
inspector = vitis_inspect.VitisInspector(target="DPUCADF8H_ISA0")
inspector.inspect_model(model, 
                        plot=True, 
                        plot_file="model.svg", 
                        dump_results=True, 
                        dump_results_file="inspect_results.txt", 
                        verbose=0)
target
string or None, the target DPU to deploy this model. It can be a name string (for example, DPUCAHX8L_ISA0), a JSON file path (for example, ./U50/arch.json) or a fingerprint. If set to None, no target will be applied and only some general, target-independent inspect results will be shown. The default value is None.
model
tf.keras.Model instance, the float model to be inspected. Float model should have concrete input shapes. Build the float model with concrete input shapes or call inspect_model with the input_shape argument.
input_shape
list(int) or list(list(int)) or tuple(int) or dictionary(int),  contains the input shape for each input layer. Use default shape info in the input layers if not set. Use list of shapes for multiple inputs, for example inspect_model(model, input_shape=[1, 224, 224, 3]) or inspect_model(model, input_shape=\[[None, 224, 224, 3], [None, 64, 1]]). All dimensions should have concrete values, and batch_size dimension should be None or int.  If the input shape of the model is variable like [None, None, None, 3], you need to specify a shape like [None, 224, 224, 3] to generate the final quantized model. The default value is None.
plot
bool, whether to plot the model inspect results by graphviz and save image to disk. It is helpful when you need to visualize the model inspection results together with some modification hints. Note that only part of output file types can show the hints, such as .svg.The default value is False.
plot_file
string, file path of model image file when plotting the model. The default value is model.svg.
dump_results
bool, whether to dump the inspect results and save text to disk. More detailed layer-by-layer results than screen logging will be dumped to the text file. The default value is False.
dump_results_file
string, file path of inspect results text file. The default value is inspect_results.txt.
verbose
int, the logging verbosity level. More detailed logging results will be shown for higher verbose value. The default value is 0.
Note: A known issue about multi-outputs pattern: 1) Due to Xcompiler's pattern matching problem, when the convolution or add layer has multiple output layers and one of which is a relu activation layer, the result of relu layer may be incorrect. 2) When the relu-like activation layer is followed by multiple convolutional layers, the result of convolutional layer may be incorrect. This issue will be fixed in a later version.