How to execute "polygraphy surgeon sanitize --fold-constants sample.onnx -o sampleFolded.onnx"?


I have installed the package using “python -m pip install colored polygraphy --extra-index-url

Now, I am not sure what to do to properly execute “polygraphy surgeon sanitize --fold-constants sample.onnx -o sampleFolded.onnx” since I mostly work in Jupyter and am not so familiar with executing Python CLI commands.

It’d be great if someone could, please, list the steps to run the command either from a command line window or Jupyter.

I use Anaconda (Win10).



Hope the following may help you.

Thank you.

Hi spolisetty,

Thank you for your suggestion.

I ended up doing it from the command line. I just had to find where the script was and install graph surgeon and onnxruntime.

However, polygraphy didn’t solve my [IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2] problem and I will make another post to see if any of the moderators can help me solve the issue. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.