after using onnx export in pytorch, reading the model as txt file shows that all the…
- User
after using onnx export in pytorch, reading the model as txt file shows that all the stack trace is kept. how to remove it, either at export time or postprocessing
Assistant
Let me help you with removing stack traces from ONNX models. There are a few approaches you can take:
- During export time, you can use
strip_doc_string=True:
torch.onnx.export( model, dummy_input, "model.onnx", strip_doc_string=True # This removes doc strings including stack traces )- For post-processing, you can use the ONNX API to remove doc strings:
import onnx # Load the model model = onnx.load("model.onnx") # Remove doc strings for node in model.graph.node: node.doc_string = "" # Save the cleaned model onnx.save(model, "cleaned_model.onnx")- During export time, you can use
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.