ONNX - Operators
Operators in ONNX are the building blocks that define computations in a machine learning model, mapping operations from various frameworks (like TensorFlow, PyTorch, etc.) into a standardized ONNX format.
In this tutorial, well explore what ONNX operators are, the different types, and how they function in ONNX-compatible models.
What are ONNX Operators?
An ONNX operator is a fundamental unit of computation used in an ONNX model. Each operator defines a specific type of operation, such as mathematical computations, data processing, or neural network layers. Operators are identified by a tuple −
<name, domain, version>
Where,
- name: The name of the operator.
- domain: The namespace to which the operator belongs.
- version: The version of the operator (to track updates and changes).
Core Operators in ONNX
Core operators are the standard set of operators that come with ONNX and ONNX-ML. These operators are highly optimized and supported by any ONNX-compatible product. These operators are designed to cover most common machine learning tasks and cannot generally be meaningfully further decomposed into simpler operations.
Key Features of Core Operators −
- These are standard operators defined within the ONNX framework.
- The ai.onnx domain contains 124 operators, while the ai.onnx.ml domain (focused on machine learning tasks) contains 19 operators.
- Core operators support various problem areas such as image classification, recommendation systems, and natural language processing.
The ai.onnx Domain Operators
Following are the list of ai.onnx operators −
| S.No | Operator |
|---|---|
| 1 | Abs |
| 2 | Acos |
| 3 | Acosh |
| 4 | Add |
| 5 | AffineGrid |
| 6 | And |
| 7 | ArgMax |
| 8 | ArgMin |
| 9 | Asin |
| 10 | Asinh |
| 11 | Atan |
| 12 | Atanh |
| 13 | AveragePool |
| 14 | BatchNormalization |
| 15 | Bernoulli |
| 16 | BitShift |
| 17 | BitwiseAnd |
| 18 | BitwiseNot |
| 19 | BitwiseOr |
| 20 | BitwiseXor |
| 21 | BlackmanWindow |
| 22 | Cast |
| 23 | CastLike |
| 24 | Ceil |
| 25 | Celu |
| 26 | CenterCropPad |
| 27 | Clip |
| 28 | Col2Im |
| 29 | Compress |
| 30 | Concat |
| 31 | ConcatFromSequence |
| 32 | Constant |
| 33 | ConstantOfShape |
| 34 | Conv |
| 35 | ConvInteger |
| 36 | ConvTranspose |
| 37 | Cos |
| 38 | Cosh |
| 39 | CumSum |
| 40 | DFT |
| 41 | DeformConv |
| 42 | DepthToSpace |
| 43 | DequantizeLinear |
| 44 | Det |
| 45 | Div |
| 46 | Dropout |
| 47 | DynamicQuantizeLinear |
| 48 | Einsum |
| 49 | Elu |
| 50 | Equal |
| 51 | Erf |
| 52 | Exp |
| 53 | Expand |
| 54 | EyeLike |
| 55 | Flatten |
| 56 | Floor |
| 57 | GRU |
| 58 | Gather |
| 59 | GatherElements |
| 60 | GatherND |
| 61 | Gelu |
| 62 | Gemm |
| 63 | GlobalAveragePool |
| 64 | GlobalLpPool |
| 65 | GlobalMaxPool |
| 66 | Greater |
| 67 | GreaterOrEqual |
| 68 | GridSample |
| 69 | GroupNormalization |
| 70 | HammingWindow |
| 71 | HannWindow |
| 72 | HardSigmoid |
| 73 | HardSwish |
| 74 | Hardmax |
| 75 | Identity |
| 76 | If |
| 77 | ImageDecoder |
| 78 | InstanceNormalization |
| 79 | IsInf |
| 80 | IsNaN |
| 81 | LRN |
| 82 | LSTM |
| 83 | LayerNormalization |
| 84 | LeakyRelu |
| 85 | Less |
| 86 | LessOrEqual |
| 87 | Log |
| 88 | LogSoftmax |
| 89 | Loop |
| 90 | LpNormalization |
| 91 | LpPool |
| 92 | MatMul |
| 93 | MatMulInteger |
| 94 | Max |
| 95 | MaxPool |
| 96 | MaxRoiPool |
| 97 | MaxUnpool |
| 98 | Mean |
| 99 | MeanVarianceNormalization |
| 100 | MelWeightMatrix |
| 101 | Min |
| 102 | Mish |
| 103 | Mod |
| 104 | Mul |
| 105 | Multinomial |
| 106 | Neg |
| 107 | NonMaxSuppression |
| 108 | NonZero |
| 109 | Not |
| 110 | OneHot |
| 111 | Optional |
| 112 | Or |
| 113 | PRelu |
| 114 | Pad |
| 115 | Pow |
| 116 | QLinearAdd |
| 117 | QLinearAveragePool |
| 118 | QLinearConcat |
| 119 | QLinearConv |
| 120 | QLinearLeakyRelu |
| 121 | QLinearMul |
| 122 | QLinearSigmoid |
| 123 | QLinearSoftmax |
| 124 | QLinearTranspose |
The ai.onnx.ml Domain Operators
Below are the list of all available operators in the ai.onnx.ml domain.
| S.No | Operator |
|---|---|
| 1 | ArrayFeatureExtractor |
| 2 | Binarizer |
| 3 | CastMap |
| 4 | CategoryMapper |
| 5 | DictVectorizer |
| 6 | FeatureVectorizer |
| 7 | Imputer |
| 8 | LabelEncoder |
| 9 | LinearClassifier |
| 10 | LinearRegressor |
| 11 | Normalizer |
| 12 | OneHotEncoder |
| 13 | SVMClassifier |
| 14 | SVMRegressor |
| 15 | Scaler |
| 16 | TreeEnsemble |
| 17 | TreeEnsembleClassifier |
| 18 | TreeEnsembleRegressor |
| 19 | ZipMap |
Custom Operators in ONNX
In addition to core operators, ONNX allows developers to define custom operators for more specialized or non-standard tasks.
- If a particular operation does not exist in the ONNX operator set, or if a developer creates a new technique or custom activation function, they can define a custom operator.
- Custom operators are identified by a custom domain name, distinguishing them from core operators.