Visualize the quantized model

111357: <p>I have set some qconfig for a model and want to check whether I insert the fake quant in right place or not.<br>
If possible to visualize the quantized model like the ONNX model?</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/8/7886f1282c584112d55eae823bab3245484ab884.png" data-download-href="https://discuss.pytorch.org/uploads/default/7886f1282c584112d55eae823bab3245484ab884" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/8/7886f1282c584112d55eae823bab3245484ab884_2_690x480.png" alt="image" data-base62-sha1="hcepjSnzu2HoLXoDnIagKT60qcQ" width="690" height="480" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/8/7886f1282c584112d55eae823bab3245484ab884_2_690x480.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/8/7886f1282c584112d55eae823bab3245484ab884_2_1035x720.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/8/7886f1282c584112d55eae823bab3245484ab884_2_1380x960.png 2x" data-dominant-color="F1F2F1"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1536×1070 72.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

jerryzh168: <p>Right now we don’t have a visualization tool.</p>
<ul>
<li>for eager mode quantization it is expected that user needs to reason about the model and make sure fake quant are inserted correctly when they place QuantStub/DeQuantStub around the model</li>
<li>for fx graph mode quantization, fake quant will be inserted correctly based on qconfig settings (QConfigMapping), and you can print the model graph (print(prepared_model.graph)) to see where they are</li>
</ul>

ConvolutionalAtom: <p>You can try also the package <strong>torchview</strong>, which provides several features (useful especially for large models). For instance you can set the display depth (depth in nested hierarchy of moduls).</p>
<p>Note: The accepted format for tool is pytorch model,  which would be fine if you can extract pytorch model from onnx format</p>
<p><a href="https://github.com/mert-kurttutan/torchview" rel="noopener nofollow ugc">github repo</a></p>
<p>Disclaimer: I am the author of the package</p>

111357: <p>Hi <a class="mention" href="/u/jerryzh168">@jerryzh168</a>, thanks for your reply. I think the visualization tool is quite important for the user <img src="https://discuss.pytorch.org/images/emoji/apple/blush.png?v=12" title=":blush:" class="emoji" alt=":blush:" loading="lazy" width="20" height="20">. Does the team have plans to add this feature?</p>

12ymh12: <p>Please make visualization tool for fake quantization and converted result.<br>
It’s important to check the actual computational graph is changed from fake quantization to quantized matrix multiplication.</p>

jerryzh168: <p>is this a general visualization for pytorch models? please feel free to request this feature in general pytorch, e.g. by opening issues: <a href="https://github.com/pytorch/pytorch/issues" class="inline-onebox" rel="noopener nofollow ugc">Issues · pytorch/pytorch · GitHub</a></p>