Tensor by Tensor

MODULE 03 · LESSON 02

Export from PyTorch

Export converts model operations into ONNX. Verification compares old and new outputs.

PLAIN-LANGUAGE INTRODUCTION

What is this?

Export converts model operations into ONNX. Verification compares old and new outputs.

One simple example

PyTorch returns [0.2,0.8]. ONNX Runtime returns [0.200001,0.799999]. Both differences are 0.000001.

What goes in?

A trained model, representative inputs, and a chosen tolerance.

What comes out?

An ONNX file plus matching-shape and matching-value evidence.

Why does it matter?

Verification catches changed behavior before deployment.

What is it not?

A successful file write does not prove correct exported predictions.

WORK THROUGH THE IDEA

See the idea in more detail

  1. Run one fixed input through the original model. Save output [0.2,0.8].
  2. Export with the intended input names, output names, shapes, and operator-set version.
  3. Run the same input in ONNX Runtime. This illustration returns [0.200001,0.799999].
  4. Each absolute difference is 0.000001. That passes a chosen tolerance of 0.00001.
  5. Common mistake: testing only one easy shape misses dynamic-shape export problems.
Open the detailed notes ↗