VitisInspector is a helper tool that inspects
a float model, shows partition results for a given DPU target architecture, and
indicates 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 inspection
results for it. Note: This feature is only
available for the default
pof2s quantize strategy
because of DPU limitations. The following code shows 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 (DPUCAHX8L_ISA0), a JSON file path (for example, ./U50/arch.json), or a fingerprint. If set to None, no target is applied, and only some general, target-independent inspection results are shown. The default value is None.
- model
-
tf.keras.Model instance. The float
model to be inspected. The model should have concrete input shapes. Build it
with concrete input shapes or call inspect_model with the
input_shapeargument. - 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 the 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 the batch_size dimension should be None or int. If the input shape of the model is variable, such as [None, None, None, 3], 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
graphvizand save the image to disk. It is helpful when you need to visualize the model inspection results with some modification hints.Note: Only some output file types can show the hints, such as.svg.The default value is False. - plot_file
- string. The file path of the model image file when plotting the model. The default value is model.svg.
- dump_results
- bool. Whether to dump the inspection results and save text to disk. More detailed layer-by-layer results than screen logging are dumped into the text file. The default value is False.
- dump_results_file
- string. The file path of inspect results text file. The default value is inspect_results.txt.
- verbose
- int. The logging verbosity level. More detailed logging results are shown for higher verbose values. The default value is 0.