Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在不导出的情况下将 PyTorch 模型转换为 ONNX,并在脚本中直接将其用作 ONNX 对象。
您可以导出到内存,如下所示:
import io f = io.BytesIO() torch.onnx.export(model, sample_inputs, f, ...) onnx_model = onnx.load_model_from_string(f.getvalue())