Supported scikit-learn Models#

skl2onnx currently can convert the following list of models for skl2onnx . They were tested using onnxruntime . All the following classes overloads the following methods such as OnnxSklearnPipeline does. They wrap existing scikit-learn classes by dynamically creating a new one which inherits from OnnxOperatorMixin which implements to_onnx methods.

Covered Converters#

Name

Package

Supported

ARDRegression

linear_model

Yes

AdaBoostClassifier

ensemble

Yes

AdaBoostRegressor

ensemble

Yes

AdditiveChi2Sampler

kernel_approximation

AffinityPropagation

cluster

AgglomerativeClustering

cluster

BaggingClassifier

ensemble

Yes

BaggingRegressor

ensemble

Yes

BaseDecisionTree

tree

BaseEnsemble

ensemble

BayesianGaussianMixture

mixture

Yes

BayesianRidge

linear_model

Yes

BernoulliNB

naive_bayes

Yes

BernoulliRBM

neural_network

Binarizer

preprocessing

Yes

Birch

cluster

BisectingKMeans

cluster

CCA

cross_decomposition

CalibratedClassifierCV

calibration

Yes

CategoricalNB

naive_bayes

Yes

ClassifierChain

multioutput

ComplementNB

naive_bayes

Yes

DBSCAN

cluster

DecisionTreeClassifier

tree

Yes

DecisionTreeRegressor

tree

Yes

DictVectorizer

feature_extraction

Yes

DictionaryLearning

decomposition

ElasticNet

linear_model

Yes

ElasticNetCV

linear_model

Yes

EllipticEnvelope

covariance

EmpiricalCovariance

covariance

ExtraTreeClassifier

tree

Yes

ExtraTreeRegressor

tree

Yes

ExtraTreesClassifier

ensemble

Yes

ExtraTreesRegressor

ensemble

Yes

FactorAnalysis

decomposition

FastICA

decomposition

FeatureAgglomeration

cluster

FeatureHasher

feature_extraction

Yes

FunctionTransformer

preprocessing

Yes

GammaRegressor

linear_model

Yes

GaussianMixture

mixture

Yes

GaussianNB

naive_bayes

Yes

GaussianProcessClassifier

gaussian_process

Yes

GaussianProcessRegressor

gaussian_process

Yes

GaussianRandomProjection

random_projection

Yes

GenericUnivariateSelect

feature_selection

Yes

GradientBoostingClassifier

ensemble

Yes

GradientBoostingRegressor

ensemble

Yes

GraphicalLasso

covariance

GraphicalLassoCV

covariance

GridSearchCV

model_selection

Yes

HDBSCAN

cluster

HistGradientBoostingClassifier

ensemble

Yes

HistGradientBoostingRegressor

ensemble

Yes

HuberRegressor

linear_model

Yes

IncrementalPCA

decomposition

Yes

IsolationForest

ensemble

Yes

IsotonicRegression

isotonic

KBinsDiscretizer

preprocessing

Yes

KMeans

cluster

Yes

KNNImputer

impute

Yes

KNeighborsClassifier

neighbors

Yes

KNeighborsRegressor

neighbors

Yes

KNeighborsTransformer

neighbors

Yes

KernelCenterer

preprocessing

Yes

KernelDensity

neighbors

KernelPCA

decomposition

Yes

KernelRidge

kernel_ridge

LabelBinarizer

preprocessing

Yes

LabelEncoder

preprocessing

Yes

LabelPropagation

semi_supervised

LabelSpreading

semi_supervised

Lars

linear_model

Yes

LarsCV

linear_model

Yes

Lasso

linear_model

Yes

LassoCV

linear_model

Yes

LassoLars

linear_model

Yes

LassoLarsCV

linear_model

Yes

LassoLarsIC

linear_model

Yes

LatentDirichletAllocation

decomposition

LedoitWolf

covariance

LinearDiscriminantAnalysis

discriminant_analysis

Yes

LinearRegression

linear_model

Yes

LinearSVC

svm

Yes

LinearSVR

svm

Yes

LocalOutlierFactor

neighbors

Yes

LogisticRegression

linear_model

Yes

LogisticRegressionCV

linear_model

Yes

MLPClassifier

neural_network

Yes

MLPRegressor

neural_network

Yes

MaxAbsScaler

preprocessing

Yes

MeanShift

cluster

MinCovDet

covariance

MinMaxScaler

preprocessing

Yes

MiniBatchDictionaryLearning

decomposition

MiniBatchKMeans

cluster

Yes

MiniBatchNMF

decomposition

MiniBatchSparsePCA

decomposition

MissingIndicator

impute

MultiLabelBinarizer

preprocessing

MultiOutputClassifier

multioutput

Yes

MultiOutputRegressor

multioutput

Yes

MultiTaskElasticNet

linear_model

Yes

MultiTaskElasticNetCV

linear_model

Yes

MultiTaskLasso

linear_model

Yes

MultiTaskLassoCV

linear_model

Yes

MultinomialNB

naive_bayes

Yes

NMF

decomposition

NearestCentroid

neighbors

NearestNeighbors

neighbors

Yes

NeighborhoodComponentsAnalysis

neighbors

Yes

Normalizer

preprocessing

Yes

NuSVC

svm

Yes

NuSVR

svm

Yes

Nystroem

kernel_approximation

OAS

covariance

OPTICS

cluster

OneClassSVM

svm

Yes

OneHotEncoder

preprocessing

Yes

OneVsOneClassifier

multiclass

Yes

OneVsRestClassifier

multiclass

Yes

OrdinalEncoder

preprocessing

Yes

OrthogonalMatchingPursuit

linear_model

Yes

OrthogonalMatchingPursuitCV

linear_model

Yes

OutputCodeClassifier

multiclass

PCA

decomposition

Yes

PLSCanonical

cross_decomposition

PLSRegression

cross_decomposition

Yes

PLSSVD

cross_decomposition

PassiveAggressiveClassifier

linear_model

Yes

PassiveAggressiveRegressor

linear_model

Yes

Perceptron

linear_model

Yes

PoissonRegressor

linear_model

Yes

PolynomialCountSketch

kernel_approximation

PolynomialFeatures

preprocessing

Yes

PowerTransformer

preprocessing

Yes

QuadraticDiscriminantAnalysis

discriminant_analysis

Yes

QuantileRegressor

linear_model

Yes

QuantileTransformer

preprocessing

RANSACRegressor

linear_model

Yes

RBFSampler

kernel_approximation

RFE

feature_selection

Yes

RFECV

feature_selection

Yes

RadiusNeighborsClassifier

neighbors

Yes

RadiusNeighborsRegressor

neighbors

Yes

RadiusNeighborsTransformer

neighbors

RandomForestClassifier

ensemble

Yes

RandomForestRegressor

ensemble

Yes

RandomTreesEmbedding

ensemble

Yes

RandomizedSearchCV

model_selection

RegressorChain

multioutput

Ridge

linear_model

Yes

RidgeCV

linear_model

Yes

RidgeClassifier

linear_model

Yes

RidgeClassifierCV

linear_model

Yes

RobustScaler

preprocessing

Yes

SGDClassifier

linear_model

Yes

SGDOneClassSVM

linear_model

Yes

SGDRegressor

linear_model

Yes

SVC

svm

Yes

SVR

svm

Yes

SelectFdr

feature_selection

Yes

SelectFpr

feature_selection

Yes

SelectFromModel

feature_selection

Yes

SelectFwe

feature_selection

Yes

SelectKBest

feature_selection

Yes

SelectPercentile

feature_selection

Yes

SelfTrainingClassifier

semi_supervised

SequentialFeatureSelector

feature_selection

ShrunkCovariance

covariance

SimpleImputer

impute

Yes

SkewedChi2Sampler

kernel_approximation

SparseCoder

decomposition

SparsePCA

decomposition

SparseRandomProjection

random_projection

SpectralBiclustering

cluster

SpectralClustering

cluster

SpectralCoclustering

cluster

SplineTransformer

preprocessing

StackingClassifier

ensemble

Yes

StackingRegressor

ensemble

Yes

StandardScaler

preprocessing

Yes

TargetEncoder

preprocessing

TheilSenRegressor

linear_model

Yes

TransformedTargetRegressor

compose

TruncatedSVD

decomposition

Yes

TweedieRegressor

linear_model

Yes

VarianceThreshold

feature_selection

Yes

VotingClassifier

ensemble

Yes

VotingRegressor

ensemble

Yes

scikit-learn’s version is 1.5.dev0. 130/191 models are covered.

Converters Documentation#

OnnxCastRegressor

OnnxSklearnKNeighborsClassifier

OnnxSklearnPassiveAggressiveClassifier

OnnxCastTransformer

OnnxSklearnKNeighborsRegressor

OnnxSklearnPassiveAggressiveRegressor

OnnxReplaceTransformer

OnnxSklearnKNeighborsTransformer

OnnxSklearnPerceptron

OnnxSklearnARDRegression

OnnxSklearnKernelCenterer

OnnxSklearnPipeline

OnnxSklearnAdaBoostClassifier

OnnxSklearnKernelPCA

OnnxSklearnPoissonRegressor

OnnxSklearnAdaBoostRegressor

OnnxSklearnLabelBinarizer

OnnxSklearnPolynomialFeatures

OnnxSklearnBaggingClassifier

OnnxSklearnLabelEncoder

OnnxSklearnPowerTransformer

OnnxSklearnBaggingRegressor

OnnxSklearnLars

OnnxSklearnQuadraticDiscriminantAnalysis

OnnxSklearnBayesianGaussianMixture

OnnxSklearnLarsCV

OnnxSklearnQuantileRegressor

OnnxSklearnBayesianRidge

OnnxSklearnLasso

OnnxSklearnRANSACRegressor

OnnxSklearnBernoulliNB

OnnxSklearnLassoCV

OnnxSklearnRFE

OnnxSklearnBinarizer

OnnxSklearnLassoLars

OnnxSklearnRFECV

OnnxSklearnCalibratedClassifierCV

OnnxSklearnLassoLarsCV

OnnxSklearnRadiusNeighborsClassifier

OnnxSklearnCategoricalNB

OnnxSklearnLassoLarsIC

OnnxSklearnRadiusNeighborsRegressor

OnnxSklearnColumnTransformer

OnnxSklearnLinearDiscriminantAnalysis

OnnxSklearnRandomForestClassifier

OnnxSklearnComplementNB

OnnxSklearnLinearRegression

OnnxSklearnRandomForestRegressor

OnnxSklearnCountVectorizer

OnnxSklearnLinearSVC

OnnxSklearnRandomTreesEmbedding

OnnxSklearnDecisionTreeClassifier

OnnxSklearnLinearSVR

OnnxSklearnRidge

OnnxSklearnDecisionTreeRegressor

OnnxSklearnLocalOutlierFactor

OnnxSklearnRidgeCV

OnnxSklearnDictVectorizer

OnnxSklearnLogisticRegression

OnnxSklearnRidgeClassifier

OnnxSklearnElasticNet

OnnxSklearnLogisticRegressionCV

OnnxSklearnRidgeClassifierCV

OnnxSklearnElasticNetCV

OnnxSklearnMLPClassifier

OnnxSklearnRobustScaler

OnnxSklearnExtraTreeClassifier

OnnxSklearnMLPRegressor

OnnxSklearnSGDClassifier

OnnxSklearnExtraTreeRegressor

OnnxSklearnMaxAbsScaler

OnnxSklearnSGDOneClassSVM

OnnxSklearnExtraTreesClassifier

OnnxSklearnMinMaxScaler

OnnxSklearnSGDRegressor

OnnxSklearnExtraTreesRegressor

OnnxSklearnMiniBatchKMeans

OnnxSklearnSVC

OnnxSklearnFeatureHasher

OnnxSklearnMultiOutputClassifier

OnnxSklearnSVR

OnnxSklearnFeatureUnion

OnnxSklearnMultiOutputRegressor

OnnxSklearnSelectFdr

OnnxSklearnFunctionTransformer

OnnxSklearnMultiTaskElasticNet

OnnxSklearnSelectFpr

OnnxSklearnGammaRegressor

OnnxSklearnMultiTaskElasticNetCV

OnnxSklearnSelectFromModel

OnnxSklearnGaussianMixture

OnnxSklearnMultiTaskLasso

OnnxSklearnSelectFwe

OnnxSklearnGaussianNB

OnnxSklearnMultiTaskLassoCV

OnnxSklearnSelectKBest

OnnxSklearnGaussianProcessClassifier

OnnxSklearnMultinomialNB

OnnxSklearnSelectPercentile

OnnxSklearnGaussianProcessRegressor

OnnxSklearnNearestNeighbors

OnnxSklearnSimpleImputer

OnnxSklearnGaussianRandomProjection

OnnxSklearnNeighborhoodComponentsAnalysis

OnnxSklearnStackingClassifier

OnnxSklearnGenericUnivariateSelect

OnnxSklearnNormalizer

OnnxSklearnStackingRegressor

OnnxSklearnGradientBoostingClassifier

OnnxSklearnNuSVC

OnnxSklearnStandardScaler

OnnxSklearnGradientBoostingRegressor

OnnxSklearnNuSVR

OnnxSklearnTfidfTransformer

OnnxSklearnGridSearchCV

OnnxSklearnOneClassSVM

OnnxSklearnTfidfVectorizer

OnnxSklearnHistGradientBoostingClassifier

OnnxSklearnOneHotEncoder

OnnxSklearnTheilSenRegressor

OnnxSklearnHistGradientBoostingRegressor

OnnxSklearnOneVsOneClassifier

OnnxSklearnTruncatedSVD

OnnxSklearnHuberRegressor

OnnxSklearnOneVsRestClassifier

OnnxSklearnTweedieRegressor

OnnxSklearnIncrementalPCA

OnnxSklearnOrdinalEncoder

OnnxSklearnVarianceThreshold

OnnxSklearnIsolationForest

OnnxSklearnOrthogonalMatchingPursuit

OnnxSklearnVotingClassifier

OnnxSklearnKBinsDiscretizer

OnnxSklearnOrthogonalMatchingPursuitCV

OnnxSklearnVotingRegressor

OnnxSklearnKMeans

OnnxSklearnPCA

OnnxSklearn_ConstantPredictor

OnnxSklearnKNNImputer

OnnxSklearnPLSRegression

OnnxCastRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxCastRegressor(estimator, *, dtype=<class 'numpy.float32'>)#

OnnxOperatorMixin for CastRegressor

OnnxCastTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxCastTransformer(*, dtype=<class 'numpy.float32'>)#

OnnxOperatorMixin for CastTransformer

OnnxReplaceTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxReplaceTransformer(*, from_value=0, to_value=nan, dtype=<class 'numpy.float32'>)#

OnnxOperatorMixin for ReplaceTransformer

OnnxSklearnARDRegression#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnARDRegression(*, max_iter=None, tol=0.001, alpha_1=1e-06, alpha_2=1e-06, lambda_1=1e-06, lambda_2=1e-06, compute_score=False, threshold_lambda=10000.0, fit_intercept=True, copy_X=True, verbose=False, n_iter='deprecated')#

OnnxOperatorMixin for ARDRegression

OnnxSklearnAdaBoostClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnAdaBoostClassifier(estimator=None, *, n_estimators=50, learning_rate=1.0, algorithm='SAMME.R', random_state=None)#

OnnxOperatorMixin for AdaBoostClassifier

OnnxSklearnAdaBoostRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnAdaBoostRegressor(estimator=None, *, n_estimators=50, learning_rate=1.0, loss='linear', random_state=None)#

OnnxOperatorMixin for AdaBoostRegressor

OnnxSklearnBaggingClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnBaggingClassifier(estimator=None, n_estimators=10, *, max_samples=1.0, max_features=1.0, bootstrap=True, bootstrap_features=False, oob_score=False, warm_start=False, n_jobs=None, random_state=None, verbose=0)#

OnnxOperatorMixin for BaggingClassifier

OnnxSklearnBaggingRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnBaggingRegressor(estimator=None, n_estimators=10, *, max_samples=1.0, max_features=1.0, bootstrap=True, bootstrap_features=False, oob_score=False, warm_start=False, n_jobs=None, random_state=None, verbose=0)#

OnnxOperatorMixin for BaggingRegressor

OnnxSklearnBayesianGaussianMixture#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnBayesianGaussianMixture(*, n_components=1, covariance_type='full', tol=0.001, reg_covar=1e-06, max_iter=100, n_init=1, init_params='kmeans', weight_concentration_prior_type='dirichlet_process', weight_concentration_prior=None, mean_precision_prior=None, mean_prior=None, degrees_of_freedom_prior=None, covariance_prior=None, random_state=None, warm_start=False, verbose=0, verbose_interval=10)#

OnnxOperatorMixin for BayesianGaussianMixture

OnnxSklearnBayesianRidge#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnBayesianRidge(*, max_iter=None, tol=0.001, alpha_1=1e-06, alpha_2=1e-06, lambda_1=1e-06, lambda_2=1e-06, alpha_init=None, lambda_init=None, compute_score=False, fit_intercept=True, copy_X=True, verbose=False, n_iter='deprecated')#

OnnxOperatorMixin for BayesianRidge

OnnxSklearnBernoulliNB#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnBernoulliNB(*, alpha=1.0, force_alpha=True, binarize=0.0, fit_prior=True, class_prior=None)#

OnnxOperatorMixin for BernoulliNB

OnnxSklearnBinarizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnBinarizer(*, threshold=0.0, copy=True)#

OnnxOperatorMixin for Binarizer

OnnxSklearnCalibratedClassifierCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnCalibratedClassifierCV(estimator=None, *, method='sigmoid', cv=None, n_jobs=None, ensemble=True)#

OnnxOperatorMixin for CalibratedClassifierCV

OnnxSklearnCategoricalNB#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnCategoricalNB(*, alpha=1.0, force_alpha=True, fit_prior=True, class_prior=None, min_categories=None)#

OnnxOperatorMixin for CategoricalNB

OnnxSklearnColumnTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnColumnTransformer(transformers, *, remainder='drop', sparse_threshold=0.3, n_jobs=None, transformer_weights=None, verbose=False, verbose_feature_names_out=True)[source]#

OnnxOperatorMixin for ColumnTransformer

OnnxSklearnComplementNB#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnComplementNB(*, alpha=1.0, force_alpha=True, fit_prior=True, class_prior=None, norm=False)#

OnnxOperatorMixin for ComplementNB

OnnxSklearnCountVectorizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnCountVectorizer(*, input='content', encoding='utf-8', decode_error='strict', strip_accents=None, lowercase=True, preprocessor=None, tokenizer=None, stop_words=None, token_pattern='(?u)\\b\\w\\w+\\b', ngram_range=(1, 1), analyzer='word', max_df=1.0, min_df=1, max_features=None, vocabulary=None, binary=False, dtype=<class 'numpy.int64'>)#

OnnxOperatorMixin for CountVectorizer

OnnxSklearnDecisionTreeClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnDecisionTreeClassifier(*, criterion='gini', splitter='best', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, max_leaf_nodes=None, min_impurity_decrease=0.0, class_weight=None, ccp_alpha=0.0, monotonic_cst=None)#

OnnxOperatorMixin for DecisionTreeClassifier

OnnxSklearnDecisionTreeRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnDecisionTreeRegressor(*, criterion='squared_error', splitter='best', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, max_leaf_nodes=None, min_impurity_decrease=0.0, ccp_alpha=0.0, monotonic_cst=None)#

OnnxOperatorMixin for DecisionTreeRegressor

OnnxSklearnDictVectorizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnDictVectorizer(*, dtype=<class 'numpy.float64'>, separator='=', sparse=True, sort=True)#

OnnxOperatorMixin for DictVectorizer

OnnxSklearnElasticNet#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnElasticNet(alpha=1.0, *, l1_ratio=0.5, fit_intercept=True, precompute=False, max_iter=1000, copy_X=True, tol=0.0001, warm_start=False, positive=False, random_state=None, selection='cyclic')#

OnnxOperatorMixin for ElasticNet

OnnxSklearnElasticNetCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnElasticNetCV(*, l1_ratio=0.5, eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, precompute='auto', max_iter=1000, tol=0.0001, cv=None, copy_X=True, verbose=0, n_jobs=None, positive=False, random_state=None, selection='cyclic')#

OnnxOperatorMixin for ElasticNetCV

OnnxSklearnExtraTreeClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnExtraTreeClassifier(*, criterion='gini', splitter='random', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='sqrt', random_state=None, max_leaf_nodes=None, min_impurity_decrease=0.0, class_weight=None, ccp_alpha=0.0, monotonic_cst=None)#

OnnxOperatorMixin for ExtraTreeClassifier

OnnxSklearnExtraTreeRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnExtraTreeRegressor(*, criterion='squared_error', splitter='random', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=1.0, random_state=None, min_impurity_decrease=0.0, max_leaf_nodes=None, ccp_alpha=0.0, monotonic_cst=None)#

OnnxOperatorMixin for ExtraTreeRegressor

OnnxSklearnExtraTreesClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnExtraTreesClassifier(n_estimators=100, *, criterion='gini', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='sqrt', max_leaf_nodes=None, min_impurity_decrease=0.0, bootstrap=False, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None, ccp_alpha=0.0, max_samples=None, monotonic_cst=None)#

OnnxOperatorMixin for ExtraTreesClassifier

OnnxSklearnExtraTreesRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnExtraTreesRegressor(n_estimators=100, *, criterion='squared_error', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=1.0, max_leaf_nodes=None, min_impurity_decrease=0.0, bootstrap=False, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, ccp_alpha=0.0, max_samples=None, monotonic_cst=None)#

OnnxOperatorMixin for ExtraTreesRegressor

OnnxSklearnFeatureHasher#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnFeatureHasher(n_features=1048576, *, input_type='dict', dtype=<class 'numpy.float64'>, alternate_sign=True)#

OnnxOperatorMixin for FeatureHasher

OnnxSklearnFeatureUnion#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnFeatureUnion(transformer_list, *, n_jobs=None, transformer_weights=None, verbose=False)[source]#

OnnxOperatorMixin for FeatureUnion

OnnxSklearnFunctionTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnFunctionTransformer(func=None, inverse_func=None, *, validate=False, accept_sparse=False, check_inverse=True, feature_names_out=None, kw_args=None, inv_kw_args=None)#

OnnxOperatorMixin for FunctionTransformer

OnnxSklearnGammaRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGammaRegressor(*, alpha=1.0, fit_intercept=True, solver='lbfgs', max_iter=100, tol=0.0001, warm_start=False, verbose=0)#

OnnxOperatorMixin for GammaRegressor

OnnxSklearnGaussianMixture#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGaussianMixture(n_components=1, *, covariance_type='full', tol=0.001, reg_covar=1e-06, max_iter=100, n_init=1, init_params='kmeans', weights_init=None, means_init=None, precisions_init=None, random_state=None, warm_start=False, verbose=0, verbose_interval=10)#

OnnxOperatorMixin for GaussianMixture

OnnxSklearnGaussianNB#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGaussianNB(*, priors=None, var_smoothing=1e-09)#

OnnxOperatorMixin for GaussianNB

OnnxSklearnGaussianProcessClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGaussianProcessClassifier(kernel=None, *, optimizer='fmin_l_bfgs_b', n_restarts_optimizer=0, max_iter_predict=100, warm_start=False, copy_X_train=True, random_state=None, multi_class='one_vs_rest', n_jobs=None)#

OnnxOperatorMixin for GaussianProcessClassifier

OnnxSklearnGaussianProcessRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGaussianProcessRegressor(kernel=None, *, alpha=1e-10, optimizer='fmin_l_bfgs_b', n_restarts_optimizer=0, normalize_y=False, copy_X_train=True, n_targets=None, random_state=None)#

OnnxOperatorMixin for GaussianProcessRegressor

OnnxSklearnGaussianRandomProjection#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGaussianRandomProjection(n_components='auto', *, eps=0.1, compute_inverse_components=False, random_state=None)#

OnnxOperatorMixin for GaussianRandomProjection

OnnxSklearnGenericUnivariateSelect#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGenericUnivariateSelect(score_func=<function f_classif>, *, mode='percentile', param=1e-05)#

OnnxOperatorMixin for GenericUnivariateSelect

OnnxSklearnGradientBoostingClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGradientBoostingClassifier(*, loss='log_loss', learning_rate=0.1, n_estimators=100, subsample=1.0, criterion='friedman_mse', min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_depth=3, min_impurity_decrease=0.0, init=None, random_state=None, max_features=None, verbose=0, max_leaf_nodes=None, warm_start=False, validation_fraction=0.1, n_iter_no_change=None, tol=0.0001, ccp_alpha=0.0)#

OnnxOperatorMixin for GradientBoostingClassifier

OnnxSklearnGradientBoostingRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGradientBoostingRegressor(*, loss='squared_error', learning_rate=0.1, n_estimators=100, subsample=1.0, criterion='friedman_mse', min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_depth=3, min_impurity_decrease=0.0, init=None, random_state=None, max_features=None, alpha=0.9, verbose=0, max_leaf_nodes=None, warm_start=False, validation_fraction=0.1, n_iter_no_change=None, tol=0.0001, ccp_alpha=0.0)#

OnnxOperatorMixin for GradientBoostingRegressor

OnnxSklearnGridSearchCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnGridSearchCV(estimator, param_grid, *, scoring=None, n_jobs=None, refit=True, cv=None, verbose=0, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False)#

OnnxOperatorMixin for GridSearchCV

OnnxSklearnHistGradientBoostingClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnHistGradientBoostingClassifier(loss='log_loss', *, learning_rate=0.1, max_iter=100, max_leaf_nodes=31, max_depth=None, min_samples_leaf=20, l2_regularization=0.0, max_features=1.0, max_bins=255, categorical_features='warn', monotonic_cst=None, interaction_cst=None, warm_start=False, early_stopping='auto', scoring='loss', validation_fraction=0.1, n_iter_no_change=10, tol=1e-07, verbose=0, random_state=None, class_weight=None)#

OnnxOperatorMixin for HistGradientBoostingClassifier

OnnxSklearnHistGradientBoostingRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnHistGradientBoostingRegressor(loss='squared_error', *, quantile=None, learning_rate=0.1, max_iter=100, max_leaf_nodes=31, max_depth=None, min_samples_leaf=20, l2_regularization=0.0, max_features=1.0, max_bins=255, categorical_features='warn', monotonic_cst=None, interaction_cst=None, warm_start=False, early_stopping='auto', scoring='loss', validation_fraction=0.1, n_iter_no_change=10, tol=1e-07, verbose=0, random_state=None)#

OnnxOperatorMixin for HistGradientBoostingRegressor

OnnxSklearnHuberRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnHuberRegressor(*, epsilon=1.35, max_iter=100, alpha=0.0001, warm_start=False, fit_intercept=True, tol=1e-05)#

OnnxOperatorMixin for HuberRegressor

OnnxSklearnIncrementalPCA#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnIncrementalPCA(n_components=None, *, whiten=False, copy=True, batch_size=None)#

OnnxOperatorMixin for IncrementalPCA

OnnxSklearnIsolationForest#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnIsolationForest(*, n_estimators=100, max_samples='auto', contamination='auto', max_features=1.0, bootstrap=False, n_jobs=None, random_state=None, verbose=0, warm_start=False)#

OnnxOperatorMixin for IsolationForest

OnnxSklearnKBinsDiscretizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKBinsDiscretizer(n_bins=5, *, encode='onehot', strategy='quantile', dtype=None, subsample='warn', random_state=None)#

OnnxOperatorMixin for KBinsDiscretizer

OnnxSklearnKMeans#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKMeans(n_clusters=8, *, init='k-means++', n_init='auto', max_iter=300, tol=0.0001, verbose=0, random_state=None, copy_x=True, algorithm='lloyd')#

OnnxOperatorMixin for KMeans

OnnxSklearnKNNImputer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKNNImputer(*, missing_values=nan, n_neighbors=5, weights='uniform', metric='nan_euclidean', copy=True, add_indicator=False, keep_empty_features=False)#

OnnxOperatorMixin for KNNImputer

OnnxSklearnKNeighborsClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKNeighborsClassifier(n_neighbors=5, *, weights='uniform', algorithm='auto', leaf_size=30, p=2, metric='minkowski', metric_params=None, n_jobs=None)#

OnnxOperatorMixin for KNeighborsClassifier

OnnxSklearnKNeighborsRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKNeighborsRegressor(n_neighbors=5, *, weights='uniform', algorithm='auto', leaf_size=30, p=2, metric='minkowski', metric_params=None, n_jobs=None)#

OnnxOperatorMixin for KNeighborsRegressor

OnnxSklearnKNeighborsTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKNeighborsTransformer(*, mode='distance', n_neighbors=5, algorithm='auto', leaf_size=30, metric='minkowski', p=2, metric_params=None, n_jobs=None)#

OnnxOperatorMixin for KNeighborsTransformer

OnnxSklearnKernelCenterer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKernelCenterer#

OnnxOperatorMixin for KernelCenterer

OnnxSklearnKernelPCA#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnKernelPCA(n_components=None, *, kernel='linear', gamma=None, degree=3, coef0=1, kernel_params=None, alpha=1.0, fit_inverse_transform=False, eigen_solver='auto', tol=0, max_iter=None, iterated_power='auto', remove_zero_eig=False, random_state=None, copy_X=True, n_jobs=None)#

OnnxOperatorMixin for KernelPCA

OnnxSklearnLabelBinarizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLabelBinarizer(*, neg_label=0, pos_label=1, sparse_output=False)#

OnnxOperatorMixin for LabelBinarizer

OnnxSklearnLabelEncoder#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLabelEncoder#

OnnxOperatorMixin for LabelEncoder

OnnxSklearnLars#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLars(*, fit_intercept=True, verbose=False, precompute='auto', n_nonzero_coefs=500, eps=2.220446049250313e-16, copy_X=True, fit_path=True, jitter=None, random_state=None)#

OnnxOperatorMixin for Lars

OnnxSklearnLarsCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLarsCV(*, fit_intercept=True, verbose=False, max_iter=500, precompute='auto', cv=None, max_n_alphas=1000, n_jobs=None, eps=2.220446049250313e-16, copy_X=True)#

OnnxOperatorMixin for LarsCV

OnnxSklearnLasso#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLasso(alpha=1.0, *, fit_intercept=True, precompute=False, copy_X=True, max_iter=1000, tol=0.0001, warm_start=False, positive=False, random_state=None, selection='cyclic')#

OnnxOperatorMixin for Lasso

OnnxSklearnLassoCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLassoCV(*, eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, precompute='auto', max_iter=1000, tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=None, positive=False, random_state=None, selection='cyclic')#

OnnxOperatorMixin for LassoCV

OnnxSklearnLassoLars#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLassoLars(alpha=1.0, *, fit_intercept=True, verbose=False, precompute='auto', max_iter=500, eps=2.220446049250313e-16, copy_X=True, fit_path=True, positive=False, jitter=None, random_state=None)#

OnnxOperatorMixin for LassoLars

OnnxSklearnLassoLarsCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLassoLarsCV(*, fit_intercept=True, verbose=False, max_iter=500, precompute='auto', cv=None, max_n_alphas=1000, n_jobs=None, eps=2.220446049250313e-16, copy_X=True, positive=False)#

OnnxOperatorMixin for LassoLarsCV

OnnxSklearnLassoLarsIC#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLassoLarsIC(criterion='aic', *, fit_intercept=True, verbose=False, precompute='auto', max_iter=500, eps=2.220446049250313e-16, copy_X=True, positive=False, noise_variance=None)#

OnnxOperatorMixin for LassoLarsIC

OnnxSklearnLinearDiscriminantAnalysis#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLinearDiscriminantAnalysis(solver='svd', shrinkage=None, priors=None, n_components=None, store_covariance=False, tol=0.0001, covariance_estimator=None)#

OnnxOperatorMixin for LinearDiscriminantAnalysis

OnnxSklearnLinearRegression#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLinearRegression(*, fit_intercept=True, copy_X=True, n_jobs=None, positive=False)#

OnnxOperatorMixin for LinearRegression

OnnxSklearnLinearSVC#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLinearSVC(penalty='l2', loss='squared_hinge', *, dual='warn', tol=0.0001, C=1.0, multi_class='ovr', fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None, max_iter=1000)#

OnnxOperatorMixin for LinearSVC

OnnxSklearnLinearSVR#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLinearSVR(*, epsilon=0.0, tol=0.0001, C=1.0, loss='epsilon_insensitive', fit_intercept=True, intercept_scaling=1.0, dual='warn', verbose=0, random_state=None, max_iter=1000)#

OnnxOperatorMixin for LinearSVR

OnnxSklearnLocalOutlierFactor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLocalOutlierFactor(n_neighbors=20, *, algorithm='auto', leaf_size=30, metric='minkowski', p=2, metric_params=None, contamination='auto', novelty=False, n_jobs=None)#

OnnxOperatorMixin for LocalOutlierFactor

OnnxSklearnLogisticRegression#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLogisticRegression(penalty='l2', *, dual=False, tol=0.0001, C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, random_state=None, solver='lbfgs', max_iter=100, multi_class='auto', verbose=0, warm_start=False, n_jobs=None, l1_ratio=None)#

OnnxOperatorMixin for LogisticRegression

OnnxSklearnLogisticRegressionCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnLogisticRegressionCV(*, Cs=10, fit_intercept=True, cv=None, dual=False, penalty='l2', scoring=None, solver='lbfgs', tol=0.0001, max_iter=100, class_weight=None, n_jobs=None, verbose=0, refit=True, intercept_scaling=1.0, multi_class='auto', random_state=None, l1_ratios=None)#

OnnxOperatorMixin for LogisticRegressionCV

OnnxSklearnMLPClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMLPClassifier(hidden_layer_sizes=(100,), activation='relu', *, solver='adam', alpha=0.0001, batch_size='auto', learning_rate='constant', learning_rate_init=0.001, power_t=0.5, max_iter=200, shuffle=True, random_state=None, tol=0.0001, verbose=False, warm_start=False, momentum=0.9, nesterovs_momentum=True, early_stopping=False, validation_fraction=0.1, beta_1=0.9, beta_2=0.999, epsilon=1e-08, n_iter_no_change=10, max_fun=15000)#

OnnxOperatorMixin for MLPClassifier

OnnxSklearnMLPRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMLPRegressor(hidden_layer_sizes=(100,), activation='relu', *, solver='adam', alpha=0.0001, batch_size='auto', learning_rate='constant', learning_rate_init=0.001, power_t=0.5, max_iter=200, shuffle=True, random_state=None, tol=0.0001, verbose=False, warm_start=False, momentum=0.9, nesterovs_momentum=True, early_stopping=False, validation_fraction=0.1, beta_1=0.9, beta_2=0.999, epsilon=1e-08, n_iter_no_change=10, max_fun=15000)#

OnnxOperatorMixin for MLPRegressor

OnnxSklearnMaxAbsScaler#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMaxAbsScaler(*, copy=True)#

OnnxOperatorMixin for MaxAbsScaler

OnnxSklearnMinMaxScaler#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMinMaxScaler(feature_range=(0, 1), *, copy=True, clip=False)#

OnnxOperatorMixin for MinMaxScaler

OnnxSklearnMiniBatchKMeans#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMiniBatchKMeans(n_clusters=8, *, init='k-means++', max_iter=100, batch_size=1024, verbose=0, compute_labels=True, random_state=None, tol=0.0, max_no_improvement=10, init_size=None, n_init='auto', reassignment_ratio=0.01)#

OnnxOperatorMixin for MiniBatchKMeans

OnnxSklearnMultiOutputClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultiOutputClassifier(estimator, *, n_jobs=None)#

OnnxOperatorMixin for MultiOutputClassifier

OnnxSklearnMultiOutputRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultiOutputRegressor(estimator, *, n_jobs=None)#

OnnxOperatorMixin for MultiOutputRegressor

OnnxSklearnMultiTaskElasticNet#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultiTaskElasticNet(alpha=1.0, *, l1_ratio=0.5, fit_intercept=True, copy_X=True, max_iter=1000, tol=0.0001, warm_start=False, random_state=None, selection='cyclic')#

OnnxOperatorMixin for MultiTaskElasticNet

OnnxSklearnMultiTaskElasticNetCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultiTaskElasticNetCV(*, l1_ratio=0.5, eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, max_iter=1000, tol=0.0001, cv=None, copy_X=True, verbose=0, n_jobs=None, random_state=None, selection='cyclic')#

OnnxOperatorMixin for MultiTaskElasticNetCV

OnnxSklearnMultiTaskLasso#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultiTaskLasso(alpha=1.0, *, fit_intercept=True, copy_X=True, max_iter=1000, tol=0.0001, warm_start=False, random_state=None, selection='cyclic')#

OnnxOperatorMixin for MultiTaskLasso

OnnxSklearnMultiTaskLassoCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultiTaskLassoCV(*, eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, max_iter=1000, tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=None, random_state=None, selection='cyclic')#

OnnxOperatorMixin for MultiTaskLassoCV

OnnxSklearnMultinomialNB#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnMultinomialNB(*, alpha=1.0, force_alpha=True, fit_prior=True, class_prior=None)#

OnnxOperatorMixin for MultinomialNB

OnnxSklearnNearestNeighbors#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnNearestNeighbors(*, n_neighbors=5, radius=1.0, algorithm='auto', leaf_size=30, metric='minkowski', p=2, metric_params=None, n_jobs=None)#

OnnxOperatorMixin for NearestNeighbors

OnnxSklearnNeighborhoodComponentsAnalysis#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnNeighborhoodComponentsAnalysis(n_components=None, *, init='auto', warm_start=False, max_iter=50, tol=1e-05, callback=None, verbose=0, random_state=None)#

OnnxOperatorMixin for NeighborhoodComponentsAnalysis

OnnxSklearnNormalizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnNormalizer(norm='l2', *, copy=True)#

OnnxOperatorMixin for Normalizer

OnnxSklearnNuSVC#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnNuSVC(*, nu=0.5, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape='ovr', break_ties=False, random_state=None)#

OnnxOperatorMixin for NuSVC

OnnxSklearnNuSVR#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnNuSVR(*, nu=0.5, C=1.0, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True, tol=0.001, cache_size=200, verbose=False, max_iter=-1)#

OnnxOperatorMixin for NuSVR

OnnxSklearnOneClassSVM#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOneClassSVM(*, kernel='rbf', degree=3, gamma='scale', coef0=0.0, tol=0.001, nu=0.5, shrinking=True, cache_size=200, verbose=False, max_iter=-1)#

OnnxOperatorMixin for OneClassSVM

OnnxSklearnOneHotEncoder#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOneHotEncoder(*, categories='auto', drop=None, sparse_output=True, dtype=<class 'numpy.float64'>, handle_unknown='error', min_frequency=None, max_categories=None, feature_name_combiner='concat')#

OnnxOperatorMixin for OneHotEncoder

OnnxSklearnOneVsOneClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOneVsOneClassifier(estimator, *, n_jobs=None)#

OnnxOperatorMixin for OneVsOneClassifier

OnnxSklearnOneVsRestClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOneVsRestClassifier(estimator, *, n_jobs=None, verbose=0)#

OnnxOperatorMixin for OneVsRestClassifier

OnnxSklearnOrdinalEncoder#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOrdinalEncoder(*, categories='auto', dtype=<class 'numpy.float64'>, handle_unknown='error', unknown_value=None, encoded_missing_value=nan, min_frequency=None, max_categories=None)#

OnnxOperatorMixin for OrdinalEncoder

OnnxSklearnOrthogonalMatchingPursuit#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOrthogonalMatchingPursuit(*, n_nonzero_coefs=None, tol=None, fit_intercept=True, precompute='auto')#

OnnxOperatorMixin for OrthogonalMatchingPursuit

OnnxSklearnOrthogonalMatchingPursuitCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnOrthogonalMatchingPursuitCV(*, copy=True, fit_intercept=True, max_iter=None, cv=None, n_jobs=None, verbose=False)#

OnnxOperatorMixin for OrthogonalMatchingPursuitCV

OnnxSklearnPCA#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPCA(n_components=None, *, copy=True, whiten=False, svd_solver='auto', tol=0.0, iterated_power='auto', n_oversamples=10, power_iteration_normalizer='auto', random_state=None)#

OnnxOperatorMixin for PCA

OnnxSklearnPLSRegression#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPLSRegression(n_components=2, *, scale=True, max_iter=500, tol=1e-06, copy=True)#

OnnxOperatorMixin for PLSRegression

OnnxSklearnPassiveAggressiveClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPassiveAggressiveClassifier(*, C=1.0, fit_intercept=True, max_iter=1000, tol=0.001, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, shuffle=True, verbose=0, loss='hinge', n_jobs=None, random_state=None, warm_start=False, class_weight=None, average=False)#

OnnxOperatorMixin for PassiveAggressiveClassifier

OnnxSklearnPassiveAggressiveRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPassiveAggressiveRegressor(*, C=1.0, fit_intercept=True, max_iter=1000, tol=0.001, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, shuffle=True, verbose=0, loss='epsilon_insensitive', epsilon=0.1, random_state=None, warm_start=False, average=False)#

OnnxOperatorMixin for PassiveAggressiveRegressor

OnnxSklearnPerceptron#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPerceptron(*, penalty=None, alpha=0.0001, l1_ratio=0.15, fit_intercept=True, max_iter=1000, tol=0.001, shuffle=True, verbose=0, eta0=1.0, n_jobs=None, random_state=0, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, class_weight=None, warm_start=False)#

OnnxOperatorMixin for Perceptron

OnnxSklearnPipeline#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPipeline(steps, *, memory=None, verbose=False)[source]#

OnnxOperatorMixin for Pipeline

OnnxSklearnPoissonRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPoissonRegressor(*, alpha=1.0, fit_intercept=True, solver='lbfgs', max_iter=100, tol=0.0001, warm_start=False, verbose=0)#

OnnxOperatorMixin for PoissonRegressor

OnnxSklearnPolynomialFeatures#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPolynomialFeatures(degree=2, *, interaction_only=False, include_bias=True, order='C')#

OnnxOperatorMixin for PolynomialFeatures

OnnxSklearnPowerTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPowerTransformer(method='yeo-johnson', *, standardize=True, copy=True)#

OnnxOperatorMixin for PowerTransformer

OnnxSklearnQuadraticDiscriminantAnalysis#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnQuadraticDiscriminantAnalysis(*, priors=None, reg_param=0.0, store_covariance=False, tol=0.0001)#

OnnxOperatorMixin for QuadraticDiscriminantAnalysis

OnnxSklearnQuantileRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnQuantileRegressor(*, quantile=0.5, alpha=1.0, fit_intercept=True, solver='highs', solver_options=None)#

OnnxOperatorMixin for QuantileRegressor

OnnxSklearnRANSACRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRANSACRegressor(estimator=None, *, min_samples=None, residual_threshold=None, is_data_valid=None, is_model_valid=None, max_trials=100, max_skips=inf, stop_n_inliers=inf, stop_score=inf, stop_probability=0.99, loss='absolute_error', random_state=None)#

OnnxOperatorMixin for RANSACRegressor

OnnxSklearnRFE#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRFE(estimator, *, n_features_to_select=None, step=1, verbose=0, importance_getter='auto')#

OnnxOperatorMixin for RFE

OnnxSklearnRFECV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRFECV(estimator, *, step=1, min_features_to_select=1, cv=None, scoring=None, verbose=0, n_jobs=None, importance_getter='auto')#

OnnxOperatorMixin for RFECV

OnnxSklearnRadiusNeighborsClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRadiusNeighborsClassifier(radius=1.0, *, weights='uniform', algorithm='auto', leaf_size=30, p=2, metric='minkowski', outlier_label=None, metric_params=None, n_jobs=None)#

OnnxOperatorMixin for RadiusNeighborsClassifier

OnnxSklearnRadiusNeighborsRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRadiusNeighborsRegressor(radius=1.0, *, weights='uniform', algorithm='auto', leaf_size=30, p=2, metric='minkowski', metric_params=None, n_jobs=None)#

OnnxOperatorMixin for RadiusNeighborsRegressor

OnnxSklearnRandomForestClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRandomForestClassifier(n_estimators=100, *, criterion='gini', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='sqrt', max_leaf_nodes=None, min_impurity_decrease=0.0, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None, ccp_alpha=0.0, max_samples=None, monotonic_cst=None)#

OnnxOperatorMixin for RandomForestClassifier

OnnxSklearnRandomForestRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRandomForestRegressor(n_estimators=100, *, criterion='squared_error', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=1.0, max_leaf_nodes=None, min_impurity_decrease=0.0, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, ccp_alpha=0.0, max_samples=None, monotonic_cst=None)#

OnnxOperatorMixin for RandomForestRegressor

OnnxSklearnRandomTreesEmbedding#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRandomTreesEmbedding(n_estimators=100, *, max_depth=5, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_leaf_nodes=None, min_impurity_decrease=0.0, sparse_output=True, n_jobs=None, random_state=None, verbose=0, warm_start=False)#

OnnxOperatorMixin for RandomTreesEmbedding

OnnxSklearnRidge#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRidge(alpha=1.0, *, fit_intercept=True, copy_X=True, max_iter=None, tol=0.0001, solver='auto', positive=False, random_state=None)#

OnnxOperatorMixin for Ridge

OnnxSklearnRidgeCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRidgeCV(alphas=(0.1, 1.0, 10.0), *, fit_intercept=True, scoring=None, cv=None, gcv_mode=None, store_cv_values=False, alpha_per_target=False)#

OnnxOperatorMixin for RidgeCV

OnnxSklearnRidgeClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRidgeClassifier(alpha=1.0, *, fit_intercept=True, copy_X=True, max_iter=None, tol=0.0001, class_weight=None, solver='auto', positive=False, random_state=None)#

OnnxOperatorMixin for RidgeClassifier

OnnxSklearnRidgeClassifierCV#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRidgeClassifierCV(alphas=(0.1, 1.0, 10.0), *, fit_intercept=True, scoring=None, cv=None, class_weight=None, store_cv_values=False)#

OnnxOperatorMixin for RidgeClassifierCV

OnnxSklearnRobustScaler#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnRobustScaler(*, with_centering=True, with_scaling=True, quantile_range=(25.0, 75.0), copy=True, unit_variance=False)#

OnnxOperatorMixin for RobustScaler

OnnxSklearnSGDClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSGDClassifier(loss='hinge', *, penalty='l2', alpha=0.0001, l1_ratio=0.15, fit_intercept=True, max_iter=1000, tol=0.001, shuffle=True, verbose=0, epsilon=0.1, n_jobs=None, random_state=None, learning_rate='optimal', eta0=0.0, power_t=0.5, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, class_weight=None, warm_start=False, average=False)#

OnnxOperatorMixin for SGDClassifier

OnnxSklearnSGDOneClassSVM#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSGDOneClassSVM(nu=0.5, fit_intercept=True, max_iter=1000, tol=0.001, shuffle=True, verbose=0, random_state=None, learning_rate='optimal', eta0=0.0, power_t=0.5, warm_start=False, average=False)#

OnnxOperatorMixin for SGDOneClassSVM

OnnxSklearnSGDRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSGDRegressor(loss='squared_error', *, penalty='l2', alpha=0.0001, l1_ratio=0.15, fit_intercept=True, max_iter=1000, tol=0.001, shuffle=True, verbose=0, epsilon=0.1, random_state=None, learning_rate='invscaling', eta0=0.01, power_t=0.25, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, warm_start=False, average=False)#

OnnxOperatorMixin for SGDRegressor

OnnxSklearnSVC#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSVC(*, C=1.0, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape='ovr', break_ties=False, random_state=None)#

OnnxOperatorMixin for SVC

OnnxSklearnSVR#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSVR(*, kernel='rbf', degree=3, gamma='scale', coef0=0.0, tol=0.001, C=1.0, epsilon=0.1, shrinking=True, cache_size=200, verbose=False, max_iter=-1)#

OnnxOperatorMixin for SVR

OnnxSklearnSelectFdr#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSelectFdr(score_func=<function f_classif>, *, alpha=0.05)#

OnnxOperatorMixin for SelectFdr

OnnxSklearnSelectFpr#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSelectFpr(score_func=<function f_classif>, *, alpha=0.05)#

OnnxOperatorMixin for SelectFpr

OnnxSklearnSelectFromModel#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSelectFromModel(estimator, *, threshold=None, prefit=False, norm_order=1, max_features=None, importance_getter='auto')#

OnnxOperatorMixin for SelectFromModel

OnnxSklearnSelectFwe#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSelectFwe(score_func=<function f_classif>, *, alpha=0.05)#

OnnxOperatorMixin for SelectFwe

OnnxSklearnSelectKBest#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSelectKBest(score_func=<function f_classif>, *, k=10)#

OnnxOperatorMixin for SelectKBest

OnnxSklearnSelectPercentile#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSelectPercentile(score_func=<function f_classif>, *, percentile=10)#

OnnxOperatorMixin for SelectPercentile

OnnxSklearnSimpleImputer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnSimpleImputer(*, missing_values=nan, strategy='mean', fill_value=None, copy=True, add_indicator=False, keep_empty_features=False)#

OnnxOperatorMixin for SimpleImputer

OnnxSklearnStackingClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnStackingClassifier(estimators, final_estimator=None, *, cv=None, stack_method='auto', n_jobs=None, passthrough=False, verbose=0)#

OnnxOperatorMixin for StackingClassifier

OnnxSklearnStackingRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnStackingRegressor(estimators, final_estimator=None, *, cv=None, n_jobs=None, passthrough=False, verbose=0)#

OnnxOperatorMixin for StackingRegressor

OnnxSklearnStandardScaler#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnStandardScaler(*, copy=True, with_mean=True, with_std=True)#

OnnxOperatorMixin for StandardScaler

OnnxSklearnTfidfTransformer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnTfidfTransformer(*, norm='l2', use_idf=True, smooth_idf=True, sublinear_tf=False)#

OnnxOperatorMixin for TfidfTransformer

OnnxSklearnTfidfVectorizer#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnTfidfVectorizer(*, input='content', encoding='utf-8', decode_error='strict', strip_accents=None, lowercase=True, preprocessor=None, tokenizer=None, analyzer='word', stop_words=None, token_pattern='(?u)\\b\\w\\w+\\b', ngram_range=(1, 1), max_df=1.0, min_df=1, max_features=None, vocabulary=None, binary=False, dtype=<class 'numpy.float64'>, norm='l2', use_idf=True, smooth_idf=True, sublinear_tf=False)#

OnnxOperatorMixin for TfidfVectorizer

OnnxSklearnTheilSenRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnTheilSenRegressor(*, fit_intercept=True, copy_X=True, max_subpopulation=10000.0, n_subsamples=None, max_iter=300, tol=0.001, random_state=None, n_jobs=None, verbose=False)#

OnnxOperatorMixin for TheilSenRegressor

OnnxSklearnTruncatedSVD#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnTruncatedSVD(n_components=2, *, algorithm='randomized', n_iter=5, n_oversamples=10, power_iteration_normalizer='auto', random_state=None, tol=0.0)#

OnnxOperatorMixin for TruncatedSVD

OnnxSklearnTweedieRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnTweedieRegressor(*, power=0.0, alpha=1.0, fit_intercept=True, link='auto', solver='lbfgs', max_iter=100, tol=0.0001, warm_start=False, verbose=0)#

OnnxOperatorMixin for TweedieRegressor

OnnxSklearnVarianceThreshold#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnVarianceThreshold(threshold=0.0)#

OnnxOperatorMixin for VarianceThreshold

OnnxSklearnVotingClassifier#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnVotingClassifier(estimators, *, voting='hard', weights=None, n_jobs=None, flatten_transform=True, verbose=False)#

OnnxOperatorMixin for VotingClassifier

OnnxSklearnVotingRegressor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnVotingRegressor(estimators, *, weights=None, n_jobs=None, verbose=False)#

OnnxOperatorMixin for VotingRegressor

OnnxSklearn_ConstantPredictor#

class skl2onnx.algebra.sklearn_ops.OnnxSklearn_ConstantPredictor#

OnnxOperatorMixin for _ConstantPredictor

Pipeline#

class skl2onnx.algebra.sklearn_ops.OnnxSklearnPipeline(steps, *, memory=None, verbose=False)[source]#

OnnxOperatorMixin for Pipeline

onnx_converter()#

Returns a converter for this model. If not overloaded, it fetches the converter mapped to the first scikit-learn parent it can find.

onnx_parser()#

Returns a parser for this model. If not overloaded, it calls the converter to guess the number of outputs. If it still fails, it fetches the parser mapped to the first scikit-learn parent it can find.

onnx_shape_calculator()#

Returns a shape calculator for this model. If not overloaded, it fetches the parser mapped to the first scikit-learn parent it can find.

to_onnx(X=None, name=None, options=None, white_op=None, black_op=None, final_types=None, target_opset=None, verbose=0)#

Converts the model in ONNX format. It calls method _to_onnx which must be overloaded.

Parameters:
  • X – training data, at least one sample, it is used to guess the type of the input data.

  • name – name of the model, if None, it is replaced by the the class name.

  • options – specific options given to converters (see Converters with options)

  • white_op – white list of ONNX nodes allowed while converting a pipeline, if empty, all are allowed

  • black_op – black list of ONNX nodes allowed while converting a pipeline, if empty, none are blacklisted

  • final_types – a python list. Works the same way as initial_types but not mandatory, it is used to overwrites the type (if type is not None) and the name of every output.

  • target_opset – to overwrite self.op_version

  • verbose – displays information while converting

to_onnx_operator(inputs=None, outputs=None, target_opset=None, options=None)#

This function must be overloaded.

class skl2onnx.algebra.sklearn_ops.OnnxSklearnColumnTransformer(transformers, *, remainder='drop', sparse_threshold=0.3, n_jobs=None, transformer_weights=None, verbose=False, verbose_feature_names_out=True)[source]#

OnnxOperatorMixin for ColumnTransformer

onnx_converter()#

Returns a converter for this model. If not overloaded, it fetches the converter mapped to the first scikit-learn parent it can find.

onnx_parser()#

Returns a parser for this model. If not overloaded, it calls the converter to guess the number of outputs. If it still fails, it fetches the parser mapped to the first scikit-learn parent it can find.

onnx_shape_calculator()#

Returns a shape calculator for this model. If not overloaded, it fetches the parser mapped to the first scikit-learn parent it can find.

to_onnx(X=None, name=None, options=None, white_op=None, black_op=None, final_types=None, target_opset=None, verbose=0)#

Converts the model in ONNX format. It calls method _to_onnx which must be overloaded.

Parameters:
  • X – training data, at least one sample, it is used to guess the type of the input data.

  • name – name of the model, if None, it is replaced by the the class name.

  • options – specific options given to converters (see Converters with options)

  • white_op – white list of ONNX nodes allowed while converting a pipeline, if empty, all are allowed

  • black_op – black list of ONNX nodes allowed while converting a pipeline, if empty, none are blacklisted

  • final_types – a python list. Works the same way as initial_types but not mandatory, it is used to overwrites the type (if type is not None) and the name of every output.

  • target_opset – to overwrite self.op_version

  • verbose – displays information while converting

to_onnx_operator(inputs=None, outputs=None, target_opset=None, options=None)#

This function must be overloaded.

class skl2onnx.algebra.sklearn_ops.OnnxSklearnFeatureUnion(transformer_list, *, n_jobs=None, transformer_weights=None, verbose=False)[source]#

OnnxOperatorMixin for FeatureUnion

onnx_converter()#

Returns a converter for this model. If not overloaded, it fetches the converter mapped to the first scikit-learn parent it can find.

onnx_parser()#

Returns a parser for this model. If not overloaded, it calls the converter to guess the number of outputs. If it still fails, it fetches the parser mapped to the first scikit-learn parent it can find.

onnx_shape_calculator()#

Returns a shape calculator for this model. If not overloaded, it fetches the parser mapped to the first scikit-learn parent it can find.

to_onnx(X=None, name=None, options=None, white_op=None, black_op=None, final_types=None, target_opset=None, verbose=0)#

Converts the model in ONNX format. It calls method _to_onnx which must be overloaded.

Parameters:
  • X – training data, at least one sample, it is used to guess the type of the input data.

  • name – name of the model, if None, it is replaced by the the class name.

  • options – specific options given to converters (see Converters with options)

  • white_op – white list of ONNX nodes allowed while converting a pipeline, if empty, all are allowed

  • black_op – black list of ONNX nodes allowed while converting a pipeline, if empty, none are blacklisted

  • final_types – a python list. Works the same way as initial_types but not mandatory, it is used to overwrites the type (if type is not None) and the name of every output.

  • target_opset – to overwrite self.op_version

  • verbose – displays information while converting

to_onnx_operator(inputs=None, outputs=None, target_opset=None, options=None)#

This function must be overloaded.

Available ONNX operators#

skl2onnx maps every ONNX operators into a class easy to insert into a graph. These operators get dynamically added and the list depends on the installed ONNX package. The documentation for these operators can be found on github: ONNX Operators.md and ONNX-ML Operators. Associated to onnxruntime, the mapping makes it easier to easily check the output of the ONNX operators on any data as shown in example Play with ONNX operators.

OnnxAbs

OnnxGreaterOrEqual_16

OnnxReduceL2_13

OnnxAbs_1

OnnxGreater_1

OnnxReduceL2_18

OnnxAbs_13

OnnxGreater_13

OnnxReduceLogSum

OnnxAbs_6

OnnxGreater_7

OnnxReduceLogSumExp

OnnxAcos

OnnxGreater_9

OnnxReduceLogSumExp_1

OnnxAcos_7

OnnxGridSample

OnnxReduceLogSumExp_11

OnnxAcosh

OnnxGridSample_16

OnnxReduceLogSumExp_13

OnnxAcosh_9

OnnxGridSample_20

OnnxReduceLogSumExp_18

OnnxAdagrad

OnnxGroupNormalization

OnnxReduceLogSum_1

OnnxAdagrad_1

OnnxGroupNormalization_18

OnnxReduceLogSum_11

OnnxAdam

OnnxHammingWindow

OnnxReduceLogSum_13

OnnxAdam_1

OnnxHammingWindow_17

OnnxReduceLogSum_18

OnnxAdd

OnnxHannWindow

OnnxReduceMax

OnnxAdd_1

OnnxHannWindow_17

OnnxReduceMax_1

OnnxAdd_13

OnnxHardSigmoid

OnnxReduceMax_11

OnnxAdd_14

OnnxHardSigmoid_1

OnnxReduceMax_12

OnnxAdd_6

OnnxHardSigmoid_6

OnnxReduceMax_13

OnnxAdd_7

OnnxHardSwish

OnnxReduceMax_18

OnnxAffineGrid

OnnxHardSwish_14

OnnxReduceMax_20

OnnxAffineGrid_20

OnnxHardmax

OnnxReduceMean

OnnxAnd

OnnxHardmax_1

OnnxReduceMean_1

OnnxAnd_1

OnnxHardmax_11

OnnxReduceMean_11

OnnxAnd_7

OnnxHardmax_13

OnnxReduceMean_13

OnnxArgMax

OnnxIdentity

OnnxReduceMean_18

OnnxArgMax_1

OnnxIdentity_1

OnnxReduceMin

OnnxArgMax_11

OnnxIdentity_13

OnnxReduceMin_1

OnnxArgMax_12

OnnxIdentity_14

OnnxReduceMin_11

OnnxArgMax_13

OnnxIdentity_16

OnnxReduceMin_12

OnnxArgMin

OnnxIdentity_19

OnnxReduceMin_13

OnnxArgMin_1

OnnxIdentity_21

OnnxReduceMin_18

OnnxArgMin_11

OnnxIf

OnnxReduceMin_20

OnnxArgMin_12

OnnxIf_1

OnnxReduceProd

OnnxArgMin_13

OnnxIf_11

OnnxReduceProd_1

OnnxArrayFeatureExtractor

OnnxIf_13

OnnxReduceProd_11

OnnxArrayFeatureExtractor_1

OnnxIf_16

OnnxReduceProd_13

OnnxAsin

OnnxIf_19

OnnxReduceProd_18

OnnxAsin_7

OnnxIf_21

OnnxReduceSum

OnnxAsinh

OnnxImageDecoder

OnnxReduceSumSquare

OnnxAsinh_9

OnnxImageDecoder_20

OnnxReduceSumSquare_1

OnnxAtan

OnnxImputer

OnnxReduceSumSquare_11

OnnxAtan_7

OnnxImputer_1

OnnxReduceSumSquare_13

OnnxAtanh

OnnxInstanceNormalization

OnnxReduceSumSquare_18

OnnxAtanh_9

OnnxInstanceNormalization_1

OnnxReduceSum_1

OnnxAveragePool

OnnxInstanceNormalization_6

OnnxReduceSum_11

OnnxAveragePool_1

OnnxIsInf

OnnxReduceSum_13

OnnxAveragePool_10

OnnxIsInf_10

OnnxRegexFullMatch

OnnxAveragePool_11

OnnxIsInf_20

OnnxRegexFullMatch_20

OnnxAveragePool_19

OnnxIsNaN

OnnxRelu

OnnxAveragePool_7

OnnxIsNaN_13

OnnxRelu_1

OnnxBatchNormalization

OnnxIsNaN_20

OnnxRelu_13

OnnxBatchNormalization_1

OnnxIsNaN_9

OnnxRelu_14

OnnxBatchNormalization_14

OnnxLRN

OnnxRelu_6

OnnxBatchNormalization_15

OnnxLRN_1

OnnxReshape

OnnxBatchNormalization_6

OnnxLRN_13

OnnxReshape_1

OnnxBatchNormalization_7

OnnxLSTM

OnnxReshape_13

OnnxBatchNormalization_9

OnnxLSTM_1

OnnxReshape_14

OnnxBernoulli

OnnxLSTM_14

OnnxReshape_19

OnnxBernoulli_15

OnnxLSTM_7

OnnxReshape_21

OnnxBinarizer

OnnxLabelEncoder

OnnxReshape_5

OnnxBinarizer_1

OnnxLabelEncoder_1

OnnxResize

OnnxBitShift

OnnxLabelEncoder_2

OnnxResize_10

OnnxBitShift_11

OnnxLabelEncoder_4

OnnxResize_11

OnnxBitwiseAnd

OnnxLayerNormalization

OnnxResize_13

OnnxBitwiseAnd_18

OnnxLayerNormalization_17

OnnxResize_18

OnnxBitwiseNot

OnnxLeakyRelu

OnnxResize_19

OnnxBitwiseNot_18

OnnxLeakyRelu_1

OnnxReverseSequence

OnnxBitwiseOr

OnnxLeakyRelu_16

OnnxReverseSequence_10

OnnxBitwiseOr_18

OnnxLeakyRelu_6

OnnxRoiAlign

OnnxBitwiseXor

OnnxLess

OnnxRoiAlign_10

OnnxBitwiseXor_18

OnnxLessOrEqual

OnnxRoiAlign_16

OnnxBlackmanWindow

OnnxLessOrEqual_12

OnnxRound

OnnxBlackmanWindow_17

OnnxLessOrEqual_16

OnnxRound_11

OnnxCast

OnnxLess_1

OnnxSTFT

OnnxCastLike

OnnxLess_13

OnnxSTFT_17

OnnxCastLike_15

OnnxLess_7

OnnxSVMClassifier

OnnxCastLike_19

OnnxLess_9

OnnxSVMClassifier_1

OnnxCastLike_21

OnnxLinearClassifier

OnnxSVMRegressor

OnnxCastMap

OnnxLinearClassifier_1

OnnxSVMRegressor_1

OnnxCastMap_1

OnnxLinearRegressor

OnnxScaler

OnnxCast_1

OnnxLinearRegressor_1

OnnxScaler_1

OnnxCast_13

OnnxLog

OnnxScan

OnnxCast_19

OnnxLogSoftmax

OnnxScan_11

OnnxCast_21

OnnxLogSoftmax_1

OnnxScan_16

OnnxCast_6

OnnxLogSoftmax_11

OnnxScan_19

OnnxCast_9

OnnxLogSoftmax_13

OnnxScan_21

OnnxCategoryMapper

OnnxLog_1

OnnxScan_8

OnnxCategoryMapper_1

OnnxLog_13

OnnxScan_9

OnnxCeil

OnnxLog_6

OnnxScatter

OnnxCeil_1

OnnxLoop

OnnxScatterElements

OnnxCeil_13

OnnxLoop_1

OnnxScatterElements_11

OnnxCeil_6

OnnxLoop_11

OnnxScatterElements_13

OnnxCelu

OnnxLoop_13

OnnxScatterElements_16

OnnxCelu_12

OnnxLoop_16

OnnxScatterElements_18

OnnxCenterCropPad

OnnxLoop_19

OnnxScatterND

OnnxCenterCropPad_18

OnnxLoop_21

OnnxScatterND_11

OnnxClip

OnnxLpNormalization

OnnxScatterND_13

OnnxClip_1

OnnxLpNormalization_1

OnnxScatterND_16

OnnxClip_11

OnnxLpPool

OnnxScatterND_18

OnnxClip_12

OnnxLpPool_1

OnnxScatter_11

OnnxClip_13

OnnxLpPool_11

OnnxScatter_9

OnnxClip_6

OnnxLpPool_18

OnnxSelu

OnnxCol2Im

OnnxLpPool_2

OnnxSelu_1

OnnxCol2Im_18

OnnxMatMul

OnnxSelu_6

OnnxCompress

OnnxMatMulInteger

OnnxSequenceAt

OnnxCompress_11

OnnxMatMulInteger_10

OnnxSequenceAt_11

OnnxCompress_9

OnnxMatMul_1

OnnxSequenceConstruct

OnnxConcat

OnnxMatMul_13

OnnxSequenceConstruct_11

OnnxConcatFromSequence

OnnxMatMul_9

OnnxSequenceEmpty

OnnxConcatFromSequence_11

OnnxMax

OnnxSequenceEmpty_11

OnnxConcat_1

OnnxMaxPool

OnnxSequenceErase

OnnxConcat_11

OnnxMaxPool_1

OnnxSequenceErase_11

OnnxConcat_13

OnnxMaxPool_10

OnnxSequenceInsert

OnnxConcat_4

OnnxMaxPool_11

OnnxSequenceInsert_11

OnnxConstant

OnnxMaxPool_12

OnnxSequenceLength

OnnxConstantOfShape

OnnxMaxPool_8

OnnxSequenceLength_11

OnnxConstantOfShape_20

OnnxMaxRoiPool

OnnxSequenceMap

OnnxConstantOfShape_21

OnnxMaxRoiPool_1

OnnxSequenceMap_17

OnnxConstantOfShape_9

OnnxMaxUnpool

OnnxShape

OnnxConstant_1

OnnxMaxUnpool_11

OnnxShape_1

OnnxConstant_11

OnnxMaxUnpool_9

OnnxShape_13

OnnxConstant_12

OnnxMax_1

OnnxShape_15

OnnxConstant_13

OnnxMax_12

OnnxShape_19

OnnxConstant_19

OnnxMax_13

OnnxShape_21

OnnxConstant_21

OnnxMax_6

OnnxShrink

OnnxConstant_9

OnnxMax_8

OnnxShrink_9

OnnxConv

OnnxMean

OnnxSigmoid

OnnxConvInteger

OnnxMeanVarianceNormalization

OnnxSigmoid_1

OnnxConvInteger_10

OnnxMeanVarianceNormalization_13

OnnxSigmoid_13

OnnxConvTranspose

OnnxMeanVarianceNormalization_9

OnnxSigmoid_6

OnnxConvTranspose_1

OnnxMean_1

OnnxSign

OnnxConvTranspose_11

OnnxMean_13

OnnxSign_13

OnnxConv_1

OnnxMean_6

OnnxSign_9

OnnxConv_11

OnnxMean_8

OnnxSin

OnnxCos

OnnxMelWeightMatrix

OnnxSin_7

OnnxCos_7

OnnxMelWeightMatrix_17

OnnxSinh

OnnxCosh

OnnxMin

OnnxSinh_9

OnnxCosh_9

OnnxMin_1

OnnxSize

OnnxCumSum

OnnxMin_12

OnnxSize_1

OnnxCumSum_11

OnnxMin_13

OnnxSize_13

OnnxCumSum_14

OnnxMin_6

OnnxSize_19

OnnxDFT

OnnxMin_8

OnnxSize_21

OnnxDFT_17

OnnxMish

OnnxSlice

OnnxDFT_20

OnnxMish_18

OnnxSlice_1

OnnxDeformConv

OnnxMod

OnnxSlice_10

OnnxDeformConv_19

OnnxMod_10

OnnxSlice_11

OnnxDepthToSpace

OnnxMod_13

OnnxSlice_13

OnnxDepthToSpace_1

OnnxMomentum

OnnxSoftmax

OnnxDepthToSpace_11

OnnxMomentum_1

OnnxSoftmaxCrossEntropyLoss

OnnxDepthToSpace_13

OnnxMul

OnnxSoftmaxCrossEntropyLoss_12

OnnxDequantizeLinear

OnnxMul_1

OnnxSoftmaxCrossEntropyLoss_13

OnnxDequantizeLinear_10

OnnxMul_13

OnnxSoftmax_1

OnnxDequantizeLinear_13

OnnxMul_14

OnnxSoftmax_11

OnnxDequantizeLinear_19

OnnxMul_6

OnnxSoftmax_13

OnnxDequantizeLinear_21

OnnxMul_7

OnnxSoftplus

OnnxDet

OnnxMultinomial

OnnxSoftplus_1

OnnxDet_11

OnnxMultinomial_7

OnnxSoftsign

OnnxDictVectorizer

OnnxNeg

OnnxSoftsign_1

OnnxDictVectorizer_1

OnnxNeg_1

OnnxSpaceToDepth

OnnxDiv

OnnxNeg_13

OnnxSpaceToDepth_1

OnnxDiv_1

OnnxNeg_6

OnnxSpaceToDepth_13

OnnxDiv_13

OnnxNegativeLogLikelihoodLoss

OnnxSplit

OnnxDiv_14

OnnxNegativeLogLikelihoodLoss_12

OnnxSplitToSequence

OnnxDiv_6

OnnxNegativeLogLikelihoodLoss_13

OnnxSplitToSequence_11

OnnxDiv_7

OnnxNonMaxSuppression

OnnxSplit_1

OnnxDropout

OnnxNonMaxSuppression_10

OnnxSplit_11

OnnxDropout_1

OnnxNonMaxSuppression_11

OnnxSplit_13

OnnxDropout_10

OnnxNonZero

OnnxSplit_18

OnnxDropout_12

OnnxNonZero_13

OnnxSplit_2

OnnxDropout_13

OnnxNonZero_9

OnnxSqrt

OnnxDropout_6

OnnxNormalizer

OnnxSqrt_1

OnnxDropout_7

OnnxNormalizer_1

OnnxSqrt_13

OnnxDynamicQuantizeLinear

OnnxNot

OnnxSqrt_6

OnnxDynamicQuantizeLinear_11

OnnxNot_1

OnnxSqueeze

OnnxEinsum

OnnxOneHot

OnnxSqueeze_1

OnnxEinsum_12

OnnxOneHotEncoder

OnnxSqueeze_11

OnnxElu

OnnxOneHotEncoder_1

OnnxSqueeze_13

OnnxElu_1

OnnxOneHot_11

OnnxSqueeze_21

OnnxElu_6

OnnxOneHot_9

OnnxStringConcat

OnnxEqual

OnnxOptional

OnnxStringConcat_20

OnnxEqual_1

OnnxOptionalGetElement

OnnxStringNormalizer

OnnxEqual_11

OnnxOptionalGetElement_15

OnnxStringNormalizer_10

OnnxEqual_13

OnnxOptionalGetElement_18

OnnxStringSplit

OnnxEqual_19

OnnxOptionalHasElement

OnnxStringSplit_20

OnnxEqual_7

OnnxOptionalHasElement_15

OnnxSub

OnnxErf

OnnxOptionalHasElement_18

OnnxSub_1

OnnxErf_13

OnnxOptional_15

OnnxSub_13

OnnxErf_9

OnnxOr

OnnxSub_14

OnnxExp

OnnxOr_1

OnnxSub_6

OnnxExp_1

OnnxOr_7

OnnxSub_7

OnnxExp_13

OnnxPRelu

OnnxSum

OnnxExp_6

OnnxPRelu_1

OnnxSum_1

OnnxExpand

OnnxPRelu_16

OnnxSum_13

OnnxExpand_13

OnnxPRelu_6

OnnxSum_6

OnnxExpand_8

OnnxPRelu_7

OnnxSum_8

OnnxEyeLike

OnnxPRelu_9

OnnxTan

OnnxEyeLike_9

OnnxPad

OnnxTan_7

OnnxFeatureVectorizer

OnnxPad_1

OnnxTanh

OnnxFeatureVectorizer_1

OnnxPad_11

OnnxTanh_1

OnnxFlatten

OnnxPad_13

OnnxTanh_13

OnnxFlatten_1

OnnxPad_18

OnnxTanh_6

OnnxFlatten_11

OnnxPad_19

OnnxTfIdfVectorizer

OnnxFlatten_13

OnnxPad_2

OnnxTfIdfVectorizer_9

OnnxFlatten_21

OnnxPad_21

OnnxThresholdedRelu

OnnxFlatten_9

OnnxPow

OnnxThresholdedRelu_10

OnnxFloor

OnnxPow_1

OnnxTile

OnnxFloor_1

OnnxPow_12

OnnxTile_1

OnnxFloor_13

OnnxPow_13

OnnxTile_13

OnnxFloor_6

OnnxPow_15

OnnxTile_6

OnnxGRU

OnnxPow_7

OnnxTopK

OnnxGRU_1

OnnxQLinearConv

OnnxTopK_1

OnnxGRU_14

OnnxQLinearConv_10

OnnxTopK_10

OnnxGRU_3

OnnxQLinearMatMul

OnnxTopK_11

OnnxGRU_7

OnnxQLinearMatMul_10

OnnxTranspose

OnnxGather

OnnxQLinearMatMul_21

OnnxTranspose_1

OnnxGatherElements

OnnxQuantizeLinear

OnnxTranspose_13

OnnxGatherElements_11

OnnxQuantizeLinear_10

OnnxTranspose_21

OnnxGatherElements_13

OnnxQuantizeLinear_13

OnnxTreeEnsembleClassifier

OnnxGatherND

OnnxQuantizeLinear_19

OnnxTreeEnsembleClassifier_1

OnnxGatherND_11

OnnxQuantizeLinear_21

OnnxTreeEnsembleClassifier_3

OnnxGatherND_12

OnnxRNN

OnnxTreeEnsembleRegressor

OnnxGatherND_13

OnnxRNN_1

OnnxTreeEnsembleRegressor_1

OnnxGather_1

OnnxRNN_14

OnnxTreeEnsembleRegressor_3

OnnxGather_11

OnnxRNN_7

OnnxTrilu

OnnxGather_13

OnnxRandomNormal

OnnxTrilu_14

OnnxGelu

OnnxRandomNormalLike

OnnxUnique

OnnxGelu_20

OnnxRandomNormalLike_1

OnnxUnique_11

OnnxGemm

OnnxRandomNormal_1

OnnxUnsqueeze

OnnxGemm_1

OnnxRandomUniform

OnnxUnsqueeze_1

OnnxGemm_11

OnnxRandomUniformLike

OnnxUnsqueeze_11

OnnxGemm_13

OnnxRandomUniformLike_1

OnnxUnsqueeze_13

OnnxGemm_6

OnnxRandomUniform_1

OnnxUnsqueeze_21

OnnxGemm_7

OnnxRange

OnnxUpsample

OnnxGemm_9

OnnxRange_11

OnnxUpsample_10

OnnxGlobalAveragePool

OnnxReciprocal

OnnxUpsample_7

OnnxGlobalAveragePool_1

OnnxReciprocal_1

OnnxUpsample_9

OnnxGlobalLpPool

OnnxReciprocal_13

OnnxWhere

OnnxGlobalLpPool_1

OnnxReciprocal_6

OnnxWhere_16

OnnxGlobalLpPool_2

OnnxReduceL1

OnnxWhere_9

OnnxGlobalMaxPool

OnnxReduceL1_1

OnnxXor

OnnxGlobalMaxPool_1

OnnxReduceL1_11

OnnxXor_1

OnnxGradient

OnnxReduceL1_13

OnnxXor_7

OnnxGradient_1

OnnxReduceL1_18

OnnxZipMap

OnnxGreater

OnnxReduceL2

OnnxZipMap_1

OnnxGreaterOrEqual

OnnxReduceL2_1

OnnxGreaterOrEqual_12

OnnxReduceL2_11

OnnxAbs#

class skl2onnx.algebra.onnx_ops.OnnxAbs(*args, **kwargs)#

Version

Onnx name: Abs

This version of the operator has been available since version 13.

Summary

Absolute takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where absolute value, y = abs(x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxAbs_1#

class skl2onnx.algebra.onnx_ops.OnnxAbs_1(*args, **kwargs)#

Version

Onnx name: Abs

This version of the operator has been available since version 1.

Summary

Absolute takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the absolute is, y = abs(x), is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAbs_13#

class skl2onnx.algebra.onnx_ops.OnnxAbs_13(*args, **kwargs)#

Version

Onnx name: Abs

This version of the operator has been available since version 13.

Summary

Absolute takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where absolute value, y = abs(x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxAbs_6#

class skl2onnx.algebra.onnx_ops.OnnxAbs_6(*args, **kwargs)#

Version

Onnx name: Abs

This version of the operator has been available since version 6.

Summary

Absolute takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the absolute is, y = abs(x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxAcos#

class skl2onnx.algebra.onnx_ops.OnnxAcos(*args, **kwargs)#

Version

Onnx name: Acos

This version of the operator has been available since version 7.

Summary

Calculates the arccosine (inverse of cosine) of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The arccosine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAcos_7#

class skl2onnx.algebra.onnx_ops.OnnxAcos_7(*args, **kwargs)#

Version

Onnx name: Acos

This version of the operator has been available since version 7.

Summary

Calculates the arccosine (inverse of cosine) of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The arccosine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAcosh#

class skl2onnx.algebra.onnx_ops.OnnxAcosh(*args, **kwargs)#

Version

Onnx name: Acosh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic arccosine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic arccosine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAcosh_9#

class skl2onnx.algebra.onnx_ops.OnnxAcosh_9(*args, **kwargs)#

Version

Onnx name: Acosh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic arccosine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic arccosine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAdagrad#

class skl2onnx.algebra.onnx_ops.OnnxAdagrad(*args, **kwargs)#

Version

Onnx name: Adagrad

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Compute one iteration of ADAGRAD, a stochastic gradient based optimization algorithm. This operator can conduct the optimization of multiple tensor variables.

Let’s define the behavior of this operator. As you can imagine, ADAGRAD requires some parameters:

  • The initial learning-rate “R”.

  • The update count “T”. That is, the number of training iterations conducted.

  • A L2-norm regularization coefficient “norm_coefficient”.

  • A learning-rate decay factor “decay_factor”.

  • A small constant “epsilon” to avoid dividing-by-zero.

At each ADAGRAD iteration, the optimized tensors are moved along a direction computed based on their estimated gradient and accumulated squared gradient. Assume that only a single tensor “X” is updated by this operator. We need the value of “X”, its gradient “G”, and its accumulated squared gradient “H”. Therefore, variables in this operator’s input list are sequentially “R”, “T”, “X”, “G”, and “H”. Other parameters are given as attributes because they are usually constants. Also, the corresponding output tensors are the new value of “X” (called “X_new”), and then the new accumulated squared gradient (called “H_new”). Those outputs are computed from the given inputs following the pseudo code below.

Let “+”, “-”, “*”, and “/” are all element-wise arithmetic operations with numpy-style broadcasting support. The pseudo code to compute those outputs is:

// Compute a scalar learning-rate factor. At the first update of X, T is generally // 0 (0-based update index) or 1 (1-based update index). r = R / (1 + T * decay_factor);

// Add gradient of 0.5 * norm_coefficient * ||X||_2^2, where ||X||_2 is the 2-norm. G_regularized = norm_coefficient * X + G;

// Compute new accumulated squared gradient. H_new = H + G_regularized * G_regularized;

// Compute the adaptive part of per-coordinate learning rate. Note that Sqrt(…) // computes element-wise square-root. H_adaptive = Sqrt(H_new) + epsilon

// Compute the new value of “X”. X_new = X - r * G_regularized / H_adaptive;

If one assign this operators to optimize multiple inputs, for example, “X_1” and “X_2”, the same pseudo code may be extended to handle all tensors jointly. More specifically, we can view “X” as a concatenation of “X_1” and “X_2” (of course, their gradient and accumulate gradient should be concatenated too) and then just reuse the entire pseudo code.

Note that ADAGRAD was first proposed in http://jmlr.org/papers/volume12/duchi11a/duchi11a.pdf. In that reference paper, this operator is a special case of the Figure 1’s composite mirror descent update.

Attributes

  • decay_factor: The decay factor of learning rate after one update.The effective learning rate is computed by r = R / (1 + T * decay_factor). Default to 0 so that increasing update counts doesn’t reduce the learning rate. Default value is name: "decay_factor" type: FLOAT f: 0

  • epsilon: Small scalar to avoid dividing by zero. Default value is name: "epsilon" type: FLOAT f: 1e-06

  • norm_coefficient: Regularization coefficient in 0.5 * norm_coefficient * ||X||_2^2. Default to 0, which means no regularization. Default value is name: "norm_coefficient" type: FLOAT f: 0

Inputs

Between 3 and 2147483647 inputs.

  • R (heterogeneous)T1: The initial learning rate.

  • T (heterogeneous)T2: The update count of “X”. It should be a scalar.

  • inputs (variadic)T3: The current values of optimized tensors, followed by their respective gradients, followed by their respective accumulated squared gradients.For example, if two tensor “X_1” and “X_2” are optimized, The input list would be [“X_1”, “X_2”, gradient of “X_1”, gradient of “X_2”, accumulated squared gradient of “X_1”, accumulated squared gradient of “X_2”].

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)T3: Updated values of optimized tensors, followed by their updated values of accumulated squared gradients. For example, if two tensor “X_1” and “X_2” are optimized, the output list would be [new value of “X_1,” new value of “X_2” new accumulated squared gradient of “X_1”, new accumulated squared gradient of “X_2”].

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float scalars.

  • T2 tensor(int64): Constrain input types to 64-bit integer scalars.

  • T3 tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAdagrad_1#

class skl2onnx.algebra.onnx_ops.OnnxAdagrad_1(*args, **kwargs)#

Version

Onnx name: Adagrad

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Compute one iteration of ADAGRAD, a stochastic gradient based optimization algorithm. This operator can conduct the optimization of multiple tensor variables.

Let’s define the behavior of this operator. As you can imagine, ADAGRAD requires some parameters:

  • The initial learning-rate “R”.

  • The update count “T”. That is, the number of training iterations conducted.

  • A L2-norm regularization coefficient “norm_coefficient”.

  • A learning-rate decay factor “decay_factor”.

  • A small constant “epsilon” to avoid dividing-by-zero.

At each ADAGRAD iteration, the optimized tensors are moved along a direction computed based on their estimated gradient and accumulated squared gradient. Assume that only a single tensor “X” is updated by this operator. We need the value of “X”, its gradient “G”, and its accumulated squared gradient “H”. Therefore, variables in this operator’s input list are sequentially “R”, “T”, “X”, “G”, and “H”. Other parameters are given as attributes because they are usually constants. Also, the corresponding output tensors are the new value of “X” (called “X_new”), and then the new accumulated squared gradient (called “H_new”). Those outputs are computed from the given inputs following the pseudo code below.

Let “+”, “-”, “*”, and “/” are all element-wise arithmetic operations with numpy-style broadcasting support. The pseudo code to compute those outputs is:

// Compute a scalar learning-rate factor. At the first update of X, T is generally // 0 (0-based update index) or 1 (1-based update index). r = R / (1 + T * decay_factor);

// Add gradient of 0.5 * norm_coefficient * ||X||_2^2, where ||X||_2 is the 2-norm. G_regularized = norm_coefficient * X + G;

// Compute new accumulated squared gradient. H_new = H + G_regularized * G_regularized;

// Compute the adaptive part of per-coordinate learning rate. Note that Sqrt(…) // computes element-wise square-root. H_adaptive = Sqrt(H_new) + epsilon

// Compute the new value of “X”. X_new = X - r * G_regularized / H_adaptive;

If one assign this operators to optimize multiple inputs, for example, “X_1” and “X_2”, the same pseudo code may be extended to handle all tensors jointly. More specifically, we can view “X” as a concatenation of “X_1” and “X_2” (of course, their gradient and accumulate gradient should be concatenated too) and then just reuse the entire pseudo code.

Note that ADAGRAD was first proposed in http://jmlr.org/papers/volume12/duchi11a/duchi11a.pdf. In that reference paper, this operator is a special case of the Figure 1’s composite mirror descent update.

Attributes

  • decay_factor: The decay factor of learning rate after one update.The effective learning rate is computed by r = R / (1 + T * decay_factor). Default to 0 so that increasing update counts doesn’t reduce the learning rate. Default value is name: "decay_factor" type: FLOAT f: 0

  • epsilon: Small scalar to avoid dividing by zero. Default value is name: "epsilon" type: FLOAT f: 1e-06

  • norm_coefficient: Regularization coefficient in 0.5 * norm_coefficient * ||X||_2^2. Default to 0, which means no regularization. Default value is name: "norm_coefficient" type: FLOAT f: 0

Inputs

Between 3 and 2147483647 inputs.

  • R (heterogeneous)T1: The initial learning rate.

  • T (heterogeneous)T2: The update count of “X”. It should be a scalar.

  • inputs (variadic)T3: The current values of optimized tensors, followed by their respective gradients, followed by their respective accumulated squared gradients.For example, if two tensor “X_1” and “X_2” are optimized, The input list would be [“X_1”, “X_2”, gradient of “X_1”, gradient of “X_2”, accumulated squared gradient of “X_1”, accumulated squared gradient of “X_2”].

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)T3: Updated values of optimized tensors, followed by their updated values of accumulated squared gradients. For example, if two tensor “X_1” and “X_2” are optimized, the output list would be [new value of “X_1,” new value of “X_2” new accumulated squared gradient of “X_1”, new accumulated squared gradient of “X_2”].

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float scalars.

  • T2 tensor(int64): Constrain input types to 64-bit integer scalars.

  • T3 tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAdam#

class skl2onnx.algebra.onnx_ops.OnnxAdam(*args, **kwargs)#

Version

Onnx name: Adam

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Compute one iteration of Adam, a stochastic gradient based optimization algorithm. This operator can conduct the optimization of multiple tensor variables.

Let’s define the behavior of this operator. First of all, Adam requires some parameters:

  • The learning-rate “R”.

  • The update count “T”. That is, the number of training iterations conducted.

  • A L2-norm regularization coefficient “norm_coefficient”.

  • A small constant “epsilon” to avoid dividing-by-zero.

  • Two coefficients, “alpha” and “beta”.

At each Adam iteration, the optimized tensors are moved along a direction computed based on their exponentially-averaged historical gradient and exponentially-averaged historical squared gradient. Assume that only a tensor “X” is being optimized. The rest of required information is

  • the value of “X”,

  • “X“‘s gradient (denoted by “G”),

  • “X“‘s exponentially-averaged historical gradient (denoted by “V”), and

  • “X“‘s exponentially-averaged historical squared gradient (denoted by “H”).

Some of those parameters are passed into this operator as input tensors and others are stored as this operator’s attributes. Specifically, this operator’s input tensor list is [“R”, “T”, “X”, “G”, “V”, “H”]. That is, “R” is the first input, “T” is the second input, and so on. Other parameters are given as attributes because they are constants. Moreover, the corresponding output tensors are

  • the new value of “X” (called “X_new”),

  • the new exponentially-averaged historical gradient (denoted by “V_new”), and

  • the new exponentially-averaged historical squared gradient (denoted by “H_new”).

Those outputs are computed following the pseudo code below.

Let “+”, “-”, “*”, and “/” are all element-wise arithmetic operations with numpy-style broadcasting support. The pseudo code to compute those outputs is:

// Add gradient of 0.5 * norm_coefficient * ||X||_2^2, where ||X||_2 is the 2-norm. G_regularized = norm_coefficient * X + G

// Update exponentially-averaged historical gradient. V_new = alpha * V + (1 - alpha) * G_regularized

// Update exponentially-averaged historical squared gradient. H_new = beta * H + (1 - beta) * G_regularized * G_regularized

// Compute the element-wise square-root of H_new. V_new will be element-wisely // divided by H_sqrt for a better update direction. H_sqrt = Sqrt(H_new) + epsilon

// Compute learning-rate. Note that “alpha**T”/”beta**T” is alpha’s/beta’s T-th power. R_adjusted = T > 0 ? R * Sqrt(1 - beta**T) / (1 - alpha**T) : R

// Compute new value of “X”. X_new = X - R_adjusted * V_new / H_sqrt

// Post-update regularization. X_final = (1 - norm_coefficient_post) * X_new

If there are multiple inputs to be optimized, the pseudo code will be applied independently to each of them.

Attributes

  • alpha: Coefficient of previously accumulated gradient in running average. Default to 0.9. Default value is name: "alpha" type: FLOAT f: 0.9

  • beta: Coefficient of previously accumulated squared-gradient in running average. Default to 0.999. Default value is name: "beta" type: FLOAT f: 0.999

  • epsilon: Small scalar to avoid dividing by zero. Default value is name: "epsilon" type: FLOAT f: 1e-06

  • norm_coefficient: Regularization coefficient of 0.5 * norm_coefficient * ||X||_2^2. Default to 0, which means no regularization. Default value is name: "norm_coefficient" type: FLOAT f: 0

  • norm_coefficient_post: Regularization coefficient of 0.5 * norm_coefficient * ||X||_2^2. Default to 0, which means no regularization. Default value is name: "norm_coefficient_post" type: FLOAT f: 0

Inputs

Between 3 and 2147483647 inputs.

  • R (heterogeneous)T1: The initial learning rate.

  • T (heterogeneous)T2: The update count of “X”. It should be a scalar.

  • inputs (variadic)T3: The tensors to be optimized, followed by their respective gradients, followed by their respective accumulated gradients (aka momentum), followed by their respective accumulated squared gradients. For example, to optimize tensors “X_1” and “X_2,”, the input list would be [“X_1”, “X_2”, gradient of “X_1”, gradient of “X_2”, accumulated gradient of “X_1”, accumulated gradient of “X_2”, accumulated squared gradient of “X_1”, accumulated squared gradient of “X_2”].

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)T3: New values of optimized tensors, followed by their respective new accumulated gradients, followed by their respective new accumulated squared gradients. For example, if two tensors “X_1” and “X_2” are optimized, the outputs list would be [new value of “X_1”, new value of “X_2”, new accumulated gradient of “X_1”, new accumulated gradient of “X_2”, new accumulated squared gradient of “X_1”, new accumulated squared gradient of “X_2”].

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float scalars.

  • T2 tensor(int64): Constrain input types to 64-bit integer scalars.

  • T3 tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAdam_1#

class skl2onnx.algebra.onnx_ops.OnnxAdam_1(*args, **kwargs)#

Version

Onnx name: Adam

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Compute one iteration of Adam, a stochastic gradient based optimization algorithm. This operator can conduct the optimization of multiple tensor variables.

Let’s define the behavior of this operator. First of all, Adam requires some parameters:

  • The learning-rate “R”.

  • The update count “T”. That is, the number of training iterations conducted.

  • A L2-norm regularization coefficient “norm_coefficient”.

  • A small constant “epsilon” to avoid dividing-by-zero.

  • Two coefficients, “alpha” and “beta”.

At each Adam iteration, the optimized tensors are moved along a direction computed based on their exponentially-averaged historical gradient and exponentially-averaged historical squared gradient. Assume that only a tensor “X” is being optimized. The rest of required information is

  • the value of “X”,

  • “X“‘s gradient (denoted by “G”),

  • “X“‘s exponentially-averaged historical gradient (denoted by “V”), and

  • “X“‘s exponentially-averaged historical squared gradient (denoted by “H”).

Some of those parameters are passed into this operator as input tensors and others are stored as this operator’s attributes. Specifically, this operator’s input tensor list is [“R”, “T”, “X”, “G”, “V”, “H”]. That is, “R” is the first input, “T” is the second input, and so on. Other parameters are given as attributes because they are constants. Moreover, the corresponding output tensors are

  • the new value of “X” (called “X_new”),

  • the new exponentially-averaged historical gradient (denoted by “V_new”), and

  • the new exponentially-averaged historical squared gradient (denoted by “H_new”).

Those outputs are computed following the pseudo code below.

Let “+”, “-”, “*”, and “/” are all element-wise arithmetic operations with numpy-style broadcasting support. The pseudo code to compute those outputs is:

// Add gradient of 0.5 * norm_coefficient * ||X||_2^2, where ||X||_2 is the 2-norm. G_regularized = norm_coefficient * X + G

// Update exponentially-averaged historical gradient. V_new = alpha * V + (1 - alpha) * G_regularized

// Update exponentially-averaged historical squared gradient. H_new = beta * H + (1 - beta) * G_regularized * G_regularized

// Compute the element-wise square-root of H_new. V_new will be element-wisely // divided by H_sqrt for a better update direction. H_sqrt = Sqrt(H_new) + epsilon

// Compute learning-rate. Note that “alpha**T”/”beta**T” is alpha’s/beta’s T-th power. R_adjusted = T > 0 ? R * Sqrt(1 - beta**T) / (1 - alpha**T) : R

// Compute new value of “X”. X_new = X - R_adjusted * V_new / H_sqrt

// Post-update regularization. X_final = (1 - norm_coefficient_post) * X_new

If there are multiple inputs to be optimized, the pseudo code will be applied independently to each of them.

Attributes

  • alpha: Coefficient of previously accumulated gradient in running average. Default to 0.9. Default value is name: "alpha" type: FLOAT f: 0.9

  • beta: Coefficient of previously accumulated squared-gradient in running average. Default to 0.999. Default value is name: "beta" type: FLOAT f: 0.999

  • epsilon: Small scalar to avoid dividing by zero. Default value is name: "epsilon" type: FLOAT f: 1e-06

  • norm_coefficient: Regularization coefficient of 0.5 * norm_coefficient * ||X||_2^2. Default to 0, which means no regularization. Default value is name: "norm_coefficient" type: FLOAT f: 0

  • norm_coefficient_post: Regularization coefficient of 0.5 * norm_coefficient * ||X||_2^2. Default to 0, which means no regularization. Default value is name: "norm_coefficient_post" type: FLOAT f: 0

Inputs

Between 3 and 2147483647 inputs.

  • R (heterogeneous)T1: The initial learning rate.

  • T (heterogeneous)T2: The update count of “X”. It should be a scalar.

  • inputs (variadic)T3: The tensors to be optimized, followed by their respective gradients, followed by their respective accumulated gradients (aka momentum), followed by their respective accumulated squared gradients. For example, to optimize tensors “X_1” and “X_2,”, the input list would be [“X_1”, “X_2”, gradient of “X_1”, gradient of “X_2”, accumulated gradient of “X_1”, accumulated gradient of “X_2”, accumulated squared gradient of “X_1”, accumulated squared gradient of “X_2”].

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)T3: New values of optimized tensors, followed by their respective new accumulated gradients, followed by their respective new accumulated squared gradients. For example, if two tensors “X_1” and “X_2” are optimized, the outputs list would be [new value of “X_1”, new value of “X_2”, new accumulated gradient of “X_1”, new accumulated gradient of “X_2”, new accumulated squared gradient of “X_1”, new accumulated squared gradient of “X_2”].

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float scalars.

  • T2 tensor(int64): Constrain input types to 64-bit integer scalars.

  • T3 tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAdd#

class skl2onnx.algebra.onnx_ops.OnnxAdd(*args, **kwargs)#

Version

Onnx name: Add

This version of the operator has been available since version 14.

Summary

Performs element-wise binary addition (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxAdd_1#

class skl2onnx.algebra.onnx_ops.OnnxAdd_1(*args, **kwargs)#

Version

Onnx name: Add

This version of the operator has been available since version 1.

Summary

Performs element-wise binary addition (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAdd_13#

class skl2onnx.algebra.onnx_ops.OnnxAdd_13(*args, **kwargs)#

Version

Onnx name: Add

This version of the operator has been available since version 13.

Summary

Performs element-wise binary addition (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

OnnxAdd_14#

class skl2onnx.algebra.onnx_ops.OnnxAdd_14(*args, **kwargs)#

Version

Onnx name: Add

This version of the operator has been available since version 14.

Summary

Performs element-wise binary addition (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxAdd_6#

class skl2onnx.algebra.onnx_ops.OnnxAdd_6(*args, **kwargs)#

Version

Onnx name: Add

This version of the operator has been available since version 6.

Summary

Performs element-wise binary addition (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxAdd_7#

class skl2onnx.algebra.onnx_ops.OnnxAdd_7(*args, **kwargs)#

Version

Onnx name: Add

This version of the operator has been available since version 7.

Summary

Performs element-wise binary addition (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxAffineGrid#

class skl2onnx.algebra.onnx_ops.OnnxAffineGrid(*args, **kwargs)#

Version

Onnx name: AffineGrid

This version of the operator has been available since version 20.

Summary

Generates a 2D or 3D flow field (sampling grid), given a batch of affine matrices theta (https://pytorch.org/docs/stable/generated/torch.nn.functional.affine_grid.html). An affine matrix theta is applied to a position tensor represented in its homogeneous expression. Here is an example in 3D:

[r00, r01, r02, t0]   [x]   [x']
[r10, r11, r12, t1] * [y] = [y']
[r20, r21, r22, t2]   [z]   [z']
[0,   0,   0,   1 ]   [1]   [1 ]

where (x, y, z) is the position in the original space, (x’, y’, z’) is the position in the output space. The last row is always [0, 0, 0, 1] and is not stored in the affine matrix. Therefore we have theta of shape (N, 2, 3) for 2D or (N, 3, 4) for 3D.

Input size is used to define grid of positions evenly spaced in the original 2D or 3D space, with dimensions ranging from -1 to 1. The output grid contains positions in the output space.

When align_corners=1, consider -1 and 1 to refer to the centers of the corner pixels (mark v in illustration).

v            v            v            v
|-------------------|------------------|
-1                  0                  1

When align_corners=0, consider -1 and 1 to refer to the outer edge of the corner pixels.

    v        v         v         v
|------------------|-------------------|
-1                 0                   1

Attributes

  • align_corners: if align_corners=1, consider -1 and 1 to refer to the centers of the corner pixels. if align_corners=0, consider -1 and 1 to refer to the outer edge the corner pixels. Default value is name: "align_corners" type: INT i: 0

Inputs

  • theta (heterogeneous)T1: input batch of affine matrices with shape (N, 2, 3) for 2D or (N, 3, 4) for 3D

  • size (heterogeneous)T2: the target output image size (N, C, H, W) for 2D or (N, C, D, H, W) for 3D

Outputs

  • grid (heterogeneous)T1: output tensor of shape (N, H, W, 2) of 2D sample coordinates or (N, D, H, W, 3) of 3D sample coordinates.

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double): Constrain grid types to float tensors.

  • T2 tensor(int64): Constrain size’s type to int64 tensors.

OnnxAffineGrid_20#

class skl2onnx.algebra.onnx_ops.OnnxAffineGrid_20(*args, **kwargs)#

Version

Onnx name: AffineGrid

This version of the operator has been available since version 20.

Summary

Generates a 2D or 3D flow field (sampling grid), given a batch of affine matrices theta (https://pytorch.org/docs/stable/generated/torch.nn.functional.affine_grid.html). An affine matrix theta is applied to a position tensor represented in its homogeneous expression. Here is an example in 3D:

[r00, r01, r02, t0]   [x]   [x']
[r10, r11, r12, t1] * [y] = [y']
[r20, r21, r22, t2]   [z]   [z']
[0,   0,   0,   1 ]   [1]   [1 ]

where (x, y, z) is the position in the original space, (x’, y’, z’) is the position in the output space. The last row is always [0, 0, 0, 1] and is not stored in the affine matrix. Therefore we have theta of shape (N, 2, 3) for 2D or (N, 3, 4) for 3D.

Input size is used to define grid of positions evenly spaced in the original 2D or 3D space, with dimensions ranging from -1 to 1. The output grid contains positions in the output space.

When align_corners=1, consider -1 and 1 to refer to the centers of the corner pixels (mark v in illustration).

v            v            v            v
|-------------------|------------------|
-1                  0                  1

When align_corners=0, consider -1 and 1 to refer to the outer edge of the corner pixels.

    v        v         v         v
|------------------|-------------------|
-1                 0                   1

Attributes

  • align_corners: if align_corners=1, consider -1 and 1 to refer to the centers of the corner pixels. if align_corners=0, consider -1 and 1 to refer to the outer edge the corner pixels. Default value is name: "align_corners" type: INT i: 0

Inputs

  • theta (heterogeneous)T1: input batch of affine matrices with shape (N, 2, 3) for 2D or (N, 3, 4) for 3D

  • size (heterogeneous)T2: the target output image size (N, C, H, W) for 2D or (N, C, D, H, W) for 3D

Outputs

  • grid (heterogeneous)T1: output tensor of shape (N, H, W, 2) of 2D sample coordinates or (N, D, H, W, 3) of 3D sample coordinates.

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double): Constrain grid types to float tensors.

  • T2 tensor(int64): Constrain size’s type to int64 tensors.

OnnxAnd#

class skl2onnx.algebra.onnx_ops.OnnxAnd(*args, **kwargs)#

Version

Onnx name: And

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxAnd_1#

class skl2onnx.algebra.onnx_ops.OnnxAnd_1(*args, **kwargs)#

Version

Onnx name: And

This version of the operator has been available since version 1.

Summary

Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Attributes

  • broadcast: Enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: Left input tensor for the logical operator.

  • B (heterogeneous)T: Right input tensor for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxAnd_7#

class skl2onnx.algebra.onnx_ops.OnnxAnd_7(*args, **kwargs)#

Version

Onnx name: And

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxArgMax#

class skl2onnx.algebra.onnx_ops.OnnxArgMax(*args, **kwargs)#

Version

Onnx name: ArgMax

This version of the operator has been available since version 13.

Summary

Computes the indices of the max elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the max is selected if the max appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is name: "select_last_index" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxArgMax_1#

class skl2onnx.algebra.onnx_ops.OnnxArgMax_1(*args, **kwargs)#

Version

Onnx name: ArgMax

This version of the operator has been available since version 1.

Summary

Computes the indices of the max elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxArgMax_11#

class skl2onnx.algebra.onnx_ops.OnnxArgMax_11(*args, **kwargs)#

Version

Onnx name: ArgMax

This version of the operator has been available since version 11.

Summary

Computes the indices of the max elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. The input tensor must not be empty. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxArgMax_12#

class skl2onnx.algebra.onnx_ops.OnnxArgMax_12(*args, **kwargs)#

Version

Onnx name: ArgMax

This version of the operator has been available since version 12.

Summary

Computes the indices of the max elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the max is selected if the max appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is name: "select_last_index" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxArgMax_13#

class skl2onnx.algebra.onnx_ops.OnnxArgMax_13(*args, **kwargs)#

Version

Onnx name: ArgMax

This version of the operator has been available since version 13.

Summary

Computes the indices of the max elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the max is selected if the max appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is name: "select_last_index" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxArgMin#

class skl2onnx.algebra.onnx_ops.OnnxArgMin(*args, **kwargs)#

Version

Onnx name: ArgMin

This version of the operator has been available since version 13.

Summary

Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the min is selected if the min appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is name: "select_last_index" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxArgMin_1#

class skl2onnx.algebra.onnx_ops.OnnxArgMin_1(*args, **kwargs)#

Version

Onnx name: ArgMin

This version of the operator has been available since version 1.

Summary

Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxArgMin_11#

class skl2onnx.algebra.onnx_ops.OnnxArgMin_11(*args, **kwargs)#

Version

Onnx name: ArgMin

This version of the operator has been available since version 11.

Summary

Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. The input tensor must not be empty. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxArgMin_12#

class skl2onnx.algebra.onnx_ops.OnnxArgMin_12(*args, **kwargs)#

Version

Onnx name: ArgMin

This version of the operator has been available since version 12.

Summary

Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the min is selected if the min appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is name: "select_last_index" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxArgMin_13#

class skl2onnx.algebra.onnx_ops.OnnxArgMin_13(*args, **kwargs)#

Version

Onnx name: ArgMin

This version of the operator has been available since version 13.

Summary

Computes the indices of the min elements of the input tensor’s element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the min is selected if the min appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Attributes

  • axis: The axis in which to compute the arg indices. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • select_last_index: Whether to select the last index or the first index if the {name} appears in multiple indices, default is False (first index). Default value is name: "select_last_index" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)tensor(int64): Reduced output tensor with integer data type.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxArrayFeatureExtractor#

class skl2onnx.algebra.onnx_ops.OnnxArrayFeatureExtractor(*args, **kwargs)#

Version

Onnx name: ArrayFeatureExtractor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Select elements of the input tensor based on the indices passed.

The indices are applied to the last axes of the tensor.

Inputs

  • X (heterogeneous)T: Data to be selected

  • Y (heterogeneous)tensor(int64): The indices, based on 0 as the first index of any dimension.

Outputs

  • Z (heterogeneous)T: Selected output data as an array

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32), tensor(string): The input must be a tensor of a numeric type or string. The output will be of the same tensor type.

OnnxArrayFeatureExtractor_1#

class skl2onnx.algebra.onnx_ops.OnnxArrayFeatureExtractor_1(*args, **kwargs)#

Version

Onnx name: ArrayFeatureExtractor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Select elements of the input tensor based on the indices passed.

The indices are applied to the last axes of the tensor.

Inputs

  • X (heterogeneous)T: Data to be selected

  • Y (heterogeneous)tensor(int64): The indices, based on 0 as the first index of any dimension.

Outputs

  • Z (heterogeneous)T: Selected output data as an array

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32), tensor(string): The input must be a tensor of a numeric type or string. The output will be of the same tensor type.

OnnxAsin#

class skl2onnx.algebra.onnx_ops.OnnxAsin(*args, **kwargs)#

Version

Onnx name: Asin

This version of the operator has been available since version 7.

Summary

Calculates the arcsine (inverse of sine) of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The arcsine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAsin_7#

class skl2onnx.algebra.onnx_ops.OnnxAsin_7(*args, **kwargs)#

Version

Onnx name: Asin

This version of the operator has been available since version 7.

Summary

Calculates the arcsine (inverse of sine) of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The arcsine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAsinh#

class skl2onnx.algebra.onnx_ops.OnnxAsinh(*args, **kwargs)#

Version

Onnx name: Asinh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic arcsine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic arcsine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAsinh_9#

class skl2onnx.algebra.onnx_ops.OnnxAsinh_9(*args, **kwargs)#

Version

Onnx name: Asinh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic arcsine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic arcsine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAtan#

class skl2onnx.algebra.onnx_ops.OnnxAtan(*args, **kwargs)#

Version

Onnx name: Atan

This version of the operator has been available since version 7.

Summary

Calculates the arctangent (inverse of tangent) of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The arctangent of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAtan_7#

class skl2onnx.algebra.onnx_ops.OnnxAtan_7(*args, **kwargs)#

Version

Onnx name: Atan

This version of the operator has been available since version 7.

Summary

Calculates the arctangent (inverse of tangent) of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The arctangent of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAtanh#

class skl2onnx.algebra.onnx_ops.OnnxAtanh(*args, **kwargs)#

Version

Onnx name: Atanh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic arctangent of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic arctangent values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAtanh_9#

class skl2onnx.algebra.onnx_ops.OnnxAtanh_9(*args, **kwargs)#

Version

Onnx name: Atanh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic arctangent of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic arctangent values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAveragePool#

class skl2onnx.algebra.onnx_ops.OnnxAveragePool(*args, **kwargs)#

Version

Onnx name: AveragePool

This version of the operator has been available since version 19.

Summary

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape is calculated differently depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d):

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled. pad_shape[i] is the sum of pads along axis i.

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D):

VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. Default value is name: "count_include_pad" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAveragePool_1#

class skl2onnx.algebra.onnx_ops.OnnxAveragePool_1(*args, **kwargs)#

Version

Onnx name: AveragePool

This version of the operator has been available since version 1.

Summary

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAveragePool_10#

class skl2onnx.algebra.onnx_ops.OnnxAveragePool_10(*args, **kwargs)#

Version

Onnx name: AveragePool

This version of the operator has been available since version 10.

Summary

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. Default value is name: "count_include_pad" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAveragePool_11#

class skl2onnx.algebra.onnx_ops.OnnxAveragePool_11(*args, **kwargs)#

Version

Onnx name: AveragePool

This version of the operator has been available since version 11.

Summary

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following: ` output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1) ` or ` output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1) ` if ceil_mode is enabled

` * pad_shape[i] is sum of pads along axis i `

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled: ` VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i]) SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) `

or when ceil_mode is disabled:

` VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i]) SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor(input_spatial_shape[i] / strides_spatial_shape[i]) `

And pad shape will be following if SAME_UPPER or SAME_LOWER: ` pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i] ` The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. Default value is name: "count_include_pad" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAveragePool_19#

class skl2onnx.algebra.onnx_ops.OnnxAveragePool_19(*args, **kwargs)#

Version

Onnx name: AveragePool

This version of the operator has been available since version 19.

Summary

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape is calculated differently depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d):

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled. pad_shape[i] is the sum of pads along axis i.

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D):

VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. Default value is name: "count_include_pad" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxAveragePool_7#

class skl2onnx.algebra.onnx_ops.OnnxAveragePool_7(*args, **kwargs)#

Version

Onnx name: AveragePool

This version of the operator has been available since version 7.

Summary

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. Default value is name: "count_include_pad" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxBatchNormalization#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 15.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, There are five required inputs ‘X’, ‘scale’, ‘B’, ‘input_mean’ and ‘input_var’. Note that ‘input_mean’ and ‘input_var’ are expected to be the estimated statistics in inference mode (training_mode=False, default), and the running statistics in training mode (training_mode=True). There are multiple cases for the number of outputs, which we list below:

  • Output case #1: Y, running_mean, running_var (training_mode=True)

  • Output case #2: Y (training_mode=False)

When training_mode=False, extra outputs are invalid. The outputs are updated as follows when training_mode=True:

running_mean = input_mean * momentum + current_mean * (1 - momentum)
running_var = input_var * momentum + current_var * (1 - momentum)

Y = (X - current_mean) / sqrt(current_var + epsilon) * scale + B

where:

current_mean = ReduceMean(X, axis=all_except_channel_index)
current_var =  ReduceVar(X, axis=all_except_channel_index)

Notice that ReduceVar refers to the population variance, and it equals to sum(sqrd(x_i - x_avg)) / N where N is the population size (this formula does not use sample size N - 1).

The computation of ReduceMean and ReduceVar uses float to avoid overflow for float16 inputs.

When training_mode=False:

Y = (X - input_mean) / sqrt(input_var + epsilon) * scale + B

For previous (depreciated) non-spatial cases, implementors are suggested to flatten the input shape to (N x C * D1 * D2 * … * Dn) before a BatchNormalization Op. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum). Default value is name: "momentum" type: FLOAT f: 0.9

  • training_mode: If set to true, it indicates BatchNormalization is being used for training, and outputs 1, 2, 3, and 4 would be populated. Default value is name: "training_mode" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size, C is the number of channels. Statistics are computed for every channel of C over N and D1 to Dn dimensions. For image data, input dimensions become (N x C x H x W). The op also accepts single dimension input of size N in which case C is assumed to be 1

  • scale (heterogeneous)T1: Scale tensor of shape (C).

  • B (heterogeneous)T1: Bias tensor of shape (C).

  • input_mean (heterogeneous)T2: running (training) or estimated (testing) mean tensor of shape (C).

  • input_var (heterogeneous)T2: running (training) or estimated (testing) variance tensor of shape (C).

Outputs

Between 1 and 3 outputs.

  • Y (heterogeneous)T: The output tensor of the same shape as X

  • running_mean (optional, heterogeneous)T2: The running mean after the BatchNormalization operator.

  • running_var (optional, heterogeneous)T2: The running variance after the BatchNormalization operator. This op uses the population size (N) for calculating variance, and not the sample size N-1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • T1 tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain scale and bias types to float tensors.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain mean and variance types to float tensors.

OnnxBatchNormalization_1#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization_1(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 1.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

Attributes

  • epsilon: The epsilon value to use to avoid division by zero, default is 1e-5f. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • is_test: If set to nonzero, run spatial batch normalization in test mode, default is 0. Default value is name: "is_test" type: INT i: 0

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum), default is 0.9f. Default value is name: "momentum" type: FLOAT f: 0.9

  • spatial: If true, compute the mean and variance across all spatial elements If false, compute the mean and variance across per feature.Default is 1. Default value is name: "spatial" type: INT i: 1

Inputs

  • X (heterogeneous)T: The input 4-dimensional tensor of shape NCHW.

  • scale (heterogeneous)T: The scale as a 1-dimensional tensor of size C to be applied to the output.

  • B (heterogeneous)T: The bias as a 1-dimensional tensor of size C to be applied to the output.

  • mean (heterogeneous)T: The running mean (training) or the estimated mean (testing) as a 1-dimensional tensor of size C.

  • var (heterogeneous)T: The running variance (training) or the estimated variance (testing) as a 1-dimensional tensor of size C.

Outputs

Between 1 and 5 outputs.

  • Y (heterogeneous)T: The output 4-dimensional tensor of the same shape as X.

  • mean (optional, heterogeneous)T: The running mean after the BatchNormalization operator. Must be in-place with the input mean. Should not be used for testing.

  • var (optional, heterogeneous)T: The running variance after the BatchNormalization operator. Must be in-place with the input var. Should not be used for testing.

  • saved_mean (optional, heterogeneous)T: Saved mean used during training to speed up gradient computation. Should not be used for testing.

  • saved_var (optional, heterogeneous)T: Saved variance used during training to speed up gradient computation. Should not be used for testing.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxBatchNormalization_14#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization_14(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 14.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, There are five required inputs ‘X’, ‘scale’, ‘B’, ‘input_mean’ and ‘input_var’. Note that ‘input_mean’ and ‘input_var’ are expected to be the estimated statistics in inference mode (training_mode=False, default), and the running statistics in training mode (training_mode=True). There are multiple cases for the number of outputs, which we list below:

Output case #1: Y, running_mean, running_var (training_mode=True) Output case #2: Y (training_mode=False)

When training_mode=False, extra outputs are invalid. The outputs are updated as follows when training_mode=True:

running_mean = input_mean * momentum + current_mean * (1 - momentum)
running_var = input_var * momentum + current_var * (1 - momentum)

Y = (X - current_mean) / sqrt(current_var + epsilon) * scale + B

where:

current_mean = ReduceMean(X, axis=all_except_channel_index)
current_var =  ReduceVar(X, axis=all_except_channel_index)

Notice that ReduceVar refers to the population variance, and it equals to
sum(sqrd(x_i - x_avg)) / N
where N is the population size (this formula does not use sample size N - 1).

When training_mode=False:

Y = (X - input_mean) / sqrt(input_var + epsilon) * scale + B

For previous (depreciated) non-spatial cases, implementors are suggested to flatten the input shape to (N x C * D1 * D2 * … * Dn) before a BatchNormalization Op. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum). Default value is name: "momentum" type: FLOAT f: 0.9

  • training_mode: If set to true, it indicates BatchNormalization is being used for training, and outputs 1, 2, 3, and 4 would be populated. Default value is name: "training_mode" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size, C is the number of channels. Statistics are computed for every channel of C over N and D1 to Dn dimensions. For image data, input dimensions become (N x C x H x W). The op also accepts single dimension input of size N in which case C is assumed to be 1

  • scale (heterogeneous)T: Scale tensor of shape (C).

  • B (heterogeneous)T: Bias tensor of shape (C).

  • input_mean (heterogeneous)U: running (training) or estimated (testing) mean tensor of shape (C).

  • input_var (heterogeneous)U: running (training) or estimated (testing) variance tensor of shape (C).

Outputs

Between 1 and 3 outputs.

  • Y (heterogeneous)T: The output tensor of the same shape as X

  • running_mean (optional, heterogeneous)U: The running mean after the BatchNormalization operator.

  • running_var (optional, heterogeneous)U: The running variance after the BatchNormalization operator. This op uses the population size (N) for calculating variance, and not the sample size N-1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • U tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain mean and variance types to float tensors. It allows all float type for U.

OnnxBatchNormalization_15#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization_15(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 15.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, There are five required inputs ‘X’, ‘scale’, ‘B’, ‘input_mean’ and ‘input_var’. Note that ‘input_mean’ and ‘input_var’ are expected to be the estimated statistics in inference mode (training_mode=False, default), and the running statistics in training mode (training_mode=True). There are multiple cases for the number of outputs, which we list below:

  • Output case #1: Y, running_mean, running_var (training_mode=True)

  • Output case #2: Y (training_mode=False)

When training_mode=False, extra outputs are invalid. The outputs are updated as follows when training_mode=True:

running_mean = input_mean * momentum + current_mean * (1 - momentum)
running_var = input_var * momentum + current_var * (1 - momentum)

Y = (X - current_mean) / sqrt(current_var + epsilon) * scale + B

where:

current_mean = ReduceMean(X, axis=all_except_channel_index)
current_var =  ReduceVar(X, axis=all_except_channel_index)

Notice that ReduceVar refers to the population variance, and it equals to sum(sqrd(x_i - x_avg)) / N where N is the population size (this formula does not use sample size N - 1).

The computation of ReduceMean and ReduceVar uses float to avoid overflow for float16 inputs.

When training_mode=False:

Y = (X - input_mean) / sqrt(input_var + epsilon) * scale + B

For previous (depreciated) non-spatial cases, implementors are suggested to flatten the input shape to (N x C * D1 * D2 * … * Dn) before a BatchNormalization Op. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum). Default value is name: "momentum" type: FLOAT f: 0.9

  • training_mode: If set to true, it indicates BatchNormalization is being used for training, and outputs 1, 2, 3, and 4 would be populated. Default value is name: "training_mode" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size, C is the number of channels. Statistics are computed for every channel of C over N and D1 to Dn dimensions. For image data, input dimensions become (N x C x H x W). The op also accepts single dimension input of size N in which case C is assumed to be 1

  • scale (heterogeneous)T1: Scale tensor of shape (C).

  • B (heterogeneous)T1: Bias tensor of shape (C).

  • input_mean (heterogeneous)T2: running (training) or estimated (testing) mean tensor of shape (C).

  • input_var (heterogeneous)T2: running (training) or estimated (testing) variance tensor of shape (C).

Outputs

Between 1 and 3 outputs.

  • Y (heterogeneous)T: The output tensor of the same shape as X

  • running_mean (optional, heterogeneous)T2: The running mean after the BatchNormalization operator.

  • running_var (optional, heterogeneous)T2: The running variance after the BatchNormalization operator. This op uses the population size (N) for calculating variance, and not the sample size N-1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • T1 tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain scale and bias types to float tensors.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain mean and variance types to float tensors.

OnnxBatchNormalization_6#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization_6(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 6.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

Attributes

  • epsilon: The epsilon value to use to avoid division by zero, default is 1e-5f. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • is_test: If set to nonzero, run spatial batch normalization in test mode, default is 0. Default value is name: "is_test" type: INT i: 0

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum), default is 0.9f. Default value is name: "momentum" type: FLOAT f: 0.9

  • spatial: If true, compute the mean and variance across all spatial elements If false, compute the mean and variance across per feature.Default is 1. Default value is name: "spatial" type: INT i: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

  • scale (heterogeneous)T: The scale as a 1-dimensional tensor of size C to be applied to the output.

  • B (heterogeneous)T: The bias as a 1-dimensional tensor of size C to be applied to the output.

  • mean (heterogeneous)T: The running mean (training) or the estimated mean (testing) as a 1-dimensional tensor of size C.

  • var (heterogeneous)T: The running variance (training) or the estimated variance (testing) as a 1-dimensional tensor of size C.

Outputs

Between 1 and 5 outputs.

  • Y (heterogeneous)T: The output tensor of the same shape as X.

  • mean (optional, heterogeneous)T: The running mean after the BatchNormalization operator. Must be in-place with the input mean. Should not be used for testing.

  • var (optional, heterogeneous)T: The running variance after the BatchNormalization operator. Must be in-place with the input var. Should not be used for testing.

  • saved_mean (optional, heterogeneous)T: Saved mean used during training to speed up gradient computation. Should not be used for testing.

  • saved_var (optional, heterogeneous)T: Saved variance used during training to speed up gradient computation. Should not be used for testing.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxBatchNormalization_7#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization_7(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 7.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum). Default value is name: "momentum" type: FLOAT f: 0.9

  • spatial: If true, compute the mean and variance across per activation. If false, compute the mean and variance across per feature over each mini-batch. Default value is name: "spatial" type: INT i: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

  • scale (heterogeneous)T: If spatial is true, the dimension of scale is (C). If spatial is false, the dimensions of scale are (C x D1 x … x Dn)

  • B (heterogeneous)T: If spatial is true, the dimension of bias is (C). If spatial is false, the dimensions of bias are (C x D1 x … x Dn)

  • mean (heterogeneous)T: If spatial is true, the dimension of the running mean (training) or the estimated mean (testing) is (C). If spatial is false, the dimensions of the running mean (training) or the estimated mean (testing) are (C x D1 x … x Dn).

  • var (heterogeneous)T: If spatial is true, the dimension of the running variance(training) or the estimated variance (testing) is (C). If spatial is false, the dimensions of the running variance(training) or the estimated variance (testing) are (C x D1 x … x Dn).

Outputs

Between 1 and 5 outputs.

  • Y (heterogeneous)T: The output tensor of the same shape as X

  • mean (optional, heterogeneous)T: The running mean after the BatchNormalization operator.

  • var (optional, heterogeneous)T: The running variance after the BatchNormalization operator.

  • saved_mean (optional, heterogeneous)T: Saved mean used during training to speed up gradient computation.

  • saved_var (optional, heterogeneous)T: Saved variance used during training to speed up gradient computation.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxBatchNormalization_9#

class skl2onnx.algebra.onnx_ops.OnnxBatchNormalization_9(*args, **kwargs)#

Version

Onnx name: BatchNormalization

This version of the operator has been available since version 9.

Summary

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

For previous (depreciated) non-spatial cases, implementors are suggested to flatten the input shape to (N x C*D1*D2 ..*Dn) before a BatchNormalization Op. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • momentum: Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum). Default value is name: "momentum" type: FLOAT f: 0.9

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size, C is the number of channels. Statistics are computed for every channel of C over N and D1 to Dn dimensions. For image data, input dimensions become (N x C x H x W). The op also accepts single dimension input of size N in which case C is assumed to be 1

  • scale (heterogeneous)T: Scale tensor of shape (C).

  • B (heterogeneous)T: Bias tensor of shape (C).

  • mean (heterogeneous)T: running (training) or estimated (testing) mean tensor of shape (C).

  • var (heterogeneous)T: running (training) or estimated (testing) variance tensor of shape (C).

Outputs

Between 1 and 5 outputs.

  • Y (heterogeneous)T: The output tensor of the same shape as X

  • mean (optional, heterogeneous)T: The running mean after the BatchNormalization operator.

  • var (optional, heterogeneous)T: The running variance after the BatchNormalization operator.

  • saved_mean (optional, heterogeneous)T: Saved mean used during training to speed up gradient computation.

  • saved_var (optional, heterogeneous)T: Saved variance used during training to speed up gradient computation.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxBernoulli#

class skl2onnx.algebra.onnx_ops.OnnxBernoulli(*args, **kwargs)#

Version

Onnx name: Bernoulli

This version of the operator has been available since version 15.

Summary

Draws binary random numbers (0 or 1) from a Bernoulli distribution. The input tensor should be a tensor containing probabilities p (a value in the range [0,1]) to be used for drawing the binary random number, where an output of 1 is produced with probability p and an output of 0 is produced with probability (1-p).

This operator is non-deterministic and may not produce the same values in different implementations (even if a seed is specified).

Attributes

Inputs

  • input (heterogeneous)T1: All values in input have to be in the range:[0, 1].

Outputs

  • output (heterogeneous)T2: The returned output tensor only has values 0 or 1, same shape as input tensor.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bool): Constrain output types to all numeric tensors and bool tensors.

OnnxBernoulli_15#

class skl2onnx.algebra.onnx_ops.OnnxBernoulli_15(*args, **kwargs)#

Version

Onnx name: Bernoulli

This version of the operator has been available since version 15.

Summary

Draws binary random numbers (0 or 1) from a Bernoulli distribution. The input tensor should be a tensor containing probabilities p (a value in the range [0,1]) to be used for drawing the binary random number, where an output of 1 is produced with probability p and an output of 0 is produced with probability (1-p).

This operator is non-deterministic and may not produce the same values in different implementations (even if a seed is specified).

Attributes

Inputs

  • input (heterogeneous)T1: All values in input have to be in the range:[0, 1].

Outputs

  • output (heterogeneous)T2: The returned output tensor only has values 0 or 1, same shape as input tensor.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bool): Constrain output types to all numeric tensors and bool tensors.

OnnxBinarizer#

class skl2onnx.algebra.onnx_ops.OnnxBinarizer(*args, **kwargs)#

Version

Onnx name: Binarizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Maps the values of the input tensor to either 0 or 1, element-wise, based on the outcome of a comparison against a threshold value.

Attributes

  • threshold: Values greater than this are mapped to 1, others to 0. Default value is name: "threshold" type: FLOAT f: 0

Inputs

  • X (heterogeneous)T: Data to be binarized

Outputs

  • Y (heterogeneous)T: Binarized output data

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type. The output will be of the same tensor type.

OnnxBinarizer_1#

class skl2onnx.algebra.onnx_ops.OnnxBinarizer_1(*args, **kwargs)#

Version

Onnx name: Binarizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Maps the values of the input tensor to either 0 or 1, element-wise, based on the outcome of a comparison against a threshold value.

Attributes

  • threshold: Values greater than this are mapped to 1, others to 0. Default value is name: "threshold" type: FLOAT f: 0

Inputs

  • X (heterogeneous)T: Data to be binarized

Outputs

  • Y (heterogeneous)T: Binarized output data

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type. The output will be of the same tensor type.

OnnxBitShift#

class skl2onnx.algebra.onnx_ops.OnnxBitShift(*args, **kwargs)#

Version

Onnx name: BitShift

This version of the operator has been available since version 11.

Summary

Bitwise shift operator performs element-wise operation. For each input element, if the attribute “direction” is “RIGHT”, this operator moves its binary representation toward the right side so that the input value is effectively decreased. If the attribute “direction” is “LEFT”, bits of binary representation moves toward the left side, which results the increase of its actual value. The input X is the tensor to be shifted and another input Y specifies the amounts of shifting. For example, if “direction” is “Right”, X is [1, 4], and S is [1, 1], the corresponding output Z would be [0, 2]. If “direction” is “LEFT” with X=[1, 2] and S=[1, 2], the corresponding output Y would be [2, 8].

Because this operator supports Numpy-style broadcasting, X’s and Y’s shapes are not necessarily identical. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Attributes

Inputs

  • X (heterogeneous)T: First operand, input to be shifted.

  • Y (heterogeneous)T: Second operand, amounts of shift.

Outputs

  • Z (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64): Constrain input and output types to integer tensors.

OnnxBitShift_11#

class skl2onnx.algebra.onnx_ops.OnnxBitShift_11(*args, **kwargs)#

Version

Onnx name: BitShift

This version of the operator has been available since version 11.

Summary

Bitwise shift operator performs element-wise operation. For each input element, if the attribute “direction” is “RIGHT”, this operator moves its binary representation toward the right side so that the input value is effectively decreased. If the attribute “direction” is “LEFT”, bits of binary representation moves toward the left side, which results the increase of its actual value. The input X is the tensor to be shifted and another input Y specifies the amounts of shifting. For example, if “direction” is “Right”, X is [1, 4], and S is [1, 1], the corresponding output Z would be [0, 2]. If “direction” is “LEFT” with X=[1, 2] and S=[1, 2], the corresponding output Y would be [2, 8].

Because this operator supports Numpy-style broadcasting, X’s and Y’s shapes are not necessarily identical. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Attributes

Inputs

  • X (heterogeneous)T: First operand, input to be shifted.

  • Y (heterogeneous)T: Second operand, amounts of shift.

Outputs

  • Z (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64): Constrain input and output types to integer tensors.

OnnxBitwiseAnd#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseAnd(*args, **kwargs)#

Version

Onnx name: BitwiseAnd

This version of the operator has been available since version 18.

Summary

Returns the tensor resulting from performing the bitwise and operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the bitwise operator.

  • B (heterogeneous)T: Second input operand for the bitwise operator.

Outputs

  • C (heterogeneous)T: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input to integer tensors.

OnnxBitwiseAnd_18#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseAnd_18(*args, **kwargs)#

Version

Onnx name: BitwiseAnd

This version of the operator has been available since version 18.

Summary

Returns the tensor resulting from performing the bitwise and operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the bitwise operator.

  • B (heterogeneous)T: Second input operand for the bitwise operator.

Outputs

  • C (heterogeneous)T: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input to integer tensors.

OnnxBitwiseNot#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseNot(*args, **kwargs)#

Version

Onnx name: BitwiseNot

This version of the operator has been available since version 18.

Summary

Returns the bitwise not of the input tensor element-wise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input/output to integer tensors.

OnnxBitwiseNot_18#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseNot_18(*args, **kwargs)#

Version

Onnx name: BitwiseNot

This version of the operator has been available since version 18.

Summary

Returns the bitwise not of the input tensor element-wise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input/output to integer tensors.

OnnxBitwiseOr#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseOr(*args, **kwargs)#

Version

Onnx name: BitwiseOr

This version of the operator has been available since version 18.

Summary

Returns the tensor resulting from performing the bitwise or operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the bitwise operator.

  • B (heterogeneous)T: Second input operand for the bitwise operator.

Outputs

  • C (heterogeneous)T: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input to integer tensors.

OnnxBitwiseOr_18#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseOr_18(*args, **kwargs)#

Version

Onnx name: BitwiseOr

This version of the operator has been available since version 18.

Summary

Returns the tensor resulting from performing the bitwise or operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the bitwise operator.

  • B (heterogeneous)T: Second input operand for the bitwise operator.

Outputs

  • C (heterogeneous)T: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input to integer tensors.

OnnxBitwiseXor#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseXor(*args, **kwargs)#

Version

Onnx name: BitwiseXor

This version of the operator has been available since version 18.

Summary

Returns the tensor resulting from performing the bitwise xor operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the bitwise operator.

  • B (heterogeneous)T: Second input operand for the bitwise operator.

Outputs

  • C (heterogeneous)T: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input to integer tensors.

OnnxBitwiseXor_18#

class skl2onnx.algebra.onnx_ops.OnnxBitwiseXor_18(*args, **kwargs)#

Version

Onnx name: BitwiseXor

This version of the operator has been available since version 18.

Summary

Returns the tensor resulting from performing the bitwise xor operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the bitwise operator.

  • B (heterogeneous)T: Second input operand for the bitwise operator.

Outputs

  • C (heterogeneous)T: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64): Constrain input to integer tensors.

OnnxBlackmanWindow#

class skl2onnx.algebra.onnx_ops.OnnxBlackmanWindow(*args, **kwargs)#

Version

Onnx name: BlackmanWindow

This version of the operator has been available since version 17.

Summary

Generates a Blackman window as described in the paper https://ieeexplore.ieee.org/document/1455106.

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T2. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

  • periodic: If 1, returns a window to be used as periodic function. If 0, return a symmetric window. When ‘periodic’ is specified, hann computes a window of length size + 1 and returns the first size points. The default value is 1. Default value is name: "periodic" type: INT i: 1

Inputs

  • size (heterogeneous)T1: A scalar value indicating the length of the window.

Outputs

  • output (heterogeneous)T2: A Blackman window with length: size. The output has the shape: [size].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain the input size to int64_t.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain output types to numeric tensors.

OnnxBlackmanWindow_17#

class skl2onnx.algebra.onnx_ops.OnnxBlackmanWindow_17(*args, **kwargs)#

Version

Onnx name: BlackmanWindow

This version of the operator has been available since version 17.

Summary

Generates a Blackman window as described in the paper https://ieeexplore.ieee.org/document/1455106.

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T2. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

  • periodic: If 1, returns a window to be used as periodic function. If 0, return a symmetric window. When ‘periodic’ is specified, hann computes a window of length size + 1 and returns the first size points. The default value is 1. Default value is name: "periodic" type: INT i: 1

Inputs

  • size (heterogeneous)T1: A scalar value indicating the length of the window.

Outputs

  • output (heterogeneous)T2: A Blackman window with length: size. The output has the shape: [size].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain the input size to int64_t.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain output types to numeric tensors.

OnnxCast#

class skl2onnx.algebra.onnx_ops.OnnxCast(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 21.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Casting from string tensor in plain (e.g., “3.14” and “1000”) and scientific numeric representations (e.g., “1e-5” and “1E8”) to float types is supported. For example, converting string “100.5” to an integer may yield result 100. There are some string literals reserved for special floating-point values; “+INF” (and “INF”), “-INF”, and “NaN” are positive infinity, negative infinity, and not-a-number, respectively. Any string which can exactly match “+INF” in a case-insensitive way would be mapped to positive infinite. Similarly, this case-insensitive rule is applied to “INF” and “NaN”. When casting from numeric tensors to string tensors, plain floating-point representation (such as “314.15926”) would be used. Converting non-numerical-literal string such as “Hello World!” is an undefined behavior. Cases of converting string representing floating-point arithmetic value, such as “2.718”, to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed. User must be aware of precision loss and value change caused by range difference between two types. For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting an integer 36 to Boolean may produce 1 because we truncate bits which can’t be stored in the targeted type.

In more detail, the conversion among numerical types should follow these rules if the destination type is not a float 8 type.

  • Casting from floating point to: * floating point: +/- infinity if OOR (out of range). * fixed point: undefined if OOR. * bool: +/- 0.0 to False; all else to True.

  • Casting from fixed point to: * floating point: +/- infinity if OOR. (+ infinity in the case of uint) * fixed point: when OOR, discard higher bits and reinterpret (with respect to two’s complement representation for

    signed types). For example, 200 (int16) -> -56 (int8).

    • bool: zero to False; nonzero to True.

  • Casting from bool to: * floating point: {1.0, 0.0}. * fixed point: {1, 0}. * bool: no change.

Float 8 type were introduced to speed up the training of deep models. By default the conversion of a float x obeys to the following rules. [x] means the value rounded to the target mantissa width.

x | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |

|------|—-|----|—-|----| | 0 | 0 | 0 | 0 | 0 | |-0 | -0 | 0 | -0 | 0 | | NaN | NaN | NaN | NaN | NaN | | +/- Inf | +/- FLT_MAX | NaN | FLT_MAX | NaN | | [x] > FLT_MAX | FLT_MAX | FLT_MAX | FLT_MAX | FLT_MAX | | [x] < -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | | else | RNE | RNE | RNE | RNE |

The behavior changes if the parameter ‘saturate’ is set to False. The rules then become:

x | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |

|------|—-|----|—-|----| | 0 | 0 | 0 | 0 | 0 | |-0 | -0 | 0 | -0 | 0 | | NaN | NaN | NaN | NaN | NaN | | +/- Inf | NaN | NaN | +/- Inf | NaN | | [x] > FLT_MAX | NaN | NaN | Inf | NaN | | [x] < -FLT_MAX | NaN | NaN | -Inf | NaN | | else | RNE | RNE | RNE | RNE |

Attributes

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. All cases are fully described in two tables inserted in the operator description. Default value is name: "saturate" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain output types. Casting to complex is not supported.

OnnxCastLike#

class skl2onnx.algebra.onnx_ops.OnnxCastLike(*args, **kwargs)#

Version

Onnx name: CastLike

This version of the operator has been available since version 21.

Summary

The operator casts the elements of a given input tensor (the first input) to the same data type as the elements of the second input tensor. See documentation of the Cast operator for further details.

Attributes

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. Please refer to operator Cast description for further details. Default value is name: "saturate" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

  • target_type (heterogeneous)T2: The (first) input tensor will be cast to produce a tensor of the same type as this (second input) tensor.

Outputs

  • output (heterogeneous)T2: Output tensor produced by casting the first input tensor to have the same type as the second input tensor.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain output types. Casting to complex is not supported.

OnnxCastLike_15#

class skl2onnx.algebra.onnx_ops.OnnxCastLike_15(*args, **kwargs)#

Version

Onnx name: CastLike

This version of the operator has been available since version 15.

Summary

The operator casts the elements of a given input tensor (the first input) to the same data type as the elements of the second input tensor. See documentation of the Cast operator for further details.

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

  • target_type (heterogeneous)T2: The (first) input tensor will be cast to produce a tensor of the same type as this (second input) tensor.

Outputs

  • output (heterogeneous)T2: Output tensor produced by casting the first input tensor to have the same type as the second input tensor.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16): Constrain output types. Casting to complex is not supported.

OnnxCastLike_19#

class skl2onnx.algebra.onnx_ops.OnnxCastLike_19(*args, **kwargs)#

Version

Onnx name: CastLike

This version of the operator has been available since version 19.

Summary

The operator casts the elements of a given input tensor (the first input) to the same data type as the elements of the second input tensor. See documentation of the Cast operator for further details.

Attributes

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. Please refer to operator Cast description for further details. Default value is name: "saturate" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

  • target_type (heterogeneous)T2: The (first) input tensor will be cast to produce a tensor of the same type as this (second input) tensor.

Outputs

  • output (heterogeneous)T2: Output tensor produced by casting the first input tensor to have the same type as the second input tensor.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain output types. Casting to complex is not supported.

OnnxCastLike_21#

class skl2onnx.algebra.onnx_ops.OnnxCastLike_21(*args, **kwargs)#

Version

Onnx name: CastLike

This version of the operator has been available since version 21.

Summary

The operator casts the elements of a given input tensor (the first input) to the same data type as the elements of the second input tensor. See documentation of the Cast operator for further details.

Attributes

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. Please refer to operator Cast description for further details. Default value is name: "saturate" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

  • target_type (heterogeneous)T2: The (first) input tensor will be cast to produce a tensor of the same type as this (second input) tensor.

Outputs

  • output (heterogeneous)T2: Output tensor produced by casting the first input tensor to have the same type as the second input tensor.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain output types. Casting to complex is not supported.

OnnxCastMap#

class skl2onnx.algebra.onnx_ops.OnnxCastMap(*args, **kwargs)#

Version

Onnx name: CastMap

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Converts a map to a tensor. The map key must be an int64 and the values will be ordered in ascending order based on this key. The operator supports dense packing or sparse packing. If using sparse packing, the key cannot exceed the max_map-1 value.

Attributes

  • cast_to: A string indicating the desired element type of the output tensor, one of ‘TO_FLOAT’, ‘TO_STRING’, ‘TO_INT64’. Default value is name: "cast_to" type: STRING s: "TO_FLOAT"

  • map_form: Indicates whether to only output as many values as are in the input (dense), or position the input based on using the key of the map as the index of the output (sparse).<br>One of ‘DENSE’, ‘SPARSE’. Default value is name: "map_form" type: STRING s: "DENSE"

  • max_map: If the value of map_form is ‘SPARSE,’ this attribute indicates the total length of the output tensor. Default value is name: "max_map" type: INT i: 1

Inputs

  • X (heterogeneous)T1: The input map that is to be cast to a tensor

Outputs

  • Y (heterogeneous)T2: A tensor representing the same data as the input map, ordered by their keys

Type Constraints

  • T1 map(int64, string), map(int64, float): The input must be an integer map to either string or float.

  • T2 tensor(string), tensor(float), tensor(int64): The output is a 1-D tensor of string, float, or integer.

OnnxCastMap_1#

class skl2onnx.algebra.onnx_ops.OnnxCastMap_1(*args, **kwargs)#

Version

Onnx name: CastMap

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Converts a map to a tensor. The map key must be an int64 and the values will be ordered in ascending order based on this key. The operator supports dense packing or sparse packing. If using sparse packing, the key cannot exceed the max_map-1 value.

Attributes

  • cast_to: A string indicating the desired element type of the output tensor, one of ‘TO_FLOAT’, ‘TO_STRING’, ‘TO_INT64’. Default value is name: "cast_to" type: STRING s: "TO_FLOAT"

  • map_form: Indicates whether to only output as many values as are in the input (dense), or position the input based on using the key of the map as the index of the output (sparse).<br>One of ‘DENSE’, ‘SPARSE’. Default value is name: "map_form" type: STRING s: "DENSE"

  • max_map: If the value of map_form is ‘SPARSE,’ this attribute indicates the total length of the output tensor. Default value is name: "max_map" type: INT i: 1

Inputs

  • X (heterogeneous)T1: The input map that is to be cast to a tensor

Outputs

  • Y (heterogeneous)T2: A tensor representing the same data as the input map, ordered by their keys

Type Constraints

  • T1 map(int64, string), map(int64, float): The input must be an integer map to either string or float.

  • T2 tensor(string), tensor(float), tensor(int64): The output is a 1-D tensor of string, float, or integer.

OnnxCast_1#

class skl2onnx.algebra.onnx_ops.OnnxCast_1(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 1.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message. NOTE: Casting to and from strings is not supported yet.

Attributes

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain input types. Casting from strings and complex are not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain output types. Casting to strings and complex are not supported.

OnnxCast_13#

class skl2onnx.algebra.onnx_ops.OnnxCast_13(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 13.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Casting from string tensor in plain (e.g., “3.14” and “1000”) and scientific numeric representations (e.g., “1e-5” and “1E8”) to float types is supported. For example, converting string “100.5” to an integer may yield result 100. There are some string literals reserved for special floating-point values; “+INF” (and “INF”), “-INF”, and “NaN” are positive infinity, negative infinity, and not-a-number, respectively. Any string which can exactly match “+INF” in a case-insensitive way would be mapped to positive infinite. Similarly, this case-insensitive rule is applied to “INF” and “NaN”. When casting from numeric tensors to string tensors, plain floating-point representation (such as “314.15926”) would be used. Converting non-numerical-literal string such as “Hello World!” is an undefined behavior. Cases of converting string representing floating-point arithmetic value, such as “2.718”, to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed. User must be aware of precision loss and value change caused by range difference between two types. For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting an integer 36 to Boolean may produce 1 because we truncate bits which can’t be stored in the targeted type.

In more detail, the conversion among numerical types should follow these rules:

  • Casting from floating point to: * floating point: +/- infinity if OOR (out of range). * fixed point: undefined if OOR. * bool: +/- 0.0 to False; all else to True.

  • Casting from fixed point to: * floating point: +/- infinity if OOR. (+ infinity in the case of uint) * fixed point: when OOR, discard higher bits and reinterpret (with respect to two’s complement representation for

    signed types). For example, 200 (int16) -> -56 (int8).

    • bool: zero to False; nonzero to True.

  • Casting from bool to: * floating point: {1.0, 0.0}. * fixed point: {1, 0}. * bool: no change.

Attributes

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16): Constrain output types. Casting to complex is not supported.

OnnxCast_19#

class skl2onnx.algebra.onnx_ops.OnnxCast_19(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 19.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Casting from string tensor in plain (e.g., “3.14” and “1000”) and scientific numeric representations (e.g., “1e-5” and “1E8”) to float types is supported. For example, converting string “100.5” to an integer may yield result 100. There are some string literals reserved for special floating-point values; “+INF” (and “INF”), “-INF”, and “NaN” are positive infinity, negative infinity, and not-a-number, respectively. Any string which can exactly match “+INF” in a case-insensitive way would be mapped to positive infinite. Similarly, this case-insensitive rule is applied to “INF” and “NaN”. When casting from numeric tensors to string tensors, plain floating-point representation (such as “314.15926”) would be used. Converting non-numerical-literal string such as “Hello World!” is an undefined behavior. Cases of converting string representing floating-point arithmetic value, such as “2.718”, to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed. User must be aware of precision loss and value change caused by range difference between two types. For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting an integer 36 to Boolean may produce 1 because we truncate bits which can’t be stored in the targeted type.

In more detail, the conversion among numerical types should follow these rules if the destination type is not a float 8 type.

  • Casting from floating point to: * floating point: +/- infinity if OOR (out of range). * fixed point: undefined if OOR. * bool: +/- 0.0 to False; all else to True.

  • Casting from fixed point to: * floating point: +/- infinity if OOR. (+ infinity in the case of uint) * fixed point: when OOR, discard higher bits and reinterpret (with respect to two’s complement representation for

    signed types). For example, 200 (int16) -> -56 (int8).

    • bool: zero to False; nonzero to True.

  • Casting from bool to: * floating point: {1.0, 0.0}. * fixed point: {1, 0}. * bool: no change.

Float 8 type were introduced to speed up the training of deep models. By default the conversion of a float x obeys to the following rules. [x] means the value rounded to the target mantissa width.

x | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |

|------|—-|----|—-|----| | 0 | 0 | 0 | 0 | 0 | |-0 | -0 | 0 | -0 | 0 | | NaN | NaN | NaN | NaN | NaN | | +/- Inf | +/- FLT_MAX | NaN | FLT_MAX | NaN | | [x] > FLT_MAX | FLT_MAX | FLT_MAX | FLT_MAX | FLT_MAX | | [x] < -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | | else | RNE | RNE | RNE | RNE |

The behavior changes if the parameter ‘saturate’ is set to False. The rules then become:

x | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |

|------|—-|----|—-|----| | 0 | 0 | 0 | 0 | 0 | |-0 | -0 | 0 | -0 | 0 | | NaN | NaN | NaN | NaN | NaN | | +/- Inf | NaN | NaN | +/- Inf | NaN | | [x] > FLT_MAX | NaN | NaN | Inf | NaN | | [x] < -FLT_MAX | NaN | NaN | -Inf | NaN | | else | RNE | RNE | RNE | RNE |

Attributes

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. All cases are fully described in two tables inserted in the operator description. Default value is name: "saturate" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain output types. Casting to complex is not supported.

OnnxCast_21#

class skl2onnx.algebra.onnx_ops.OnnxCast_21(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 21.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Casting from string tensor in plain (e.g., “3.14” and “1000”) and scientific numeric representations (e.g., “1e-5” and “1E8”) to float types is supported. For example, converting string “100.5” to an integer may yield result 100. There are some string literals reserved for special floating-point values; “+INF” (and “INF”), “-INF”, and “NaN” are positive infinity, negative infinity, and not-a-number, respectively. Any string which can exactly match “+INF” in a case-insensitive way would be mapped to positive infinite. Similarly, this case-insensitive rule is applied to “INF” and “NaN”. When casting from numeric tensors to string tensors, plain floating-point representation (such as “314.15926”) would be used. Converting non-numerical-literal string such as “Hello World!” is an undefined behavior. Cases of converting string representing floating-point arithmetic value, such as “2.718”, to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed. User must be aware of precision loss and value change caused by range difference between two types. For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting an integer 36 to Boolean may produce 1 because we truncate bits which can’t be stored in the targeted type.

In more detail, the conversion among numerical types should follow these rules if the destination type is not a float 8 type.

  • Casting from floating point to: * floating point: +/- infinity if OOR (out of range). * fixed point: undefined if OOR. * bool: +/- 0.0 to False; all else to True.

  • Casting from fixed point to: * floating point: +/- infinity if OOR. (+ infinity in the case of uint) * fixed point: when OOR, discard higher bits and reinterpret (with respect to two’s complement representation for

    signed types). For example, 200 (int16) -> -56 (int8).

    • bool: zero to False; nonzero to True.

  • Casting from bool to: * floating point: {1.0, 0.0}. * fixed point: {1, 0}. * bool: no change.

Float 8 type were introduced to speed up the training of deep models. By default the conversion of a float x obeys to the following rules. [x] means the value rounded to the target mantissa width.

x | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |

|------|—-|----|—-|----| | 0 | 0 | 0 | 0 | 0 | |-0 | -0 | 0 | -0 | 0 | | NaN | NaN | NaN | NaN | NaN | | +/- Inf | +/- FLT_MAX | NaN | FLT_MAX | NaN | | [x] > FLT_MAX | FLT_MAX | FLT_MAX | FLT_MAX | FLT_MAX | | [x] < -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | | else | RNE | RNE | RNE | RNE |

The behavior changes if the parameter ‘saturate’ is set to False. The rules then become:

x | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |

|------|—-|----|—-|----| | 0 | 0 | 0 | 0 | 0 | |-0 | -0 | 0 | -0 | 0 | | NaN | NaN | NaN | NaN | NaN | | +/- Inf | NaN | NaN | +/- Inf | NaN | | [x] > FLT_MAX | NaN | NaN | Inf | NaN | | [x] < -FLT_MAX | NaN | NaN | -Inf | NaN | | else | RNE | RNE | RNE | RNE |

Attributes

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. All cases are fully described in two tables inserted in the operator description. Default value is name: "saturate" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain output types. Casting to complex is not supported.

OnnxCast_6#

class skl2onnx.algebra.onnx_ops.OnnxCast_6(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 6.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message. NOTE: Casting to and from strings is not supported yet.

Attributes

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain input types. Casting from strings and complex are not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain output types. Casting to strings and complex are not supported.

OnnxCast_9#

class skl2onnx.algebra.onnx_ops.OnnxCast_9(*args, **kwargs)#

Version

Onnx name: Cast

This version of the operator has been available since version 9.

Summary

The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Casting from string tensor in plain (e.g., “3.14” and “1000”) and scientific numeric representations (e.g., “1e-5” and “1E8”) to float types is supported. For example, converting string “100.5” to an integer may yield result 100. There are some string literals reserved for special floating-point values; “+INF” (and “INF”), “-INF”, and “NaN” are positive infinity, negative infinity, and not-a-number, respectively. Any string which can exactly match “+INF” in a case-insensitive way would be mapped to positive infinite. Similarly, this case-insensitive rule is applied to “INF” and “NaN”. When casting from numeric tensors to string tensors, plain floating-point representation (such as “314.15926”) would be used. Converting non-numerical-literal string such as “Hello World!” is an undefined behavior. Cases of converting string representing floating-point arithmetic value, such as “2.718”, to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed. User must be aware of precision loss and value change caused by range difference between two types. For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting an integer 36 to Boolean may produce 1 because we truncate bits which can’t be stored in the targeted type.

Attributes

Inputs

  • input (heterogeneous)T1: Input tensor to be cast.

Outputs

  • output (heterogeneous)T2: Output tensor with the same shape as input with type specified by the ‘to’ argument

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string): Constrain input types. Casting from complex is not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string): Constrain output types. Casting to complex is not supported.

OnnxCategoryMapper#

class skl2onnx.algebra.onnx_ops.OnnxCategoryMapper(*args, **kwargs)#

Version

Onnx name: CategoryMapper

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Converts strings to integers and vice versa.

Two sequences of equal length are used to map between integers and strings, with strings and integers at the same index detailing the mapping.

Each operator converts either integers to strings or strings to integers, depending on which default value attribute is provided. Only one default value attribute should be defined.

If the string default value is set, it will convert integers to strings. If the int default value is set, it will convert strings to integers.

Attributes

  • default_int64: An integer to use when an input string value is not found in the map.<br>One and only one of the ‘default_*’ attributes must be defined. Default value is name: "default_int64" type: INT i: -1

  • default_string: A string to use when an input integer value is not found in the map.<br>One and only one of the ‘default_*’ attributes must be defined. Default value is name: "default_string" type: STRING s: "_Unused"

Inputs

  • X (heterogeneous)T1: Input data

Outputs

  • Y (heterogeneous)T2: Output data. If strings are input, the output values are integers, and vice versa.

Type Constraints

  • T1 tensor(string), tensor(int64): The input must be a tensor of strings or integers, either [N,C] or [C].

  • T2 tensor(string), tensor(int64): The output is a tensor of strings or integers. Its shape will be the same as the input shape.

OnnxCategoryMapper_1#

class skl2onnx.algebra.onnx_ops.OnnxCategoryMapper_1(*args, **kwargs)#

Version

Onnx name: CategoryMapper

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Converts strings to integers and vice versa.

Two sequences of equal length are used to map between integers and strings, with strings and integers at the same index detailing the mapping.

Each operator converts either integers to strings or strings to integers, depending on which default value attribute is provided. Only one default value attribute should be defined.

If the string default value is set, it will convert integers to strings. If the int default value is set, it will convert strings to integers.

Attributes

  • default_int64: An integer to use when an input string value is not found in the map.<br>One and only one of the ‘default_*’ attributes must be defined. Default value is name: "default_int64" type: INT i: -1

  • default_string: A string to use when an input integer value is not found in the map.<br>One and only one of the ‘default_*’ attributes must be defined. Default value is name: "default_string" type: STRING s: "_Unused"

Inputs

  • X (heterogeneous)T1: Input data

Outputs

  • Y (heterogeneous)T2: Output data. If strings are input, the output values are integers, and vice versa.

Type Constraints

  • T1 tensor(string), tensor(int64): The input must be a tensor of strings or integers, either [N,C] or [C].

  • T2 tensor(string), tensor(int64): The output is a tensor of strings or integers. Its shape will be the same as the input shape.

OnnxCeil#

class skl2onnx.algebra.onnx_ops.OnnxCeil(*args, **kwargs)#

Version

Onnx name: Ceil

This version of the operator has been available since version 13.

Summary

Ceil takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the ceil is, y = ceil(x), is applied to the tensor elementwise. If x is integral, +0, -0, NaN, or infinite, x itself is returned.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxCeil_1#

class skl2onnx.algebra.onnx_ops.OnnxCeil_1(*args, **kwargs)#

Version

Onnx name: Ceil

This version of the operator has been available since version 1.

Summary

Ceil takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the ceil is, y = ceil(x), is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCeil_13#

class skl2onnx.algebra.onnx_ops.OnnxCeil_13(*args, **kwargs)#

Version

Onnx name: Ceil

This version of the operator has been available since version 13.

Summary

Ceil takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the ceil is, y = ceil(x), is applied to the tensor elementwise. If x is integral, +0, -0, NaN, or infinite, x itself is returned.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxCeil_6#

class skl2onnx.algebra.onnx_ops.OnnxCeil_6(*args, **kwargs)#

Version

Onnx name: Ceil

This version of the operator has been available since version 6.

Summary

Ceil takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the ceil is, y = ceil(x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCelu#

class skl2onnx.algebra.onnx_ops.OnnxCelu(*args, **kwargs)#

Version

Onnx name: Celu

This version of the operator has been available since version 12.

Summary

Continuously Differentiable Exponential Linear Units: Perform the linear unit element-wise on the input tensor X using formula:

max(0,x) + min(0,alpha*(exp(x/alpha)-1))

Attributes

  • alpha: The Alpha value in Celu formula which control the shape of the unit. The default value is 1.0. Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float): Constrain input and output types to float32 tensors.

OnnxCelu_12#

class skl2onnx.algebra.onnx_ops.OnnxCelu_12(*args, **kwargs)#

Version

Onnx name: Celu

This version of the operator has been available since version 12.

Summary

Continuously Differentiable Exponential Linear Units: Perform the linear unit element-wise on the input tensor X using formula:

max(0,x) + min(0,alpha*(exp(x/alpha)-1))

Attributes

  • alpha: The Alpha value in Celu formula which control the shape of the unit. The default value is 1.0. Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float): Constrain input and output types to float32 tensors.

OnnxCenterCropPad#

class skl2onnx.algebra.onnx_ops.OnnxCenterCropPad(*args, **kwargs)#

Version

Onnx name: CenterCropPad

This version of the operator has been available since version 18.

Summary

Center crop or pad an input to given dimensions.

The crop/pad dimensions can be specified for a subset of the axes. Non-specified dimensions will not be cropped or padded.

If the input dimensions are bigger than the crop shape, a centered cropping window is extracted from the input. If the input dimensions are smaller than the crop shape, the input is padded on each side equally, so that the input is centered in the output.

Attributes

Inputs

  • input_data (heterogeneous)T: Input to extract the centered crop from.

  • shape (heterogeneous)Tind: 1-D tensor representing the cropping window dimensions.

Outputs

  • output_data (heterogeneous)T: Output data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxCenterCropPad_18#

class skl2onnx.algebra.onnx_ops.OnnxCenterCropPad_18(*args, **kwargs)#

Version

Onnx name: CenterCropPad

This version of the operator has been available since version 18.

Summary

Center crop or pad an input to given dimensions.

The crop/pad dimensions can be specified for a subset of the axes. Non-specified dimensions will not be cropped or padded.

If the input dimensions are bigger than the crop shape, a centered cropping window is extracted from the input. If the input dimensions are smaller than the crop shape, the input is padded on each side equally, so that the input is centered in the output.

Attributes

Inputs

  • input_data (heterogeneous)T: Input to extract the centered crop from.

  • shape (heterogeneous)Tind: 1-D tensor representing the cropping window dimensions.

Outputs

  • output_data (heterogeneous)T: Output data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxClip#

class skl2onnx.algebra.onnx_ops.OnnxClip(*args, **kwargs)#

Version

Onnx name: Clip

This version of the operator has been available since version 13.

Summary

Clip operator limits the given input within an interval. The interval is specified by the inputs ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max(), respectively.

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous)T: Input tensor whose elements to be clipped

  • min (optional, heterogeneous)T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).

  • max (optional, heterogeneous)T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).

Outputs

  • output (heterogeneous)T: Output tensor with clipped input elements

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxClip_1#

class skl2onnx.algebra.onnx_ops.OnnxClip_1(*args, **kwargs)#

Version

Onnx name: Clip

This version of the operator has been available since version 1.

Summary

Clip operator limits the given input within an interval. The interval is specified with arguments ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max() respectively.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor whose elements to be clipped

Outputs

  • output (heterogeneous)T: Output tensor with clipped input elements

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxClip_11#

class skl2onnx.algebra.onnx_ops.OnnxClip_11(*args, **kwargs)#

Version

Onnx name: Clip

This version of the operator has been available since version 11.

Summary

Clip operator limits the given input within an interval. The interval is specified by the inputs ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max(), respectively.

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous)T: Input tensor whose elements to be clipped

  • min (optional, heterogeneous)T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).

  • max (optional, heterogeneous)T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).

Outputs

  • output (heterogeneous)T: Output tensor with clipped input elements

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxClip_12#

class skl2onnx.algebra.onnx_ops.OnnxClip_12(*args, **kwargs)#

Version

Onnx name: Clip

This version of the operator has been available since version 12.

Summary

Clip operator limits the given input within an interval. The interval is specified by the inputs ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max(), respectively.

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous)T: Input tensor whose elements to be clipped

  • min (optional, heterogeneous)T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).

  • max (optional, heterogeneous)T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).

Outputs

  • output (heterogeneous)T: Output tensor with clipped input elements

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxClip_13#

class skl2onnx.algebra.onnx_ops.OnnxClip_13(*args, **kwargs)#

Version

Onnx name: Clip

This version of the operator has been available since version 13.

Summary

Clip operator limits the given input within an interval. The interval is specified by the inputs ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max(), respectively.

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous)T: Input tensor whose elements to be clipped

  • min (optional, heterogeneous)T: Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape).

  • max (optional, heterogeneous)T: Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape).

Outputs

  • output (heterogeneous)T: Output tensor with clipped input elements

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxClip_6#

class skl2onnx.algebra.onnx_ops.OnnxClip_6(*args, **kwargs)#

Version

Onnx name: Clip

This version of the operator has been available since version 6.

Summary

Clip operator limits the given input within an interval. The interval is specified with arguments ‘min’ and ‘max’. They default to numeric_limits::lowest() and numeric_limits::max() respectively.

Attributes

  • max: Maximum value, above which element is replaced by max Default value is name: "max" type: FLOAT f: 3.40282347e+38

  • min: Minimum value, under which element is replaced by min Default value is name: "min" type: FLOAT f: -3.40282347e+38

Inputs

  • input (heterogeneous)T: Input tensor whose elements to be clipped

Outputs

  • output (heterogeneous)T: Output tensor with clipped input elements

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCol2Im#

class skl2onnx.algebra.onnx_ops.OnnxCol2Im(*args, **kwargs)#

Version

Onnx name: Col2Im

This version of the operator has been available since version 18.

Summary

The operator rearranges column blocks back into a multidimensional image

Col2Im behaves similarly to PyTorch’s fold https://pytorch.org/docs/stable/generated/torch.nn.Fold.html, but it only supports batched multi-dimensional image tensors. Another implementation in Python with N-dimension support can be found at https://github.com/f-dangel/unfoldNd/.

NOTE:

Although specifying image_shape looks redundant because it could be calculated from convolution formulas, it is required as input for more advanced scenarios as explained at PyTorch’s implementation (https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/Col2Im.cpp#L10)

Attributes

Inputs

  • input (heterogeneous)T: Input data tensor to be rearranged from column blocks back into an image. This is a 3-dimensional tensor containing [N, C * n-ary-product(block_shape), L], where N is batch dimension, C is image channel dimension and L is number of blocks.The blocks are enumerated in increasing lexicographic-order of their indices.For example, with an image-size 10*20 and block-size 9*18, there would be 2*3 blocks, enumerated in the order block(0, 0), block(0, 1), block(0, 2), block(1, 0), block(1, 1), block(1, 2).

  • image_shape (heterogeneous)tensor(int64): The shape of the spatial dimensions of the image after rearranging the column blocks.This is a 1-dimensional tensor with size of at least 2, containing the value [H_img, W_img] for a 2-D image or [dim_i1, dim_i2, …, dim_iN] for a N-D image.

  • block_shape (heterogeneous)tensor(int64): The shape of the block to apply on the input.This is a 1-dimensional tensor of size of at least 2, containing the value [H_block, W_block] for a 2-D image or [dim_b1, dim_b2, …, dim_bN] for a N-D block.This is the block-shape before dilation is applied to it.

Outputs

  • output (heterogeneous)T: Output tensor produced by rearranging blocks into an image.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all numeric tensor types.

OnnxCol2Im_18#

class skl2onnx.algebra.onnx_ops.OnnxCol2Im_18(*args, **kwargs)#

Version

Onnx name: Col2Im

This version of the operator has been available since version 18.

Summary

The operator rearranges column blocks back into a multidimensional image

Col2Im behaves similarly to PyTorch’s fold https://pytorch.org/docs/stable/generated/torch.nn.Fold.html, but it only supports batched multi-dimensional image tensors. Another implementation in Python with N-dimension support can be found at https://github.com/f-dangel/unfoldNd/.

NOTE:

Although specifying image_shape looks redundant because it could be calculated from convolution formulas, it is required as input for more advanced scenarios as explained at PyTorch’s implementation (https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/Col2Im.cpp#L10)

Attributes

Inputs

  • input (heterogeneous)T: Input data tensor to be rearranged from column blocks back into an image. This is a 3-dimensional tensor containing [N, C * n-ary-product(block_shape), L], where N is batch dimension, C is image channel dimension and L is number of blocks.The blocks are enumerated in increasing lexicographic-order of their indices.For example, with an image-size 10*20 and block-size 9*18, there would be 2*3 blocks, enumerated in the order block(0, 0), block(0, 1), block(0, 2), block(1, 0), block(1, 1), block(1, 2).

  • image_shape (heterogeneous)tensor(int64): The shape of the spatial dimensions of the image after rearranging the column blocks.This is a 1-dimensional tensor with size of at least 2, containing the value [H_img, W_img] for a 2-D image or [dim_i1, dim_i2, …, dim_iN] for a N-D image.

  • block_shape (heterogeneous)tensor(int64): The shape of the block to apply on the input.This is a 1-dimensional tensor of size of at least 2, containing the value [H_block, W_block] for a 2-D image or [dim_b1, dim_b2, …, dim_bN] for a N-D block.This is the block-shape before dilation is applied to it.

Outputs

  • output (heterogeneous)T: Output tensor produced by rearranging blocks into an image.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all numeric tensor types.

OnnxCompress#

class skl2onnx.algebra.onnx_ops.OnnxCompress(*args, **kwargs)#

Version

Onnx name: Compress

This version of the operator has been available since version 11.

Summary

Selects slices from an input tensor along a given axis where condition evaluates to True for each axis index. In case axis is not provided, input is flattened before elements are selected. Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html

Attributes

Inputs

  • input (heterogeneous)T: Tensor of rank r >= 1.

  • condition (heterogeneous)T1: Rank 1 tensor of booleans to indicate which slices or data elements to be selected. Its length can be less than the input length along the axis or the flattened input size if axis is not specified. In such cases data slices or elements exceeding the condition length are discarded.

Outputs

  • output (heterogeneous)T: Tensor of rank r if axis is specified. Otherwise output is a Tensor of rank 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • T1 tensor(bool): Constrain to boolean tensors.

OnnxCompress_11#

class skl2onnx.algebra.onnx_ops.OnnxCompress_11(*args, **kwargs)#

Version

Onnx name: Compress

This version of the operator has been available since version 11.

Summary

Selects slices from an input tensor along a given axis where condition evaluates to True for each axis index. In case axis is not provided, input is flattened before elements are selected. Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html

Attributes

Inputs

  • input (heterogeneous)T: Tensor of rank r >= 1.

  • condition (heterogeneous)T1: Rank 1 tensor of booleans to indicate which slices or data elements to be selected. Its length can be less than the input length along the axis or the flattened input size if axis is not specified. In such cases data slices or elements exceeding the condition length are discarded.

Outputs

  • output (heterogeneous)T: Tensor of rank r if axis is specified. Otherwise output is a Tensor of rank 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • T1 tensor(bool): Constrain to boolean tensors.

OnnxCompress_9#

class skl2onnx.algebra.onnx_ops.OnnxCompress_9(*args, **kwargs)#

Version

Onnx name: Compress

This version of the operator has been available since version 9.

Summary

Selects slices from an input tensor along a given axis where condition evaluates to True for each axis index. In case axis is not provided, input is flattened before elements are selected. Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html

Attributes

Inputs

  • input (heterogeneous)T: Tensor of rank r >= 1.

  • condition (heterogeneous)T1: Rank 1 tensor of booleans to indicate which slices or data elements to be selected. Its length can be less than the input length alone the axis or the flattened input size if axis is not specified. In such cases data slices or elements exceeding the condition length are discarded.

Outputs

  • output (heterogeneous)T: Tensor of rank r if axis is specified. Otherwise output is a Tensor of rank 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • T1 tensor(bool): Constrain to boolean tensors.

OnnxConcat#

class skl2onnx.algebra.onnx_ops.OnnxConcat(*args, **kwargs)#

Version

Onnx name: Concat

This version of the operator has been available since version 13.

Summary

Concatenate a list of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: List of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain output types to any tensor type.

OnnxConcatFromSequence#

class skl2onnx.algebra.onnx_ops.OnnxConcatFromSequence(*args, **kwargs)#

Version

Onnx name: ConcatFromSequence

This version of the operator has been available since version 11.

Summary

Concatenate a sequence of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on. By default ‘new_axis’ is 0, the behavior is similar to numpy.concatenate. When ‘new_axis’ is 1, the behavior is similar to numpy.stack.

Attributes

  • new_axis: Insert and concatenate on a new axis or not, default 0 means do not insert new axis. Default value is name: "new_axis" type: INT i: 0

Inputs

  • input_sequence (heterogeneous)S: Sequence of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input types to any tensor type.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain output types to any tensor type.

OnnxConcatFromSequence_11#

class skl2onnx.algebra.onnx_ops.OnnxConcatFromSequence_11(*args, **kwargs)#

Version

Onnx name: ConcatFromSequence

This version of the operator has been available since version 11.

Summary

Concatenate a sequence of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on. By default ‘new_axis’ is 0, the behavior is similar to numpy.concatenate. When ‘new_axis’ is 1, the behavior is similar to numpy.stack.

Attributes

  • new_axis: Insert and concatenate on a new axis or not, default 0 means do not insert new axis. Default value is name: "new_axis" type: INT i: 0

Inputs

  • input_sequence (heterogeneous)S: Sequence of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input types to any tensor type.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain output types to any tensor type.

OnnxConcat_1#

class skl2onnx.algebra.onnx_ops.OnnxConcat_1(*args, **kwargs)#

Version

Onnx name: Concat

This version of the operator has been available since version 1.

Summary

Concatenate a list of tensors into a single tensor

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: List of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxConcat_11#

class skl2onnx.algebra.onnx_ops.OnnxConcat_11(*args, **kwargs)#

Version

Onnx name: Concat

This version of the operator has been available since version 11.

Summary

Concatenate a list of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: List of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain output types to any tensor type.

OnnxConcat_13#

class skl2onnx.algebra.onnx_ops.OnnxConcat_13(*args, **kwargs)#

Version

Onnx name: Concat

This version of the operator has been available since version 13.

Summary

Concatenate a list of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: List of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain output types to any tensor type.

OnnxConcat_4#

class skl2onnx.algebra.onnx_ops.OnnxConcat_4(*args, **kwargs)#

Version

Onnx name: Concat

This version of the operator has been available since version 4.

Summary

Concatenate a list of tensors into a single tensor

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: List of tensors for concatenation

Outputs

  • concat_result (heterogeneous)T: Concatenated tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain output types to any tensor type.

OnnxConstant#

class skl2onnx.algebra.onnx_ops.OnnxConstant(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 21.

Summary

This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types.

OnnxConstantOfShape#

class skl2onnx.algebra.onnx_ops.OnnxConstantOfShape(*args, **kwargs)#

Version

Onnx name: ConstantOfShape

This version of the operator has been available since version 21.

Summary

Generate a tensor with given value and shape.

Attributes

Inputs

  • input (heterogeneous)T1: 1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar. All values must be >= 0.

Outputs

  • output (heterogeneous)T2: Output tensor of shape specified by ‘input’.If attribute ‘value’ is specified, the value and datatype of the output tensor is taken from ‘value’.If attribute ‘value’ is not specified, the value in the output defaults to 0, and the datatype defaults to float32.

Type Constraints

  • T1 tensor(int64): Constrain input types.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain output types to be numerics.

OnnxConstantOfShape_20#

class skl2onnx.algebra.onnx_ops.OnnxConstantOfShape_20(*args, **kwargs)#

Version

Onnx name: ConstantOfShape

This version of the operator has been available since version 20.

Summary

Generate a tensor with given value and shape.

Attributes

Inputs

  • input (heterogeneous)T1: 1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar. All values must be >= 0.

Outputs

  • output (heterogeneous)T2: Output tensor of shape specified by ‘input’.If attribute ‘value’ is specified, the value and datatype of the output tensor is taken from ‘value’.If attribute ‘value’ is not specified, the value in the output defaults to 0, and the datatype defaults to float32.

Type Constraints

  • T1 tensor(int64): Constrain input types.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain output types to be numerics.

OnnxConstantOfShape_21#

class skl2onnx.algebra.onnx_ops.OnnxConstantOfShape_21(*args, **kwargs)#

Version

Onnx name: ConstantOfShape

This version of the operator has been available since version 21.

Summary

Generate a tensor with given value and shape.

Attributes

Inputs

  • input (heterogeneous)T1: 1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar. All values must be >= 0.

Outputs

  • output (heterogeneous)T2: Output tensor of shape specified by ‘input’.If attribute ‘value’ is specified, the value and datatype of the output tensor is taken from ‘value’.If attribute ‘value’ is not specified, the value in the output defaults to 0, and the datatype defaults to float32.

Type Constraints

  • T1 tensor(int64): Constrain input types.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain output types to be numerics.

OnnxConstantOfShape_9#

class skl2onnx.algebra.onnx_ops.OnnxConstantOfShape_9(*args, **kwargs)#

Version

Onnx name: ConstantOfShape

This version of the operator has been available since version 9.

Summary

Generate a tensor with given value and shape.

Attributes

Inputs

  • input (heterogeneous)T1: 1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar. All values must be >= 0.

Outputs

  • output (heterogeneous)T2: Output tensor of shape specified by ‘input’.If attribute ‘value’ is specified, the value and datatype of the output tensor is taken from ‘value’.If attribute ‘value’ is not specified, the value in the output defaults to 0, and the datatype defaults to float32.

Type Constraints

  • T1 tensor(int64): Constrain input types.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain output types to be numerics.

OnnxConstant_1#

class skl2onnx.algebra.onnx_ops.OnnxConstant_1(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 1.

Summary

A constant tensor.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxConstant_11#

class skl2onnx.algebra.onnx_ops.OnnxConstant_11(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 11.

Summary

A constant tensor. Exactly one of the two attributes, either value or sparse_value, must be specified.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxConstant_12#

class skl2onnx.algebra.onnx_ops.OnnxConstant_12(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 12.

Summary

This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxConstant_13#

class skl2onnx.algebra.onnx_ops.OnnxConstant_13(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 13.

Summary

This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxConstant_19#

class skl2onnx.algebra.onnx_ops.OnnxConstant_19(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 19.

Summary

This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input and output types to all tensor types.

OnnxConstant_21#

class skl2onnx.algebra.onnx_ops.OnnxConstant_21(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 21.

Summary

This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types.

OnnxConstant_9#

class skl2onnx.algebra.onnx_ops.OnnxConstant_9(*args, **kwargs)#

Version

Onnx name: Constant

This version of the operator has been available since version 9.

Summary

A constant tensor.

Attributes

Outputs

  • output (heterogeneous)T: Output tensor containing the same value of the provided tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxConv#

class skl2onnx.algebra.onnx_ops.OnnxConv(*args, **kwargs)#

Version

Onnx name: Conv

This version of the operator has been available since version 11.

Summary

The convolution operator consumes an input tensor and a filter, and computes the output.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • W (heterogeneous)T: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. Assuming zero based indices for the shape array, X.shape[1] == (W.shape[1] * group) == C and W.shape[0] mod G == 0. Or in other words FILTER_IN_CHANNEL multiplied by the number of groups should be equal to DATA_CHANNEL and the number of feature maps M should be a multiple of the number of groups G.

  • B (optional, heterogeneous)T: Optional 1D bias to be added to the convolution, has size of M.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxConvInteger#

class skl2onnx.algebra.onnx_ops.OnnxConvInteger(*args, **kwargs)#

Version

Onnx name: ConvInteger

This version of the operator has been available since version 10.

Summary

The integer convolution operator consumes an input tensor, its zero-point, a filter, and its zero-point, and computes the output. The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. default is 1. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 4 inputs.

  • x (heterogeneous)T1: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • w (heterogeneous)T2: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. X.shape[1] == (W.shape[1] * group) == C (assuming zero based indices for the shape array). Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL.

  • x_zero_point (optional, heterogeneous)T1: Zero point tensor for input ‘x’. It’s optional and default value is 0. It’s a scalar, which means a per-tensor/layer quantization.

  • w_zero_point (optional, heterogeneous)T2: Zero point tensor for input ‘w’. It’s optional and default value is 0. It could be a scalar or a 1-D tensor, which means a per-tensor/layer or per output channel quantization. If it’s a 1-D tensor, its number of elements should be equal to the number of output channels (M)

Outputs

  • y (heterogeneous)T3: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input x and its zero point data type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain input w and its zero point data type to 8-bit integer tensor.

  • T3 tensor(int32): Constrain output y data type to 32-bit integer tensor.

OnnxConvInteger_10#

class skl2onnx.algebra.onnx_ops.OnnxConvInteger_10(*args, **kwargs)#

Version

Onnx name: ConvInteger

This version of the operator has been available since version 10.

Summary

The integer convolution operator consumes an input tensor, its zero-point, a filter, and its zero-point, and computes the output. The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. default is 1. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 4 inputs.

  • x (heterogeneous)T1: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • w (heterogeneous)T2: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. X.shape[1] == (W.shape[1] * group) == C (assuming zero based indices for the shape array). Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL.

  • x_zero_point (optional, heterogeneous)T1: Zero point tensor for input ‘x’. It’s optional and default value is 0. It’s a scalar, which means a per-tensor/layer quantization.

  • w_zero_point (optional, heterogeneous)T2: Zero point tensor for input ‘w’. It’s optional and default value is 0. It could be a scalar or a 1-D tensor, which means a per-tensor/layer or per output channel quantization. If it’s a 1-D tensor, its number of elements should be equal to the number of output channels (M)

Outputs

  • y (heterogeneous)T3: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input x and its zero point data type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain input w and its zero point data type to 8-bit integer tensor.

  • T3 tensor(int32): Constrain output y data type to 32-bit integer tensor.

OnnxConvTranspose#

class skl2onnx.algebra.onnx_ops.OnnxConvTranspose(*args, **kwargs)#

Version

Onnx name: ConvTranspose

This version of the operator has been available since version 11.

Summary

The convolution transpose operator consumes an input tensor and a filter, and computes the output.

If the pads parameter is provided the shape of the output is calculated via the following equation:

output_shape[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - pads[start_i] - pads[end_i]

output_shape can also be explicitly specified in which case pads values are auto generated using these equations:

total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i] If (auto_pads == SAME_UPPER): pads[start_i] = total_padding[i]/2; pads[end_i] = total_padding[i] - (total_padding[i]/2) Else: pads[start_i] = total_padding[i] - (total_padding[i]/2); pads[end_i] = (total_padding[i]/2).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = input_shape[i] * strides[i] for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn)

  • W (heterogeneous)T: The weight tensor that will be used in the convolutions; has size (C x M/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the weight shape will be (C x M/group x k1 x k2 x … x kn), where (k1 x k2 x … x kn) is the dimension of the kernel. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

  • B (optional, heterogeneous)T: Optional 1D bias to be added to the convolution, has size of M.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, pad lengths and group count. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxConvTranspose_1#

class skl2onnx.algebra.onnx_ops.OnnxConvTranspose_1(*args, **kwargs)#

Version

Onnx name: ConvTranspose

This version of the operator has been available since version 1.

Summary

The convolution transpose operator consumes an input tensor and a filter, and computes the output.

If the pads parameter is provided the shape of the output is calculated via the following equation:

output_shape[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - pads[start_i] - pads[end_i]

output_shape can also be explicitly specified in which case pads values are auto generated using these equations:

total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i] If (auto_pads != SAME_UPPER): pads[start_i] = total_padding[i]/2; pads[end_i] = total_padding[i] - (total_padding[i]/2) Else: pads[start_i] = total_padding[i] - (total_padding[i]/2); pads[end_i] = (total_padding[i]/2).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn)

  • W (heterogeneous)T: The weight tensor that will be used in the convolutions; has size (C x M/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the weight shape will be (C x M/group x k1 x k2 x … x kn), where (k1 x k2 x … x kn) is the dimension of the kernel. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

  • B (optional, heterogeneous)T: Optional 1D bias to be added to the convolution, has size of M.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, pad lengths and group count. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxConvTranspose_11#

class skl2onnx.algebra.onnx_ops.OnnxConvTranspose_11(*args, **kwargs)#

Version

Onnx name: ConvTranspose

This version of the operator has been available since version 11.

Summary

The convolution transpose operator consumes an input tensor and a filter, and computes the output.

If the pads parameter is provided the shape of the output is calculated via the following equation:

output_shape[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - pads[start_i] - pads[end_i]

output_shape can also be explicitly specified in which case pads values are auto generated using these equations:

total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i] If (auto_pads == SAME_UPPER): pads[start_i] = total_padding[i]/2; pads[end_i] = total_padding[i] - (total_padding[i]/2) Else: pads[start_i] = total_padding[i] - (total_padding[i]/2); pads[end_i] = (total_padding[i]/2).

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = input_shape[i] * strides[i] for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn)

  • W (heterogeneous)T: The weight tensor that will be used in the convolutions; has size (C x M/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the weight shape will be (C x M/group x k1 x k2 x … x kn), where (k1 x k2 x … x kn) is the dimension of the kernel. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

  • B (optional, heterogeneous)T: Optional 1D bias to be added to the convolution, has size of M.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, pad lengths and group count. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxConv_1#

class skl2onnx.algebra.onnx_ops.OnnxConv_1(*args, **kwargs)#

Version

Onnx name: Conv

This version of the operator has been available since version 1.

Summary

The convolution operator consumes an input tensor and a filter, and computes the output.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • W (heterogeneous)T: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. X.shape[1] == (W.shape[1] * group) == C (assuming zero based indices for the shape array). Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL.

  • B (optional, heterogeneous)T: Optional 1D bias to be added to the convolution, has size of M.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxConv_11#

class skl2onnx.algebra.onnx_ops.OnnxConv_11(*args, **kwargs)#

Version

Onnx name: Conv

This version of the operator has been available since version 11.

Summary

The convolution operator consumes an input tensor and a filter, and computes the output.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. Default value is name: "group" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • W (heterogeneous)T: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. Assuming zero based indices for the shape array, X.shape[1] == (W.shape[1] * group) == C and W.shape[0] mod G == 0. Or in other words FILTER_IN_CHANNEL multiplied by the number of groups should be equal to DATA_CHANNEL and the number of feature maps M should be a multiple of the number of groups G.

  • B (optional, heterogeneous)T: Optional 1D bias to be added to the convolution, has size of M.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCos#

class skl2onnx.algebra.onnx_ops.OnnxCos(*args, **kwargs)#

Version

Onnx name: Cos

This version of the operator has been available since version 7.

Summary

Calculates the cosine of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The cosine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCos_7#

class skl2onnx.algebra.onnx_ops.OnnxCos_7(*args, **kwargs)#

Version

Onnx name: Cos

This version of the operator has been available since version 7.

Summary

Calculates the cosine of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The cosine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCosh#

class skl2onnx.algebra.onnx_ops.OnnxCosh(*args, **kwargs)#

Version

Onnx name: Cosh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic cosine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic cosine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCosh_9#

class skl2onnx.algebra.onnx_ops.OnnxCosh_9(*args, **kwargs)#

Version

Onnx name: Cosh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic cosine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic cosine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxCumSum#

class skl2onnx.algebra.onnx_ops.OnnxCumSum(*args, **kwargs)#

Version

Onnx name: CumSum

This version of the operator has been available since version 14.

Summary

Performs cumulative sum of the input elements along the given axis. By default, it will do the sum inclusively meaning the first element is copied as is. Through an exclusive attribute, this behavior can change to exclude the first element. It can also perform summation in the opposite direction of the axis. For that, set reverse attribute to 1.

Example:

input_x = [1, 2, 3]
axis=0
output = [1, 3, 6]
exclusive=1
output = [0, 1, 3]
exclusive=0
reverse=1
output = [6, 5, 3]
exclusive=1
reverse=1
output = [5, 3, 0]

Attributes

  • exclusive: If set to 1 will return exclusive sum in which the top element is not included. In other terms, if set to 1, the j-th output element would be the sum of the first (j-1) elements. Otherwise, it would be the sum of the first j elements. Default value is name: "exclusive" type: INT i: 0

  • reverse: If set to 1 will perform the sums in reverse direction. Default value is name: "reverse" type: INT i: 0

Inputs

  • x (heterogeneous)T: An input tensor that is to be processed.

  • axis (heterogeneous)T2: A 0-D tensor. Must be in the range [-rank(x), rank(x)-1]. Negative value means counting dimensions from the back.

Outputs

  • y (heterogeneous)T: Output tensor of the same type as ‘x’ with cumulative sums of the x’s elements

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

  • T2 tensor(int32), tensor(int64): axis tensor can be int32 or int64 only

OnnxCumSum_11#

class skl2onnx.algebra.onnx_ops.OnnxCumSum_11(*args, **kwargs)#

Version

Onnx name: CumSum

This version of the operator has been available since version 11.

Summary

Performs cumulative sum of the input elements along the given axis. By default, it will do the sum inclusively meaning the first element is copied as is. Through an exclusive attribute, this behavior can change to exclude the first element. It can also perform summation in the opposite direction of the axis. For that, set reverse attribute to 1.

Example:

input_x = [1, 2, 3]
axis=0
output = [1, 3, 6]
exclusive=1
output = [0, 1, 3]
exclusive=0
reverse=1
output = [6, 5, 3]
exclusive=1
reverse=1
output = [5, 3, 0]

Attributes

  • exclusive: If set to 1 will return exclusive sum in which the top element is not included. In other terms, if set to 1, the j-th output element would be the sum of the first (j-1) elements. Otherwise, it would be the sum of the first j elements. Default value is name: "exclusive" type: INT i: 0

  • reverse: If set to 1 will perform the sums in reverse direction. Default value is name: "reverse" type: INT i: 0

Inputs

  • x (heterogeneous)T: An input tensor that is to be processed.

  • axis (heterogeneous)T2: A 0-D tensor. Must be in the range [-rank(x), rank(x)-1]. Negative value means counting dimensions from the back.

Outputs

  • y (heterogeneous)T: Output tensor of the same type as ‘x’ with cumulative sums of the x’s elements

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float), tensor(double): Input can be of any tensor type.

  • T2 tensor(int32), tensor(int64): axis tensor can be int32 or int64 only

OnnxCumSum_14#

class skl2onnx.algebra.onnx_ops.OnnxCumSum_14(*args, **kwargs)#

Version

Onnx name: CumSum

This version of the operator has been available since version 14.

Summary

Performs cumulative sum of the input elements along the given axis. By default, it will do the sum inclusively meaning the first element is copied as is. Through an exclusive attribute, this behavior can change to exclude the first element. It can also perform summation in the opposite direction of the axis. For that, set reverse attribute to 1.

Example:

input_x = [1, 2, 3]
axis=0
output = [1, 3, 6]
exclusive=1
output = [0, 1, 3]
exclusive=0
reverse=1
output = [6, 5, 3]
exclusive=1
reverse=1
output = [5, 3, 0]

Attributes

  • exclusive: If set to 1 will return exclusive sum in which the top element is not included. In other terms, if set to 1, the j-th output element would be the sum of the first (j-1) elements. Otherwise, it would be the sum of the first j elements. Default value is name: "exclusive" type: INT i: 0

  • reverse: If set to 1 will perform the sums in reverse direction. Default value is name: "reverse" type: INT i: 0

Inputs

  • x (heterogeneous)T: An input tensor that is to be processed.

  • axis (heterogeneous)T2: A 0-D tensor. Must be in the range [-rank(x), rank(x)-1]. Negative value means counting dimensions from the back.

Outputs

  • y (heterogeneous)T: Output tensor of the same type as ‘x’ with cumulative sums of the x’s elements

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

  • T2 tensor(int32), tensor(int64): axis tensor can be int32 or int64 only

OnnxDFT#

class skl2onnx.algebra.onnx_ops.OnnxDFT(*args, **kwargs)#

Version

Onnx name: DFT

This version of the operator has been available since version 20.

Summary

Computes the discrete Fourier Transform (DFT) of the input.

Assuming the input has shape [M, N], where N is the dimension over which the DFT is computed and M denotes the conceptual “all other dimensions,” the DFT y[m, k] of shape [M, N] is defined as

$$y[m, k] = sum_{n=0}^{N-1} e^{-2 pi j frac{k n}{N} } x[m, n] ,$$

and the inverse transform is defined as

$$x[m, n] = frac{1}{N} sum_{k=0}^{N-1} e^{2 pi j frac{k n}{N} } y[m, k] ,$$

where $j$ is the imaginary unit.

The actual shape of the output is specified in the “output” section.

Reference: https://docs.scipy.org/doc/scipy/tutorial/fft.html

Attributes

  • inverse: Whether to perform the inverse discrete Fourier Transform. Default is 0, which corresponds to false. Default value is name: "inverse" type: INT i: 0

  • onesided: If onesided is 1 and input is real, only values for k in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, k] = X[m, n_fft-k]*, where m denotes “all other dimensions” DFT was not applied on. If the input tensor is complex, onesided output is not possible. Value can be 0 or 1. Default is 0. Default value is name: "onesided" type: INT i: 0

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous)T1: For real input, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[signal_dimN][1]. For complex input, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[signal_dimN][2]. The final dimension represents the real and imaginary parts of the value in that order.

  • dft_length (optional, heterogeneous)T2: The length of the signal as a scalar. If greater than the axis dimension, the signal will be zero-padded up to dft_length. If less than the axis dimension, only the first dft_length values will be used as the signal.

  • axis (optional, heterogeneous)tensor(int64): The axis as a scalar on which to perform the DFT. Default is -2 (last signal axis). Negative value means counting dimensions from the back. Accepted range is $[-r, -2] cup [0, r-2]$ where r = rank(input). The last dimension is for representing complex numbers and thus is an invalid axis.

Outputs

  • output (heterogeneous)T1: The Fourier Transform of the input vector. If onesided is 0, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[signal_dimN][2]. If axis=0 and onesided is 1, the following shape is expected: [floor(signal_dim0/2)+1][signal_dim1][signal_dim2]…[signal_dimN][2]. If axis=1 and onesided is 1, the following shape is expected: [signal_dim0][floor(signal_dim1/2)+1][signal_dim2]…[signal_dimN][2]. If axis=N and onesided is 1, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[floor(signal_dimN/2)+1][2]. The signal_dim at the specified axis is equal to the dft_length.

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain scalar length types to integers.

OnnxDFT_17#

class skl2onnx.algebra.onnx_ops.OnnxDFT_17(*args, **kwargs)#

Version

Onnx name: DFT

This version of the operator has been available since version 17.

Summary

Computes the discrete Fourier transform of input.

Attributes

  • axis: The axis on which to perform the DFT. By default this value is set to 1, which corresponds to the first dimension after the batch index. Negative value means counting dimensions from the back. Accepted range is $[-r, -2] cup [0, r-2]$ where r = rank(input). The last dimension is for representing complex numbers and thus is an invalid axis. Default value is name: "axis" type: INT i: 1

  • inverse: Whether to perform the inverse discrete fourier transform. By default this value is set to 0, which corresponds to false. Default value is name: "inverse" type: INT i: 0

  • onesided: If onesided is 1, only values for w in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, w] = X[m, n_fft-w]*. Note if the input or window tensors are complex, then onesided output is not possible. Enabling onesided with real inputs performs a Real-valued fast Fourier transform (RFFT). When invoked with real or complex valued input, the default value is 0. Values can be 0 or 1. Default value is name: "onesided" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T1: For real input, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[signal_dimN][1]. For complex input, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[signal_dimN][2]. The first dimension is the batch dimension. The following N dimensions correspond to the signal’s dimensions. The final dimension represents the real and imaginary parts of the value in that order.

  • dft_length (optional, heterogeneous)T2: The length of the signal as a scalar. If greater than the axis dimension, the signal will be zero-padded up to dft_length. If less than the axis dimension, only the first dft_length values will be used as the signal. It’s an optional value.

Outputs

  • output (heterogeneous)T1: The Fourier Transform of the input vector. If onesided is 0, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[signal_dimN][2]. If axis=1 and onesided is 1, the following shape is expected: [batch_idx][floor(signal_dim1/2)+1][signal_dim2]…[signal_dimN][2]. If axis=2 and onesided is 1, the following shape is expected: [batch_idx][signal_dim1][floor(signal_dim2/2)+1]…[signal_dimN][2]. If axis=N and onesided is 1, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[floor(signal_dimN/2)+1][2]. The signal_dim at the specified axis is equal to the dft_length.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain scalar length types to int64_t.

OnnxDFT_20#

class skl2onnx.algebra.onnx_ops.OnnxDFT_20(*args, **kwargs)#

Version

Onnx name: DFT

This version of the operator has been available since version 20.

Summary

Computes the discrete Fourier Transform (DFT) of the input.

Assuming the input has shape [M, N], where N is the dimension over which the DFT is computed and M denotes the conceptual “all other dimensions,” the DFT y[m, k] of shape [M, N] is defined as

$$y[m, k] = sum_{n=0}^{N-1} e^{-2 pi j frac{k n}{N} } x[m, n] ,$$

and the inverse transform is defined as

$$x[m, n] = frac{1}{N} sum_{k=0}^{N-1} e^{2 pi j frac{k n}{N} } y[m, k] ,$$

where $j$ is the imaginary unit.

The actual shape of the output is specified in the “output” section.

Reference: https://docs.scipy.org/doc/scipy/tutorial/fft.html

Attributes

  • inverse: Whether to perform the inverse discrete Fourier Transform. Default is 0, which corresponds to false. Default value is name: "inverse" type: INT i: 0

  • onesided: If onesided is 1 and input is real, only values for k in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, k] = X[m, n_fft-k]*, where m denotes “all other dimensions” DFT was not applied on. If the input tensor is complex, onesided output is not possible. Value can be 0 or 1. Default is 0. Default value is name: "onesided" type: INT i: 0

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous)T1: For real input, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[signal_dimN][1]. For complex input, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[signal_dimN][2]. The final dimension represents the real and imaginary parts of the value in that order.

  • dft_length (optional, heterogeneous)T2: The length of the signal as a scalar. If greater than the axis dimension, the signal will be zero-padded up to dft_length. If less than the axis dimension, only the first dft_length values will be used as the signal.

  • axis (optional, heterogeneous)tensor(int64): The axis as a scalar on which to perform the DFT. Default is -2 (last signal axis). Negative value means counting dimensions from the back. Accepted range is $[-r, -2] cup [0, r-2]$ where r = rank(input). The last dimension is for representing complex numbers and thus is an invalid axis.

Outputs

  • output (heterogeneous)T1: The Fourier Transform of the input vector. If onesided is 0, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[signal_dimN][2]. If axis=0 and onesided is 1, the following shape is expected: [floor(signal_dim0/2)+1][signal_dim1][signal_dim2]…[signal_dimN][2]. If axis=1 and onesided is 1, the following shape is expected: [signal_dim0][floor(signal_dim1/2)+1][signal_dim2]…[signal_dimN][2]. If axis=N and onesided is 1, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]…[floor(signal_dimN/2)+1][2]. The signal_dim at the specified axis is equal to the dft_length.

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain scalar length types to integers.

OnnxDeformConv#

class skl2onnx.algebra.onnx_ops.OnnxDeformConv(*args, **kwargs)#

Version

Onnx name: DeformConv

This version of the operator has been available since version 19.

Summary

Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168. This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data.

Attributes

  • group: Number of groups the input and output channels, C and oC, are divided into. C and oC must both be divisible by group. Default is 1. Default value is name: "group" type: INT i: 1

  • offset_group: Number of groups of offset. C must be divisible by offset_group. Default is 1. Default value is name: "offset_group" type: INT i: 1

Inputs

Between 3 and 5 inputs.

  • X (heterogeneous)T: Input data tensor. For 2D image data, it has shape (N, C, H, W) where N is the batch size, C is the number of input channels, and H and W are the height and width. In general, the shape is (N, C, D1, D2, … , Dn) for n-dimensional data, where D1 to Dn are the spatial dimension sizes. Most common use cases have n = 2 or 3.

  • W (heterogeneous)T: Weight tensor that will be used in the convolutions. It has shape (oC, C/group, kH, kW), where oC is the number of output channels and kH and kW are the kernel height and width. For more than 2 dimensions, it has shape (oC, C/group, k1, k2, … , kn).

  • offset (heterogeneous)T: Offset tensor denoting the offset for the sampling locations in the convolution kernel. It has shape (N, offset_group * kH * kW * 2, oH, oW) for 2D data or (N, offset_group * k1 * k2 * … * kn * n, o1, o2, … , on) for nD data. Use linear interpolationfor fractional offset values. Sampling locations outside of the padded input tensor gives zero.

  • B (optional, heterogeneous)T: Optional 1D bias of length oC to be added to the convolution. Default is a tensor of zeros.

  • mask (optional, heterogeneous)T: The mask tensor to be applied to each position in the convolution kernel. It has shape (N, offset_group * kH * kW, oH, oW) for 2D data or (N, offset_group * k1 * k2 * … * kn * n, o1, o2, … , on) for nD data. Default is a tensor of ones.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of convolution. It has shape (N, oC, oH, oW) for 2D data or (N, oC, o1, o2, …, on) for nD data

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxDeformConv_19#

class skl2onnx.algebra.onnx_ops.OnnxDeformConv_19(*args, **kwargs)#

Version

Onnx name: DeformConv

This version of the operator has been available since version 19.

Summary

Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168. This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data.

Attributes

  • group: Number of groups the input and output channels, C and oC, are divided into. C and oC must both be divisible by group. Default is 1. Default value is name: "group" type: INT i: 1

  • offset_group: Number of groups of offset. C must be divisible by offset_group. Default is 1. Default value is name: "offset_group" type: INT i: 1

Inputs

Between 3 and 5 inputs.

  • X (heterogeneous)T: Input data tensor. For 2D image data, it has shape (N, C, H, W) where N is the batch size, C is the number of input channels, and H and W are the height and width. In general, the shape is (N, C, D1, D2, … , Dn) for n-dimensional data, where D1 to Dn are the spatial dimension sizes. Most common use cases have n = 2 or 3.

  • W (heterogeneous)T: Weight tensor that will be used in the convolutions. It has shape (oC, C/group, kH, kW), where oC is the number of output channels and kH and kW are the kernel height and width. For more than 2 dimensions, it has shape (oC, C/group, k1, k2, … , kn).

  • offset (heterogeneous)T: Offset tensor denoting the offset for the sampling locations in the convolution kernel. It has shape (N, offset_group * kH * kW * 2, oH, oW) for 2D data or (N, offset_group * k1 * k2 * … * kn * n, o1, o2, … , on) for nD data. Use linear interpolationfor fractional offset values. Sampling locations outside of the padded input tensor gives zero.

  • B (optional, heterogeneous)T: Optional 1D bias of length oC to be added to the convolution. Default is a tensor of zeros.

  • mask (optional, heterogeneous)T: The mask tensor to be applied to each position in the convolution kernel. It has shape (N, offset_group * kH * kW, oH, oW) for 2D data or (N, offset_group * k1 * k2 * … * kn * n, o1, o2, … , on) for nD data. Default is a tensor of ones.

Outputs

  • Y (heterogeneous)T: Output data tensor that contains the result of convolution. It has shape (N, oC, oH, oW) for 2D data or (N, oC, o1, o2, …, on) for nD data

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxDepthToSpace#

class skl2onnx.algebra.onnx_ops.OnnxDepthToSpace(*args, **kwargs)#

Version

Onnx name: DepthToSpace

This version of the operator has been available since version 13.

Summary

DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged in the following order: depth, column, and then row. The output y is computed from the input x as below:

b, c, h, w = x.shape
tmp = np.reshape(x, [b, blocksize, blocksize, c // (blocksize**2), h, w])
tmp = np.transpose(tmp, [0, 3, 4, 1, 5, 2])
y = np.reshape(tmp, [b, c // (blocksize**2), h * blocksize, w * blocksize])

In the CRD mode, elements along the depth dimension from the input tensor are rearranged in the following order: column, row, and the depth. The output y is computed from the input x as below:

b, c, h, w = x.shape
tmp = np.reshape(x, [b, c // (blocksize ** 2), blocksize, blocksize, h, w])
tmp = np.transpose(tmp, [0, 1, 4, 2, 5, 3])
y = np.reshape(tmp, [b, c // (blocksize ** 2), h * blocksize, w * blocksize])

Attributes

  • mode: DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order. Default value is name: "mode" type: STRING s: "DCR"

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxDepthToSpace_1#

class skl2onnx.algebra.onnx_ops.OnnxDepthToSpace_1(*args, **kwargs)#

Version

Onnx name: DepthToSpace

This version of the operator has been available since version 1.

Summary

DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxDepthToSpace_11#

class skl2onnx.algebra.onnx_ops.OnnxDepthToSpace_11(*args, **kwargs)#

Version

Onnx name: DepthToSpace

This version of the operator has been available since version 11.

Summary

DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged in the following order: depth, column, and then row. The output y is computed from the input x as below:

b, c, h, w = x.shape

tmp = np.reshape(x, [b, blocksize, blocksize, c // (blocksize**2), h, w])

tmp = np.transpose(tmp, [0, 3, 4, 1, 5, 2])

y = np.reshape(tmp, [b, c // (blocksize**2), h * blocksize, w * blocksize])

In the CRD mode, elements along the depth dimension from the input tensor are rearranged in the following order: column, row, and the depth. The output y is computed from the input x as below:

b, c, h, w = x.shape

tmp = np.reshape(x, [b, c // (blocksize ** 2), blocksize, blocksize, h, w])

tmp = np.transpose(tmp, [0, 1, 4, 2, 5, 3])

y = np.reshape(tmp, [b, c // (blocksize ** 2), h * blocksize, w * blocksize])

Attributes

  • mode: DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order. Default value is name: "mode" type: STRING s: "DCR"

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxDepthToSpace_13#

class skl2onnx.algebra.onnx_ops.OnnxDepthToSpace_13(*args, **kwargs)#

Version

Onnx name: DepthToSpace

This version of the operator has been available since version 13.

Summary

DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged in the following order: depth, column, and then row. The output y is computed from the input x as below:

b, c, h, w = x.shape
tmp = np.reshape(x, [b, blocksize, blocksize, c // (blocksize**2), h, w])
tmp = np.transpose(tmp, [0, 3, 4, 1, 5, 2])
y = np.reshape(tmp, [b, c // (blocksize**2), h * blocksize, w * blocksize])

In the CRD mode, elements along the depth dimension from the input tensor are rearranged in the following order: column, row, and the depth. The output y is computed from the input x as below:

b, c, h, w = x.shape
tmp = np.reshape(x, [b, c // (blocksize ** 2), blocksize, blocksize, h, w])
tmp = np.transpose(tmp, [0, 1, 4, 2, 5, 3])
y = np.reshape(tmp, [b, c // (blocksize ** 2), h * blocksize, w * blocksize])

Attributes

  • mode: DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order. Default value is name: "mode" type: STRING s: "DCR"

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxDequantizeLinear#

class skl2onnx.algebra.onnx_ops.OnnxDequantizeLinear(*args, **kwargs)#

Version

Onnx name: DequantizeLinear

This version of the operator has been available since version 21.

Summary

The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. x_zero_point and x must have same type. x and y must have same shape. In the case of dequantizing int32, there’s no zero point (zero point is supposed to be 0). zero-point is usually not used in the case of float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz quantization, but the dequantization formula remains the same for consistency and ‘x_scale’ still determines the output type.

Attributes

  • axis: (Optional) The axis of the dequantizing dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D quantized input tensor to be de-quantized.

  • x_scale (heterogeneous)T2: Scale for input ‘x’. It can be a scalar, which means a per-tensor/layer dequantization, or a 1-D tensor for per-axis dequantization.

  • x_zero_point (optional, heterogeneous)T1: Zero point for input ‘x’. Shape must match x_scale. It’s optional. Zero point is 0 when it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D full precision output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(int8), tensor(uint8), tensor(int16), tensor(uint16), tensor(int32), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): The type of the inputs ‘x_zero_point’ and ‘x’.

  • T2 tensor(float), tensor(float16), tensor(bfloat16): ‘x_scale’ determines the output type.

OnnxDequantizeLinear_10#

class skl2onnx.algebra.onnx_ops.OnnxDequantizeLinear_10(*args, **kwargs)#

Version

Onnx name: DequantizeLinear

This version of the operator has been available since version 10.

Summary

The linear dequantization operator. It consumes a quantized tensor, a scale, a zero point to compute the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. ‘x_scale’ and ‘x_zero_point’ are both scalars. ‘x_zero_point’ and ‘x’ must have same type. ‘x’ and ‘y’ must have same shape. In the case of dequantizing int32, there’s no zero point (zero point is supposed to be 0).

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T: N-D quantized input tensor to be de-quantized.

  • x_scale (heterogeneous)tensor(float): Scale for input ‘x’. It’s a scalar, which means a per-tensor/layer quantization.

  • x_zero_point (optional, heterogeneous)T: Zero point for input ‘x’. It’s a scalar, which means a per-tensor/layer quantization. It’s optional. 0 is the default value when it’s not specified.

Outputs

  • y (heterogeneous)tensor(float): N-D full precision output tensor. It has same shape as input ‘x’.

Type Constraints

  • T tensor(int8), tensor(uint8), tensor(int32): Constrain ‘x_zero_point’ and ‘x’ to 8-bit/32-bit integer tensor.

OnnxDequantizeLinear_13#

class skl2onnx.algebra.onnx_ops.OnnxDequantizeLinear_13(*args, **kwargs)#

Version

Onnx name: DequantizeLinear

This version of the operator has been available since version 13.

Summary

The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. x_zero_point and x must have same type. x and y must have same shape. In the case of dequantizing int32, there’s no zero point (zero point is supposed to be 0).

Attributes

  • axis: (Optional) The axis of the dequantizing dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T: N-D quantized input tensor to be de-quantized.

  • x_scale (heterogeneous)tensor(float): Scale for input ‘x’. It can be a scalar, which means a per-tensor/layer dequantization, or a 1-D tensor for per-axis dequantization.

  • x_zero_point (optional, heterogeneous)T: Zero point for input ‘x’. Shape must match x_scale. It’s optional. Zero point is 0 when it’s not specified.

Outputs

  • y (heterogeneous)tensor(float): N-D full precision output tensor. It has same shape as input ‘x’.

Type Constraints

  • T tensor(int8), tensor(uint8), tensor(int32): Constrain ‘x_zero_point’ and ‘x’ to 8-bit/32-bit integer tensor.

OnnxDequantizeLinear_19#

class skl2onnx.algebra.onnx_ops.OnnxDequantizeLinear_19(*args, **kwargs)#

Version

Onnx name: DequantizeLinear

This version of the operator has been available since version 19.

Summary

The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. x_zero_point and x must have same type. x and y must have same shape. In the case of dequantizing int32, there’s no zero point (zero point is supposed to be 0). zero-point is usually not used in the case of float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz quantization, but the dequantization formula remains the same for consistency and ‘x_scale’ still determines the output type.

Attributes

  • axis: (Optional) The axis of the dequantizing dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D quantized input tensor to be de-quantized.

  • x_scale (heterogeneous)T2: Scale for input ‘x’. It can be a scalar, which means a per-tensor/layer dequantization, or a 1-D tensor for per-axis dequantization.

  • x_zero_point (optional, heterogeneous)T1: Zero point for input ‘x’. Shape must match x_scale. It’s optional. Zero point is 0 when it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D full precision output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(int8), tensor(uint8), tensor(int32), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain ‘x_zero_point’ and ‘x’ to 8-bit integer or float, or /32-bit integer tensor.

  • T2 tensor(float), tensor(float16), tensor(bfloat16): ‘x_scale’ determines the output type.

OnnxDequantizeLinear_21#

class skl2onnx.algebra.onnx_ops.OnnxDequantizeLinear_21(*args, **kwargs)#

Version

Onnx name: DequantizeLinear

This version of the operator has been available since version 21.

Summary

The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. x_zero_point and x must have same type. x and y must have same shape. In the case of dequantizing int32, there’s no zero point (zero point is supposed to be 0). zero-point is usually not used in the case of float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz quantization, but the dequantization formula remains the same for consistency and ‘x_scale’ still determines the output type.

Attributes

  • axis: (Optional) The axis of the dequantizing dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D quantized input tensor to be de-quantized.

  • x_scale (heterogeneous)T2: Scale for input ‘x’. It can be a scalar, which means a per-tensor/layer dequantization, or a 1-D tensor for per-axis dequantization.

  • x_zero_point (optional, heterogeneous)T1: Zero point for input ‘x’. Shape must match x_scale. It’s optional. Zero point is 0 when it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D full precision output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(int8), tensor(uint8), tensor(int16), tensor(uint16), tensor(int32), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): The type of the inputs ‘x_zero_point’ and ‘x’.

  • T2 tensor(float), tensor(float16), tensor(bfloat16): ‘x_scale’ determines the output type.

OnnxDet#

class skl2onnx.algebra.onnx_ops.OnnxDet(*args, **kwargs)#

Version

Onnx name: Det

This version of the operator has been available since version 11.

Summary

Det calculates determinant of a square matrix or batches of square matrices. Det takes one input tensor of shape [*, M, M], where * is zero or more batch dimensions, and the inner-most 2 dimensions form square matrices. The output is a tensor of shape [*], containing the determinants of all input submatrices. e.g., When the input is 2-D, the output is a scalar(shape is empty: []).

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to floating-point tensors.

OnnxDet_11#

class skl2onnx.algebra.onnx_ops.OnnxDet_11(*args, **kwargs)#

Version

Onnx name: Det

This version of the operator has been available since version 11.

Summary

Det calculates determinant of a square matrix or batches of square matrices. Det takes one input tensor of shape [*, M, M], where * is zero or more batch dimensions, and the inner-most 2 dimensions form square matrices. The output is a tensor of shape [*], containing the determinants of all input submatrices. e.g., When the input is 2-D, the output is a scalar(shape is empty: []).

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to floating-point tensors.

OnnxDictVectorizer#

class skl2onnx.algebra.onnx_ops.OnnxDictVectorizer(*args, **kwargs)#

Version

Onnx name: DictVectorizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Uses an index mapping to convert a dictionary to an array.

Given a dictionary, each key is looked up in the vocabulary attribute corresponding to the key type. The index into the vocabulary array at which the key is found is then used to index the output 1-D tensor ‘Y’ and insert into it the value found in the dictionary ‘X’.

The key type of the input map must correspond to the element type of the defined vocabulary attribute. Therefore, the output array will be equal in length to the index mapping vector parameter. All keys in the input dictionary must be present in the index mapping vector. For each item in the input dictionary, insert its value in the output array. Any keys not present in the input dictionary, will be zero in the output array.

For example: if the string_vocabulary parameter is set to ["a", "c", "b", "z"], then an input of {"a": 4, "c": 8} will produce an output of [4, 8, 0, 0].

Attributes

Inputs

  • X (heterogeneous)T1: A dictionary.

Outputs

  • Y (heterogeneous)T2: A 1-D tensor holding values from the input dictionary.

Type Constraints

  • T1 map(string, int64), map(int64, string), map(int64, float), map(int64, double), map(string, float), map(string, double): The input must be a map from strings or integers to either strings or a numeric type. The key and value types cannot be the same.

  • T2 tensor(int64), tensor(float), tensor(double), tensor(string): The output will be a tensor of the value type of the input map. It’s shape will be [1,C], where C is the length of the input dictionary.

OnnxDictVectorizer_1#

class skl2onnx.algebra.onnx_ops.OnnxDictVectorizer_1(*args, **kwargs)#

Version

Onnx name: DictVectorizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Uses an index mapping to convert a dictionary to an array.

Given a dictionary, each key is looked up in the vocabulary attribute corresponding to the key type. The index into the vocabulary array at which the key is found is then used to index the output 1-D tensor ‘Y’ and insert into it the value found in the dictionary ‘X’.

The key type of the input map must correspond to the element type of the defined vocabulary attribute. Therefore, the output array will be equal in length to the index mapping vector parameter. All keys in the input dictionary must be present in the index mapping vector. For each item in the input dictionary, insert its value in the output array. Any keys not present in the input dictionary, will be zero in the output array.

For example: if the string_vocabulary parameter is set to ["a", "c", "b", "z"], then an input of {"a": 4, "c": 8} will produce an output of [4, 8, 0, 0].

Attributes

Inputs

  • X (heterogeneous)T1: A dictionary.

Outputs

  • Y (heterogeneous)T2: A 1-D tensor holding values from the input dictionary.

Type Constraints

  • T1 map(string, int64), map(int64, string), map(int64, float), map(int64, double), map(string, float), map(string, double): The input must be a map from strings or integers to either strings or a numeric type. The key and value types cannot be the same.

  • T2 tensor(int64), tensor(float), tensor(double), tensor(string): The output will be a tensor of the value type of the input map. It’s shape will be [1,C], where C is the length of the input dictionary.

OnnxDiv#

class skl2onnx.algebra.onnx_ops.OnnxDiv(*args, **kwargs)#

Version

Onnx name: Div

This version of the operator has been available since version 14.

Summary

Performs element-wise binary division (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxDiv_1#

class skl2onnx.algebra.onnx_ops.OnnxDiv_1(*args, **kwargs)#

Version

Onnx name: Div

This version of the operator has been available since version 1.

Summary

Performs element-wise binary division (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxDiv_13#

class skl2onnx.algebra.onnx_ops.OnnxDiv_13(*args, **kwargs)#

Version

Onnx name: Div

This version of the operator has been available since version 13.

Summary

Performs element-wise binary division (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

OnnxDiv_14#

class skl2onnx.algebra.onnx_ops.OnnxDiv_14(*args, **kwargs)#

Version

Onnx name: Div

This version of the operator has been available since version 14.

Summary

Performs element-wise binary division (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxDiv_6#

class skl2onnx.algebra.onnx_ops.OnnxDiv_6(*args, **kwargs)#

Version

Onnx name: Div

This version of the operator has been available since version 6.

Summary

Performs element-wise binary division (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxDiv_7#

class skl2onnx.algebra.onnx_ops.OnnxDiv_7(*args, **kwargs)#

Version

Onnx name: Div

This version of the operator has been available since version 7.

Summary

Performs element-wise binary division (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxDropout#

class skl2onnx.algebra.onnx_ops.OnnxDropout(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 13.

Summary

Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, output (floating-point tensor) and mask (optional Tensor<bool>). If training_mode is true then the output Y will be a random dropout; Note that this Dropout scales the masked input data by the following equation, so to convert the trained model into inference mode, the user can simply not pass training_mode input or set it to false.

output = scale * data * mask,

where

scale = 1. / (1. - ratio).

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

Inputs

Between 1 and 3 inputs.

  • data (heterogeneous)T: The input data as Tensor.

  • ratio (optional, heterogeneous)T1: The ratio of random dropout, with value in [0, 1). If this input was not set, or if it was set to 0, the output would be a simple copy of the input. If it’s non-zero, output will be a random dropout of the scaled input, which is typically the case during training. It is an optional value, if not specified it will default to 0.5.

  • training_mode (optional, heterogeneous)T2: If set to true then it indicates dropout is being used for training. It is an optional value hence unless specified explicitly, it is false. If it is false, ratio is ignored and the operation mimics inference mode where nothing will be dropped from the input data and if mask is requested as output it will contain all ones.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T2: The output mask.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input ‘ratio’ types to float tensors.

  • T2 tensor(bool): Constrain output ‘mask’ types to boolean tensors.

OnnxDropout_1#

class skl2onnx.algebra.onnx_ops.OnnxDropout_1(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 1.

Summary

Dropout takes one input data (Tensor<float>) and produces two Tensor outputs, output (Tensor<float>) and mask (Tensor<bool>). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done.

Attributes

  • is_test: (int, default 0) if nonzero, run dropout in test mode where the output is simply Y = X. Default value is name: "is_test" type: INT i: 0

  • ratio: (float, default 0.5) the ratio of random dropout Default value is name: "ratio" type: FLOAT f: 0.5

Inputs

  • data (heterogeneous)T: The input data as Tensor.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T: The output mask. If is_test is nonzero, this output is not filled.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxDropout_10#

class skl2onnx.algebra.onnx_ops.OnnxDropout_10(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 10.

Summary

Dropout takes one input floating tensor and produces two tensor outputs, output (floating tensor) and mask (Tensor<bool>). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • ratio: The ratio of random dropout Default value is name: "ratio" type: FLOAT f: 0.5

Inputs

  • data (heterogeneous)T: The input data as Tensor.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T1: The output mask.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(bool): Constrain output mask types to boolean tensors.

OnnxDropout_12#

class skl2onnx.algebra.onnx_ops.OnnxDropout_12(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 12.

Summary

Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, output (floating-point tensor) and mask (optional Tensor<bool>). If training_mode is true then the output Y will be a random dropout; Note that this Dropout scales the masked input data by the following equation, so to convert the trained model into inference mode, the user can simply not pass training_mode input or set it to false.

output = scale * data * mask,

where

scale = 1. / (1. - ratio).

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

Inputs

Between 1 and 3 inputs.

  • data (heterogeneous)T: The input data as Tensor.

  • ratio (optional, heterogeneous)T1: The ratio of random dropout, with value in [0, 1). If this input was not set, or if it was set to 0, the output would be a simple copy of the input. If it’s non-zero, output will be a random dropout of the scaled input, which is typically the case during training. It is an optional value, if not specified it will default to 0.5.

  • training_mode (optional, heterogeneous)T2: If set to true then it indicates dropout is being used for training. It is an optional value hence unless specified explicitly, it is false. If it is false, ratio is ignored and the operation mimics inference mode where nothing will be dropped from the input data and if mask is requested as output it will contain all ones.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T2: The output mask.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input ‘ratio’ types to float tensors.

  • T2 tensor(bool): Constrain output ‘mask’ types to boolean tensors.

OnnxDropout_13#

class skl2onnx.algebra.onnx_ops.OnnxDropout_13(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 13.

Summary

Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, output (floating-point tensor) and mask (optional Tensor<bool>). If training_mode is true then the output Y will be a random dropout; Note that this Dropout scales the masked input data by the following equation, so to convert the trained model into inference mode, the user can simply not pass training_mode input or set it to false.

output = scale * data * mask,

where

scale = 1. / (1. - ratio).

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

Inputs

Between 1 and 3 inputs.

  • data (heterogeneous)T: The input data as Tensor.

  • ratio (optional, heterogeneous)T1: The ratio of random dropout, with value in [0, 1). If this input was not set, or if it was set to 0, the output would be a simple copy of the input. If it’s non-zero, output will be a random dropout of the scaled input, which is typically the case during training. It is an optional value, if not specified it will default to 0.5.

  • training_mode (optional, heterogeneous)T2: If set to true then it indicates dropout is being used for training. It is an optional value hence unless specified explicitly, it is false. If it is false, ratio is ignored and the operation mimics inference mode where nothing will be dropped from the input data and if mask is requested as output it will contain all ones.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T2: The output mask.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input ‘ratio’ types to float tensors.

  • T2 tensor(bool): Constrain output ‘mask’ types to boolean tensors.

OnnxDropout_6#

class skl2onnx.algebra.onnx_ops.OnnxDropout_6(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 6.

Summary

Dropout takes one input data (Tensor<float>) and produces two Tensor outputs, output (Tensor<float>) and mask (Tensor<bool>). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done.

Attributes

  • is_test: (int, default 0) if nonzero, run dropout in test mode where the output is simply Y = X. Default value is name: "is_test" type: INT i: 0

  • ratio: (float, default 0.5) the ratio of random dropout Default value is name: "ratio" type: FLOAT f: 0.5

Inputs

  • data (heterogeneous)T: The input data as Tensor.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T: The output mask. If is_test is nonzero, this output is not filled.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxDropout_7#

class skl2onnx.algebra.onnx_ops.OnnxDropout_7(*args, **kwargs)#

Version

Onnx name: Dropout

This version of the operator has been available since version 7.

Summary

Dropout takes one input data (Tensor<float>) and produces two Tensor outputs, output (Tensor<float>) and mask (Tensor<bool>). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • ratio: The ratio of random dropout Default value is name: "ratio" type: FLOAT f: 0.5

Inputs

  • data (heterogeneous)T: The input data as Tensor.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: The output.

  • mask (optional, heterogeneous)T: The output mask.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxDynamicQuantizeLinear#

class skl2onnx.algebra.onnx_ops.OnnxDynamicQuantizeLinear(*args, **kwargs)#

Version

Onnx name: DynamicQuantizeLinear

This version of the operator has been available since version 11.

Summary

A Function to fuse calculation for Scale, Zero Point and FP32->8Bit conversion of FP32 Input data. Outputs Scale, ZeroPoint and Quantized Input for a given FP32 Input. Scale is calculated as:

y_scale = (maximum(0, max(x)) - minimum(0, min(x))) / (qmax - qmin)
  • where qmax and qmin are max and min values for quantization range i.e. [0, 255] in case of uint8

  • data range is adjusted to include 0.

Zero point is calculated as:

intermediate_zero_point = qmin - min(x)/y_scale
y_zero_point = cast(round(saturate(itermediate_zero_point)))
  • where qmax and qmin are max and min values for quantization range .i.e [0, 255] in case of uint8

  • for saturation, it saturates to [0, 255] if it’s uint8, or [-127, 127] if it’s int8. Right now only uint8 is supported.

  • rounding to nearest ties to even.

Data quantization formula is:

y = saturate (round (x / y_scale) + y_zero_point)
  • for saturation, it saturates to [0, 255] if it’s uint8, or [-127, 127] if it’s int8. Right now only uint8 is supported.

  • rounding to nearest ties to even.

Inputs

  • x (heterogeneous)T1: Input tensor

Outputs

  • y (heterogeneous)T2: Quantized output tensor

  • y_scale (heterogeneous)tensor(float): Output scale. It’s a scalar, which means a per-tensor/layer quantization.

  • y_zero_point (heterogeneous)T2: Output zero point. It’s a scalar, which means a per-tensor/layer quantization.

Type Constraints

  • T1 tensor(float): Constrain ‘x’ to float tensor.

  • T2 tensor(uint8): Constrain ‘y_zero_point’ and ‘y’ to 8-bit unsigned integer tensor.

OnnxDynamicQuantizeLinear_11#

class skl2onnx.algebra.onnx_ops.OnnxDynamicQuantizeLinear_11(*args, **kwargs)#

Version

Onnx name: DynamicQuantizeLinear

This version of the operator has been available since version 11.

Summary

A Function to fuse calculation for Scale, Zero Point and FP32->8Bit conversion of FP32 Input data. Outputs Scale, ZeroPoint and Quantized Input for a given FP32 Input. Scale is calculated as:

y_scale = (maximum(0, max(x)) - minimum(0, min(x))) / (qmax - qmin)
  • where qmax and qmin are max and min values for quantization range i.e. [0, 255] in case of uint8

  • data range is adjusted to include 0.

Zero point is calculated as:

intermediate_zero_point = qmin - min(x)/y_scale
y_zero_point = cast(round(saturate(itermediate_zero_point)))
  • where qmax and qmin are max and min values for quantization range .i.e [0, 255] in case of uint8

  • for saturation, it saturates to [0, 255] if it’s uint8, or [-127, 127] if it’s int8. Right now only uint8 is supported.

  • rounding to nearest ties to even.

Data quantization formula is:

y = saturate (round (x / y_scale) + y_zero_point)
  • for saturation, it saturates to [0, 255] if it’s uint8, or [-127, 127] if it’s int8. Right now only uint8 is supported.

  • rounding to nearest ties to even.

Inputs

  • x (heterogeneous)T1: Input tensor

Outputs

  • y (heterogeneous)T2: Quantized output tensor

  • y_scale (heterogeneous)tensor(float): Output scale. It’s a scalar, which means a per-tensor/layer quantization.

  • y_zero_point (heterogeneous)T2: Output zero point. It’s a scalar, which means a per-tensor/layer quantization.

Type Constraints

  • T1 tensor(float): Constrain ‘x’ to float tensor.

  • T2 tensor(uint8): Constrain ‘y_zero_point’ and ‘y’ to 8-bit unsigned integer tensor.

OnnxEinsum#

class skl2onnx.algebra.onnx_ops.OnnxEinsum(*args, **kwargs)#

Version

Onnx name: Einsum

This version of the operator has been available since version 12.

Summary

An einsum of the form term1, term2 -> output-term produces an output tensor using the following equation

output[output-term] = reduce-sum( input1[term1] * input2[term2] )

where the reduce-sum performs a summation over all the indices occurring in the input terms (term1, term2) that do not occur in the output-term.

The Einsum operator evaluates algebraic tensor operations on a sequence of tensors, using the Einstein summation convention. The equation string contains a comma-separated sequence of lower case letters. Each term corresponds to an operand tensor, and the characters within the terms correspond to operands dimensions.

This sequence may be followed by “->” to separate the left and right hand side of the equation. If the equation contains “->” followed by the right-hand side, the explicit (not classical) form of the Einstein summation is performed, and the right-hand side indices indicate output tensor dimensions. In other cases, output indices are (implicitly) set to the alphabetically sorted sequence of indices appearing exactly once in the equation.

When a dimension character is repeated in the left-hand side, it represents summation along the dimension.

The equation may contain ellipsis (”…”) to enable broadcasting. Ellipsis must indicate a fixed number of dimensions. Specifically, every occurrence of ellipsis in the equation must represent the same number of dimensions. The right-hand side may contain exactly one ellipsis. In implicit mode, the ellipsis dimensions are set to the beginning of the output. The equation string may contain space (U+0020) character.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • Inputs (variadic, heterogeneous)T: Operands

Outputs

  • Output (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numerical tensor types.

OnnxEinsum_12#

class skl2onnx.algebra.onnx_ops.OnnxEinsum_12(*args, **kwargs)#

Version

Onnx name: Einsum

This version of the operator has been available since version 12.

Summary

An einsum of the form term1, term2 -> output-term produces an output tensor using the following equation

output[output-term] = reduce-sum( input1[term1] * input2[term2] )

where the reduce-sum performs a summation over all the indices occurring in the input terms (term1, term2) that do not occur in the output-term.

The Einsum operator evaluates algebraic tensor operations on a sequence of tensors, using the Einstein summation convention. The equation string contains a comma-separated sequence of lower case letters. Each term corresponds to an operand tensor, and the characters within the terms correspond to operands dimensions.

This sequence may be followed by “->” to separate the left and right hand side of the equation. If the equation contains “->” followed by the right-hand side, the explicit (not classical) form of the Einstein summation is performed, and the right-hand side indices indicate output tensor dimensions. In other cases, output indices are (implicitly) set to the alphabetically sorted sequence of indices appearing exactly once in the equation.

When a dimension character is repeated in the left-hand side, it represents summation along the dimension.

The equation may contain ellipsis (”…”) to enable broadcasting. Ellipsis must indicate a fixed number of dimensions. Specifically, every occurrence of ellipsis in the equation must represent the same number of dimensions. The right-hand side may contain exactly one ellipsis. In implicit mode, the ellipsis dimensions are set to the beginning of the output. The equation string may contain space (U+0020) character.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • Inputs (variadic, heterogeneous)T: Operands

Outputs

  • Output (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numerical tensor types.

OnnxElu#

class skl2onnx.algebra.onnx_ops.OnnxElu(*args, **kwargs)#

Version

Onnx name: Elu

This version of the operator has been available since version 6.

Summary

Elu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the function f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0., is applied to the tensor elementwise.

Attributes

  • alpha: Coefficient of ELU. Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: 1D input tensor

Outputs

  • Y (heterogeneous)T: 1D output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxElu_1#

class skl2onnx.algebra.onnx_ops.OnnxElu_1(*args, **kwargs)#

Version

Onnx name: Elu

This version of the operator has been available since version 1.

Summary

Elu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the function f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0., is applied to the tensor elementwise.

Attributes

  • alpha: Coefficient of ELU default to 1.0. Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: 1D input tensor

Outputs

  • Y (heterogeneous)T: 1D input tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxElu_6#

class skl2onnx.algebra.onnx_ops.OnnxElu_6(*args, **kwargs)#

Version

Onnx name: Elu

This version of the operator has been available since version 6.

Summary

Elu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the function f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0., is applied to the tensor elementwise.

Attributes

  • alpha: Coefficient of ELU. Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: 1D input tensor

Outputs

  • Y (heterogeneous)T: 1D output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxEqual#

class skl2onnx.algebra.onnx_ops.OnnxEqual(*args, **kwargs)#

Version

Onnx name: Equal

This version of the operator has been available since version 19.

Summary

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(string): Constrain input types to all (non-complex) tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxEqual_1#

class skl2onnx.algebra.onnx_ops.OnnxEqual_1(*args, **kwargs)#

Version

Onnx name: Equal

This version of the operator has been available since version 1.

Summary

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Attributes

  • broadcast: Enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: Left input tensor for the logical operator.

  • B (heterogeneous)T: Right input tensor for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool), tensor(int32), tensor(int64): Constrain input to integral tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxEqual_11#

class skl2onnx.algebra.onnx_ops.OnnxEqual_11(*args, **kwargs)#

Version

Onnx name: Equal

This version of the operator has been available since version 11.

Summary

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxEqual_13#

class skl2onnx.algebra.onnx_ops.OnnxEqual_13(*args, **kwargs)#

Version

Onnx name: Equal

This version of the operator has been available since version 13.

Summary

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxEqual_19#

class skl2onnx.algebra.onnx_ops.OnnxEqual_19(*args, **kwargs)#

Version

Onnx name: Equal

This version of the operator has been available since version 19.

Summary

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(string): Constrain input types to all (non-complex) tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxEqual_7#

class skl2onnx.algebra.onnx_ops.OnnxEqual_7(*args, **kwargs)#

Version

Onnx name: Equal

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool), tensor(int32), tensor(int64): Constrain input to integral tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxErf#

class skl2onnx.algebra.onnx_ops.OnnxErf(*args, **kwargs)#

Version

Onnx name: Erf

This version of the operator has been available since version 13.

Summary

Computes the error function of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The error function of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxErf_13#

class skl2onnx.algebra.onnx_ops.OnnxErf_13(*args, **kwargs)#

Version

Onnx name: Erf

This version of the operator has been available since version 13.

Summary

Computes the error function of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The error function of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxErf_9#

class skl2onnx.algebra.onnx_ops.OnnxErf_9(*args, **kwargs)#

Version

Onnx name: Erf

This version of the operator has been available since version 9.

Summary

Computes the error function of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The error function of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxExp#

class skl2onnx.algebra.onnx_ops.OnnxExp(*args, **kwargs)#

Version

Onnx name: Exp

This version of the operator has been available since version 13.

Summary

Calculates the exponential of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The exponential of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxExp_1#

class skl2onnx.algebra.onnx_ops.OnnxExp_1(*args, **kwargs)#

Version

Onnx name: Exp

This version of the operator has been available since version 1.

Summary

Calculates the exponential of the given input tensor, element-wise.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The exponential of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxExp_13#

class skl2onnx.algebra.onnx_ops.OnnxExp_13(*args, **kwargs)#

Version

Onnx name: Exp

This version of the operator has been available since version 13.

Summary

Calculates the exponential of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The exponential of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxExp_6#

class skl2onnx.algebra.onnx_ops.OnnxExp_6(*args, **kwargs)#

Version

Onnx name: Exp

This version of the operator has been available since version 6.

Summary

Calculates the exponential of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The exponential of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxExpand#

class skl2onnx.algebra.onnx_ops.OnnxExpand(*args, **kwargs)#

Version

Onnx name: Expand

This version of the operator has been available since version 13.

Summary

Broadcast the input tensor following the given shape and the broadcast rule. The broadcast rule is similar to numpy.array(input) * numpy.ones(shape): Dimensions are right alignment; Two corresponding dimensions must have the same value, or one of them is equal to 1. Also, this operator is similar to numpy.broadcast_to(input, shape), but the major difference is numpy.broadcast_to() does not allow shape to be smaller than input.size(). It is possible that the output.shape is not equal to shape, when some dimensions in shape is equal to 1, or the shape.ndim < input.shape.ndim.

Inputs

  • input (heterogeneous)T: Input tensor

  • shape (heterogeneous)tensor(int64): A 1-D tensor indicates the shape you want to expand to, following the broadcast rule

Outputs

  • output (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensors.

OnnxExpand_13#

class skl2onnx.algebra.onnx_ops.OnnxExpand_13(*args, **kwargs)#

Version

Onnx name: Expand

This version of the operator has been available since version 13.

Summary

Broadcast the input tensor following the given shape and the broadcast rule. The broadcast rule is similar to numpy.array(input) * numpy.ones(shape): Dimensions are right alignment; Two corresponding dimensions must have the same value, or one of them is equal to 1. Also, this operator is similar to numpy.broadcast_to(input, shape), but the major difference is numpy.broadcast_to() does not allow shape to be smaller than input.size(). It is possible that the output.shape is not equal to shape, when some dimensions in shape is equal to 1, or the shape.ndim < input.shape.ndim.

Inputs

  • input (heterogeneous)T: Input tensor

  • shape (heterogeneous)tensor(int64): A 1-D tensor indicates the shape you want to expand to, following the broadcast rule

Outputs

  • output (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensors.

OnnxExpand_8#

class skl2onnx.algebra.onnx_ops.OnnxExpand_8(*args, **kwargs)#

Version

Onnx name: Expand

This version of the operator has been available since version 8.

Summary

Broadcast the input tensor following the given shape and the broadcast rule. The broadcast rule is similar to numpy.array(input) * numpy.ones(shape): Dimensions are right alignment; Two corresponding dimensions must have the same value, or one of them is equal to 1. Also, this operator is similar to numpy.broadcast_to(input, shape), but the major difference is numpy.broadcast_to() does not allow shape to be smaller than input.size(). It is possible that the output.shape is not equal to shape, when some dimensions in shape is equal to 1, or the shape.ndim < input.shape.ndim.

Inputs

  • input (heterogeneous)T: Input tensor

  • shape (heterogeneous)tensor(int64): A 1-D tensor indicates the shape you want to expand to, following the broadcast rule

Outputs

  • output (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensors.

OnnxEyeLike#

class skl2onnx.algebra.onnx_ops.OnnxEyeLike(*args, **kwargs)#

Version

Onnx name: EyeLike

This version of the operator has been available since version 9.

Summary

Generate a 2D tensor (matrix) with ones on the diagonal and zeros everywhere else. Only 2D tensors are supported, i.e. input T1 must be of rank 2. The shape of the output tensor is the same as the input tensor. The data type can be specified by the ‘dtype’ argument. If ‘dtype’ is not specified, then the type of input tensor is used. By default, the main diagonal is populated with ones, but attribute ‘k’ can be used to populate upper or lower diagonals. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message and be valid as an output type.

Attributes

  • k: (Optional) Index of the diagonal to be populated with ones. Default is 0. If T2 is the output, this op sets T2[i, i+k] = 1. k = 0 populates the main diagonal, k > 0 populates an upper diagonal, and k < 0 populates a lower diagonal. Default value is name: "k" type: INT i: 0

Inputs

  • input (heterogeneous)T1: 2D input tensor to copy shape, and optionally, type information from.

Outputs

  • output (heterogeneous)T2: Output tensor, same shape as input tensor T1.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain input types. Strings and complex are not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain output types. Strings and complex are not supported.

OnnxEyeLike_9#

class skl2onnx.algebra.onnx_ops.OnnxEyeLike_9(*args, **kwargs)#

Version

Onnx name: EyeLike

This version of the operator has been available since version 9.

Summary

Generate a 2D tensor (matrix) with ones on the diagonal and zeros everywhere else. Only 2D tensors are supported, i.e. input T1 must be of rank 2. The shape of the output tensor is the same as the input tensor. The data type can be specified by the ‘dtype’ argument. If ‘dtype’ is not specified, then the type of input tensor is used. By default, the main diagonal is populated with ones, but attribute ‘k’ can be used to populate upper or lower diagonals. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message and be valid as an output type.

Attributes

  • k: (Optional) Index of the diagonal to be populated with ones. Default is 0. If T2 is the output, this op sets T2[i, i+k] = 1. k = 0 populates the main diagonal, k > 0 populates an upper diagonal, and k < 0 populates a lower diagonal. Default value is name: "k" type: INT i: 0

Inputs

  • input (heterogeneous)T1: 2D input tensor to copy shape, and optionally, type information from.

Outputs

  • output (heterogeneous)T2: Output tensor, same shape as input tensor T1.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain input types. Strings and complex are not supported.

  • T2 tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool): Constrain output types. Strings and complex are not supported.

OnnxFeatureVectorizer#

class skl2onnx.algebra.onnx_ops.OnnxFeatureVectorizer(*args, **kwargs)#

Version

Onnx name: FeatureVectorizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Concatenates input tensors into one continuous output.

All input shapes are 2-D and are concatenated along the second dimension. 1-D tensors are treated as [1,C]. Inputs are copied to the output maintaining the order of the input arguments.

All inputs must be integers or floats, while the output will be all floating point values.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • X (variadic, heterogeneous)T1: An ordered collection of tensors, all with the same element type.

Outputs

  • Y (heterogeneous)tensor(float): The output array, elements ordered as the inputs.

Type Constraints

  • T1 tensor(int32), tensor(int64), tensor(float), tensor(double): The input type must be a tensor of a numeric type.

OnnxFeatureVectorizer_1#

class skl2onnx.algebra.onnx_ops.OnnxFeatureVectorizer_1(*args, **kwargs)#

Version

Onnx name: FeatureVectorizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Concatenates input tensors into one continuous output.

All input shapes are 2-D and are concatenated along the second dimension. 1-D tensors are treated as [1,C]. Inputs are copied to the output maintaining the order of the input arguments.

All inputs must be integers or floats, while the output will be all floating point values.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • X (variadic, heterogeneous)T1: An ordered collection of tensors, all with the same element type.

Outputs

  • Y (heterogeneous)tensor(float): The output array, elements ordered as the inputs.

Type Constraints

  • T1 tensor(int32), tensor(int64), tensor(float), tensor(double): The input type must be a tensor of a numeric type.

OnnxFlatten#

class skl2onnx.algebra.onnx_ops.OnnxFlatten(*args, **kwargs)#

Version

Onnx name: Flatten

This version of the operator has been available since version 21.

Summary

Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n) then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn).

Attributes

  • axis: Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output. The value for axis must be in the range [-r, r], where r is the rank of the input tensor. Negative value means counting dimensions from the back. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 … d_n), where the shape of the input tensor is (d_0, d_1, … d_n). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: A tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: A 2D tensor with the contents of the input tensor, with input dimensions up to axis flattened to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output to all tensor types up to IRv10.

OnnxFlatten_1#

class skl2onnx.algebra.onnx_ops.OnnxFlatten_1(*args, **kwargs)#

Version

Onnx name: Flatten

This version of the operator has been available since version 1.

Summary

Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n) then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn).

Attributes

  • axis: Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output. The value for axis must be in the range [0, R], where R is the rank of the input tensor. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 … d_n), where the shape of the input tensor is (d_0, d_1, … d_n). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: A tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: A 2D tensor with the contents of the input tensor, with input dimensions up to axis flattened to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxFlatten_11#

class skl2onnx.algebra.onnx_ops.OnnxFlatten_11(*args, **kwargs)#

Version

Onnx name: Flatten

This version of the operator has been available since version 11.

Summary

Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n) then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn).

Attributes

  • axis: Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output. The value for axis must be in the range [-r, r], where r is the rank of the input tensor. Negative value means counting dimensions from the back. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 … d_n), where the shape of the input tensor is (d_0, d_1, … d_n). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: A tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: A 2D tensor with the contents of the input tensor, with input dimensions up to axis flattened to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output to all tensor types.

OnnxFlatten_13#

class skl2onnx.algebra.onnx_ops.OnnxFlatten_13(*args, **kwargs)#

Version

Onnx name: Flatten

This version of the operator has been available since version 13.

Summary

Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n) then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn).

Attributes

  • axis: Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output. The value for axis must be in the range [-r, r], where r is the rank of the input tensor. Negative value means counting dimensions from the back. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 … d_n), where the shape of the input tensor is (d_0, d_1, … d_n). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: A tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: A 2D tensor with the contents of the input tensor, with input dimensions up to axis flattened to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output to all tensor types.

OnnxFlatten_21#

class skl2onnx.algebra.onnx_ops.OnnxFlatten_21(*args, **kwargs)#

Version

Onnx name: Flatten

This version of the operator has been available since version 21.

Summary

Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n) then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn).

Attributes

  • axis: Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output. The value for axis must be in the range [-r, r], where r is the rank of the input tensor. Negative value means counting dimensions from the back. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 … d_n), where the shape of the input tensor is (d_0, d_1, … d_n). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: A tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: A 2D tensor with the contents of the input tensor, with input dimensions up to axis flattened to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output to all tensor types up to IRv10.

OnnxFlatten_9#

class skl2onnx.algebra.onnx_ops.OnnxFlatten_9(*args, **kwargs)#

Version

Onnx name: Flatten

This version of the operator has been available since version 9.

Summary

Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n) then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn).

Attributes

  • axis: Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output. The value for axis must be in the range [0, R], where R is the rank of the input tensor. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 … d_n), where the shape of the input tensor is (d_0, d_1, … d_n). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: A tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: A 2D tensor with the contents of the input tensor, with input dimensions up to axis flattened to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output to all tensor types.

OnnxFloor#

class skl2onnx.algebra.onnx_ops.OnnxFloor(*args, **kwargs)#

Version

Onnx name: Floor

This version of the operator has been available since version 13.

Summary

Floor takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the floor is, y = floor(x), is applied to the tensor elementwise. If x is integral, +0, -0, NaN, or infinite, x itself is returned.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxFloor_1#

class skl2onnx.algebra.onnx_ops.OnnxFloor_1(*args, **kwargs)#

Version

Onnx name: Floor

This version of the operator has been available since version 1.

Summary

Floor takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the floor is, y = floor(x), is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxFloor_13#

class skl2onnx.algebra.onnx_ops.OnnxFloor_13(*args, **kwargs)#

Version

Onnx name: Floor

This version of the operator has been available since version 13.

Summary

Floor takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the floor is, y = floor(x), is applied to the tensor elementwise. If x is integral, +0, -0, NaN, or infinite, x itself is returned.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxFloor_6#

class skl2onnx.algebra.onnx_ops.OnnxFloor_6(*args, **kwargs)#

Version

Onnx name: Floor

This version of the operator has been available since version 6.

Summary

Floor takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the floor is, y = floor(x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGRU#

class skl2onnx.algebra.onnx_ops.OnnxGRU(*args, **kwargs)#

Version

Onnx name: GRU

This version of the operator has been available since version 14.

Summary

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

  • X - input tensor

  • z - update gate

  • r - reset gate

  • h - hidden gate

  • t - time step (t-1 means previous time step)

  • W[zrh] - W parameter weight matrix for update, reset, and hidden gates

  • R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

  • Wb[zrh] - W bias vectors for update, reset, and hidden gates

  • Rb[zrh] - R bias vectors for update, reset, and hidden gates

  • WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

  • RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

  • WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

  • RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

  • H - Hidden state

  • num_directions - 2 if direction == bidirectional else 1

Activation functions:

  • Relu(x) - max(0, x)

  • Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

  • Sigmoid(x) - 1/(1 + e^{-x})

NOTE:

Below are optional

  • Affine(x) - alpha * x + beta

  • LeakyRelu(x) - x if x >= 0 else alpha * x

  • ThresholdedRelu(x) - x if x >= alpha else 0

  • ScaledTanh(x) - alpha * Tanh(beta * x)

  • HardSigmoid(x) - min(max(alpha * x + beta, 0), 1)

  • Elu(x) - x if x >= 0 else alpha * (e^x - 1)

  • Softsign(x) - x/(1 + |x|)

  • Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

  • zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz)

  • rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr)

  • ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0

  • ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0

  • Ht = (1 - zt) (.) ht + zt (.) Ht-1

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • layout: The shape format of inputs X, initial_h and outputs Y, Y_h. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size]. Default value is name: "layout" type: INT i: 0

  • linear_before_reset: When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate. Default value is name: "linear_before_reset" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[zrh] and WB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[zrh] and RB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]] and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 6*hidden_size]. Optional: If not specified - assumed to be 0

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxGRU_1#

class skl2onnx.algebra.onnx_ops.OnnxGRU_1(*args, **kwargs)#

Version

Onnx name: GRU

This version of the operator has been available since version 1.

Summary

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

z - update gate

r - reset gate

h - hidden gate

t - time step (t-1 means previous time step)

W[zrh] - W parameter weight matrix for update, reset, and hidden gates

R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

Wb[zrh] - W bias vectors for update, reset, and hidden gates

Rb[zrh] - R bias vectors for update, reset, and hidden gates

WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

  • zt = f(Xt*(Wz^T) + Ht-1*Rz + Wbz + Rbz)

  • rt = f(Xt*(Wr^T) + Ht-1*Rr + Wbr + Rbr)

  • ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*Rh + Rbh + Wbh) # default, when linear_before_reset = 0

  • ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*Rh + Rbh) + Wbh) # when linear_before_reset != 0

  • Ht = (1 - zt) (.) ht + zt (.) Ht-1

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "foward"

  • output_sequence: The sequence output for the hidden is optional if 0. Default 0. Default value is name: "output_sequence" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[zrh] and WB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[zrh] and RB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]] and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 6*hidden_size]. Optional: If not specified - assumed to be 0

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size]. It is optional if output_sequence is 0.

  • Y_h (heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxGRU_14#

class skl2onnx.algebra.onnx_ops.OnnxGRU_14(*args, **kwargs)#

Version

Onnx name: GRU

This version of the operator has been available since version 14.

Summary

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

  • X - input tensor

  • z - update gate

  • r - reset gate

  • h - hidden gate

  • t - time step (t-1 means previous time step)

  • W[zrh] - W parameter weight matrix for update, reset, and hidden gates

  • R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

  • Wb[zrh] - W bias vectors for update, reset, and hidden gates

  • Rb[zrh] - R bias vectors for update, reset, and hidden gates

  • WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

  • RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

  • WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

  • RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

  • H - Hidden state

  • num_directions - 2 if direction == bidirectional else 1

Activation functions:

  • Relu(x) - max(0, x)

  • Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

  • Sigmoid(x) - 1/(1 + e^{-x})

NOTE:

Below are optional

  • Affine(x) - alpha * x + beta

  • LeakyRelu(x) - x if x >= 0 else alpha * x

  • ThresholdedRelu(x) - x if x >= alpha else 0

  • ScaledTanh(x) - alpha * Tanh(beta * x)

  • HardSigmoid(x) - min(max(alpha * x + beta, 0), 1)

  • Elu(x) - x if x >= 0 else alpha * (e^x - 1)

  • Softsign(x) - x/(1 + |x|)

  • Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

  • zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz)

  • rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr)

  • ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0

  • ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0

  • Ht = (1 - zt) (.) ht + zt (.) Ht-1

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • layout: The shape format of inputs X, initial_h and outputs Y, Y_h. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size]. Default value is name: "layout" type: INT i: 0

  • linear_before_reset: When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate. Default value is name: "linear_before_reset" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[zrh] and WB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[zrh] and RB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]] and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 6*hidden_size]. Optional: If not specified - assumed to be 0

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxGRU_3#

class skl2onnx.algebra.onnx_ops.OnnxGRU_3(*args, **kwargs)#

Version

Onnx name: GRU

This version of the operator has been available since version 3.

Summary

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

z - update gate

r - reset gate

h - hidden gate

t - time step (t-1 means previous time step)

W[zrh] - W parameter weight matrix for update, reset, and hidden gates

R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

Wb[zrh] - W bias vectors for update, reset, and hidden gates

Rb[zrh] - R bias vectors for update, reset, and hidden gates

WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

  • zt = f(Xt*(Wz^T) + Ht-1*Rz + Wbz + Rbz)

  • rt = f(Xt*(Wr^T) + Ht-1*Rr + Wbr + Rbr)

  • ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*Rh + Rbh + Wbh) # default, when linear_before_reset = 0

  • ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*Rh + Rbh) + Wbh) # when linear_before_reset != 0

  • Ht = (1 - zt) (.) ht + zt (.) Ht-1

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • linear_before_reset: When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate. Default value is name: "linear_before_reset" type: INT i: 0

  • output_sequence: The sequence output for the hidden is optional if 0. Default 0. Default value is name: "output_sequence" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[zrh] and WB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[zrh] and RB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]] and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 6*hidden_size]. Optional: If not specified - assumed to be 0

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size]. It is optional if output_sequence is 0.

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxGRU_7#

class skl2onnx.algebra.onnx_ops.OnnxGRU_7(*args, **kwargs)#

Version

Onnx name: GRU

This version of the operator has been available since version 7.

Summary

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

z - update gate

r - reset gate

h - hidden gate

t - time step (t-1 means previous time step)

W[zrh] - W parameter weight matrix for update, reset, and hidden gates

R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

Wb[zrh] - W bias vectors for update, reset, and hidden gates

Rb[zrh] - R bias vectors for update, reset, and hidden gates

WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

  • zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz)

  • rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr)

  • ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0

  • ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0

  • Ht = (1 - zt) (.) ht + zt (.) Ht-1

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • linear_before_reset: When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate. Default value is name: "linear_before_reset" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[zrh] and WB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[zrh] and RB[zrh] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 3*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]] and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 6*hidden_size]. Optional: If not specified - assumed to be 0

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxGather#

class skl2onnx.algebra.onnx_ops.OnnxGather(*args, **kwargs)#

Version

Onnx name: Gather

This version of the operator has been available since version 13.

Summary

Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them in an output tensor of rank q + (r - 1).

If axis = 0, let k = indices[i_{0}, …, i_{q-1}] then output[i_{0}, …, i_{q-1}, j_{0}, …, j_{r-2}] = input[k , j_{0}, …, j_{r-2}]:

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]
indices = [
    [0, 1],
    [1, 2],
]
output = [
    [
        [1.0, 1.2],
        [2.3, 3.4],
    ],
    [
        [2.3, 3.4],
        [4.5, 5.7],
    ],
]

If axis = 1, let k = indices[i_{0}, …, i_{q-1}] then output[j_{0}, i_{0}, …, i_{q-1}, j_{1}, …, j_{r-2}] = input[j_{0}, k, j_{1}, …, j_{r-2}]:

data = [
    [1.0, 1.2, 1.9],
    [2.3, 3.4, 3.9],
    [4.5, 5.7, 5.9],
]
indices = [
    [0, 2],
]
axis = 1,
output = [
        [[1.0, 1.9]],
        [[2.3, 3.9]],
        [[4.5, 5.9]],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + (r - 1).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGatherElements#

class skl2onnx.algebra.onnx_ops.OnnxGatherElements(*args, **kwargs)#

Version

Onnx name: GatherElements

This version of the operator has been available since version 13.

Summary

GatherElements takes two inputs data and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). It is an indexing operation that produces its output by indexing into the input data tensor at index positions determined by elements of the indices tensor. Its output shape is the same as the shape of indices and consists of one value (gathered from the data) for each element in indices.

For instance, in the 3-D case (r = 3), the output produced is determined by the following equations:

out[i][j][k] = input[index[i][j][k]][j][k] if axis = 0,
out[i][j][k] = input[i][index[i][j][k]][k] if axis = 1,
out[i][j][k] = input[i][j][index[i][j][k]] if axis = 2,

This operator is also the inverse of ScatterElements. It is similar to Torch’s gather operation.

Example 1:

data = [
    [1, 2],
    [3, 4],
]
indices = [
    [0, 0],
    [1, 0],
]
axis = 1
output = [
    [1, 1],
    [4, 3],
]

Example 2:

data = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
]
indices = [
    [1, 2, 0],
    [2, 0, 0],
]
axis = 0
output = [
    [4, 8, 3],
    [7, 2, 3],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, with the same rank r as the input. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of the same shape as indices.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGatherElements_11#

class skl2onnx.algebra.onnx_ops.OnnxGatherElements_11(*args, **kwargs)#

Version

Onnx name: GatherElements

This version of the operator has been available since version 11.

Summary

GatherElements takes two inputs data and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). It is an indexing operation that produces its output by indexing into the input data tensor at index positions determined by elements of the indices tensor. Its output shape is the same as the shape of indices and consists of one value (gathered from the data) for each element in indices.

For instance, in the 3-D case (r = 3), the output produced is determined by the following equations:

out[i][j][k] = input[index[i][j][k]][j][k] if axis = 0,
out[i][j][k] = input[i][index[i][j][k]][k] if axis = 1,
out[i][j][k] = input[i][j][index[i][j][k]] if axis = 2,

This operator is also the inverse of ScatterElements. It is similar to Torch’s gather operation.

Example 1:

data = [
    [1, 2],
    [3, 4],
]
indices = [
    [0, 0],
    [1, 0],
]
axis = 1
output = [
    [
      [1, 1],
      [4, 3],
    ],
]

Example 2:

data = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
]
indices = [
    [1, 2, 0],
    [2, 0, 0],
]
axis = 0
output = [
    [
      [4, 8, 3],
      [7, 2, 3],
    ],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, with the same rank r as the input. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of the same shape as indices.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGatherElements_13#

class skl2onnx.algebra.onnx_ops.OnnxGatherElements_13(*args, **kwargs)#

Version

Onnx name: GatherElements

This version of the operator has been available since version 13.

Summary

GatherElements takes two inputs data and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). It is an indexing operation that produces its output by indexing into the input data tensor at index positions determined by elements of the indices tensor. Its output shape is the same as the shape of indices and consists of one value (gathered from the data) for each element in indices.

For instance, in the 3-D case (r = 3), the output produced is determined by the following equations:

out[i][j][k] = input[index[i][j][k]][j][k] if axis = 0,
out[i][j][k] = input[i][index[i][j][k]][k] if axis = 1,
out[i][j][k] = input[i][j][index[i][j][k]] if axis = 2,

This operator is also the inverse of ScatterElements. It is similar to Torch’s gather operation.

Example 1:

data = [
    [1, 2],
    [3, 4],
]
indices = [
    [0, 0],
    [1, 0],
]
axis = 1
output = [
    [1, 1],
    [4, 3],
]

Example 2:

data = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
]
indices = [
    [1, 2, 0],
    [2, 0, 0],
]
axis = 0
output = [
    [4, 8, 3],
    [7, 2, 3],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, with the same rank r as the input. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of the same shape as indices.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGatherND#

class skl2onnx.algebra.onnx_ops.OnnxGatherND(*args, **kwargs)#

Version

Onnx name: GatherND

This version of the operator has been available since version 13.

Summary

Given data tensor of rank r >= 1, indices tensor of rank q >= 1, and batch_dims integer b, this operator gathers slices of data into an output tensor of rank q + r - indices_shape[-1] - 1 - b.

indices is an q-dimensional integer tensor, best thought of as a (q-1)-dimensional tensor of index-tuples into data, where each element defines a slice of data

batch_dims (denoted as b) is an integer indicating the number of batch dimensions, i.e the leading b number of dimensions of data tensor and indices are representing the batches, and the gather starts from the b+1 dimension.

Some salient points about the inputs’ rank and shape:

  1. r >= 1 and q >= 1 are to be honored. There is no dependency condition to be met between ranks r and q

  2. The first b dimensions of the shape of indices tensor and data tensor must be equal.

  3. b < min(q, r) is to be honored.

  4. The indices_shape[-1] should have a value between 1 (inclusive) and rank r-b (inclusive)

  5. All values in indices are expected to be within bounds [-s, s-1] along axis of size s (i.e.) -data_shape[i] <= indices[…,i] <= data_shape[i] - 1. It is an error if any of the index values are out of bounds.

The output is computed as follows:

The output tensor is obtained by mapping each index-tuple in the indices tensor to the corresponding slice of the input data.

  1. If indices_shape[-1] > r-b => error condition

  2. If indices_shape[-1] == r-b, since the rank of indices is q, indices can be thought of as N (q-b-1)-dimensional tensors containing 1-D tensors of dimension r-b, where N is an integer equals to the product of 1 and all the elements in the batch dimensions of the indices_shape. Let us think of each such r-b ranked tensor as indices_slice. Each scalar value corresponding to data[0:b-1,indices_slice] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Example 1 below)

  3. If indices_shape[-1] < r-b, since the rank of indices is q, indices can be thought of as N (q-b-1)-dimensional tensor containing 1-D tensors of dimension < r-b. Let us think of each such tensors as indices_slice. Each tensor slice corresponding to data[0:b-1, indices_slice , :] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Examples 2, 3, 4 and 5 below)

This operator is the inverse of ScatterND.

Example 1

batch_dims = 0
data    = [[0,1],[2,3]]   # data_shape    = [2, 2]
indices = [[0,0],[1,1]]   # indices_shape = [2, 2]
output  = [0,3]           # output_shape  = [2]

Example 2

batch_dims = 0
data    = [[0,1],[2,3]]  # data_shape    = [2, 2]
indices = [[1],[0]]      # indices_shape = [2, 1]
output  = [[2,3],[0,1]]  # output_shape  = [2, 2]

Example 3

batch_dims = 0
data    = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape    = [2, 2, 2]
indices = [[0,1],[1,0]]                 # indices_shape = [2, 2]
output  = [[2,3],[4,5]]                 # output_shape  = [2, 2]

Example 4

batch_dims = 0
data    = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape    = [2, 2, 2]
indices = [[[0,1]],[[1,0]]]             # indices_shape = [2, 1, 2]
output  = [[[2,3]],[[4,5]]]             # output_shape  = [2, 1, 2]

Example 5

batch_dims = 1
data    = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape    = [2, 2, 2]
indices = [[1],[0]]                     # indices_shape = [2, 1]
output  = [[2,3],[4,5]]                 # output_shape  = [2, 2]

Attributes

  • batch_dims: The number of batch dimensions. The gather of indexing starts from dimension of data[batch_dims:] Default value is name: "batch_dims" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxGatherND_11#

class skl2onnx.algebra.onnx_ops.OnnxGatherND_11(*args, **kwargs)#

Version

Onnx name: GatherND

This version of the operator has been available since version 11.

Summary

Given data tensor of rank r >= 1, and indices tensor of rank q >= 1, this operator gathers slices of data into an output tensor of rank q + r - indices_shape[-1] - 1.

indices is an q-dimensional integer tensor, best thought of as a (q-1)-dimensional tensor of index-tuples into data, where each element defines a slice of data

Some salient points about the inputs’ rank and shape:

  1. r >= 1 and q >= 1 are to be honored. There is no dependency condition to be met between ranks r and q

  2. The indices_shape[-1] should have a value between 1 (inclusive) and rank r (inclusive)

  3. All values in indices are expected to be within bounds [-s, s-1] along axis of size s (i.e.) -data_shape[i] <= indices[…,i] <= data_shape[i] - 1. It is an error if any of the index values are out of bounds.

The output is computed as follows:

The output tensor is obtained by mapping each index-tuple in the indices tensor to the corresponding slice of the input data.

  1. If indices_shape[-1] > r => error condition

  2. If indices_shape[-1] == r, since the rank of indices is q, indices can be thought of as a (q-1)-dimensional tensor containing 1-D tensors of dimension r. Let us think of each such r ranked tensor as indices_slice. Each scalar value corresponding to data[indices_slice] is filled into the corresponding location of the (q-1)-dimensional tensor to form the output tensor (Example 1 below)

  3. If indices_shape[-1] < r, since the rank of indices is q, indices can be thought of as a (q-1)-dimensional tensor containing 1-D tensors of dimension < r. Let us think of each such tensors as indices_slice. Each tensor slice corresponding to data[indices_slice , :] is filled into the corresponding location of the (q-1)-dimensional tensor to form the output tensor (Examples 2, 3, and 4 below)

This operator is the inverse of ScatterND.

Example 1

data = [[0,1],[2,3]] # data_shape = [2, 2]

indices = [[0,0],[1,1]] # indices_shape = [2, 2]

output = [0,3] # output_shape = [2]

Example 2

data = [[0,1],[2,3]] # data_shape = [2, 2]

indices = [[1],[0]] # indices_shape = [2, 1]

output = [[2,3],[0,1]] # output_shape = [2, 2]

Example 3

data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]

indices = [[0,1],[1,0]] # indices_shape = [2, 2]

output = [[2,3],[4,5]] # output_shape = [2, 2]

Example 4

data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]

indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]

output = [[[2,3]],[[4,5]]] # output_shape = [2, 1, 2]

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxGatherND_12#

class skl2onnx.algebra.onnx_ops.OnnxGatherND_12(*args, **kwargs)#

Version

Onnx name: GatherND

This version of the operator has been available since version 12.

Summary

Given data tensor of rank r >= 1, indices tensor of rank q >= 1, and batch_dims integer b, this operator gathers slices of data into an output tensor of rank q + r - indices_shape[-1] - 1 - b.

indices is an q-dimensional integer tensor, best thought of as a (q-1)-dimensional tensor of index-tuples into data, where each element defines a slice of data

batch_dims (denoted as b) is an integer indicating the number of batch dimensions, i.e the leading b number of dimensions of data tensor and indices are representing the batches, and the gather starts from the b+1 dimension.

Some salient points about the inputs’ rank and shape:

  1. r >= 1 and q >= 1 are to be honored. There is no dependency condition to be met between ranks r and q

  2. The first b dimensions of the shape of indices tensor and data tensor must be equal.

  3. b < min(q, r) is to be honored.

  4. The indices_shape[-1] should have a value between 1 (inclusive) and rank r-b (inclusive)

  5. All values in indices are expected to be within bounds [-s, s-1] along axis of size s (i.e.) -data_shape[i] <= indices[…,i] <= data_shape[i] - 1. It is an error if any of the index values are out of bounds.

The output is computed as follows:

The output tensor is obtained by mapping each index-tuple in the indices tensor to the corresponding slice of the input data.

  1. If indices_shape[-1] > r-b => error condition

  2. If indices_shape[-1] == r-b, since the rank of indices is q, indices can be thought of as N (q-b-1)-dimensional tensors containing 1-D tensors of dimension r-b, where N is an integer equals to the product of 1 and all the elements in the batch dimensions of the indices_shape. Let us think of each such r-b ranked tensor as indices_slice. Each scalar value corresponding to data[0:b-1,indices_slice] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Example 1 below)

  3. If indices_shape[-1] < r-b, since the rank of indices is q, indices can be thought of as N (q-b-1)-dimensional tensor containing 1-D tensors of dimension < r-b. Let us think of each such tensors as indices_slice. Each tensor slice corresponding to data[0:b-1, indices_slice , :] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Examples 2, 3, 4 and 5 below)

This operator is the inverse of ScatterND.

Example 1

batch_dims = 0

data = [[0,1],[2,3]] # data_shape = [2, 2]

indices = [[0,0],[1,1]] # indices_shape = [2, 2]

output = [0,3] # output_shape = [2]

Example 2

batch_dims = 0

data = [[0,1],[2,3]] # data_shape = [2, 2]

indices = [[1],[0]] # indices_shape = [2, 1]

output = [[2,3],[0,1]] # output_shape = [2, 2]

Example 3

batch_dims = 0

data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]

indices = [[0,1],[1,0]] # indices_shape = [2, 2]

output = [[2,3],[4,5]] # output_shape = [2, 2]

Example 4

batch_dims = 0

data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]

indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]

output = [[[2,3]],[[4,5]]] # output_shape = [2, 1, 2]

Example 5

batch_dims = 1

data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]

indices = [[1],[0]] # indices_shape = [2, 1]

output = [[2,3],[4,5]] # output_shape = [2, 2]

Attributes

  • batch_dims: The number of batch dimensions. The gather of indexing starts from dimension of data[batch_dims:] Default value is name: "batch_dims" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxGatherND_13#

class skl2onnx.algebra.onnx_ops.OnnxGatherND_13(*args, **kwargs)#

Version

Onnx name: GatherND

This version of the operator has been available since version 13.

Summary

Given data tensor of rank r >= 1, indices tensor of rank q >= 1, and batch_dims integer b, this operator gathers slices of data into an output tensor of rank q + r - indices_shape[-1] - 1 - b.

indices is an q-dimensional integer tensor, best thought of as a (q-1)-dimensional tensor of index-tuples into data, where each element defines a slice of data

batch_dims (denoted as b) is an integer indicating the number of batch dimensions, i.e the leading b number of dimensions of data tensor and indices are representing the batches, and the gather starts from the b+1 dimension.

Some salient points about the inputs’ rank and shape:

  1. r >= 1 and q >= 1 are to be honored. There is no dependency condition to be met between ranks r and q

  2. The first b dimensions of the shape of indices tensor and data tensor must be equal.

  3. b < min(q, r) is to be honored.

  4. The indices_shape[-1] should have a value between 1 (inclusive) and rank r-b (inclusive)

  5. All values in indices are expected to be within bounds [-s, s-1] along axis of size s (i.e.) -data_shape[i] <= indices[…,i] <= data_shape[i] - 1. It is an error if any of the index values are out of bounds.

The output is computed as follows:

The output tensor is obtained by mapping each index-tuple in the indices tensor to the corresponding slice of the input data.

  1. If indices_shape[-1] > r-b => error condition

  2. If indices_shape[-1] == r-b, since the rank of indices is q, indices can be thought of as N (q-b-1)-dimensional tensors containing 1-D tensors of dimension r-b, where N is an integer equals to the product of 1 and all the elements in the batch dimensions of the indices_shape. Let us think of each such r-b ranked tensor as indices_slice. Each scalar value corresponding to data[0:b-1,indices_slice] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Example 1 below)

  3. If indices_shape[-1] < r-b, since the rank of indices is q, indices can be thought of as N (q-b-1)-dimensional tensor containing 1-D tensors of dimension < r-b. Let us think of each such tensors as indices_slice. Each tensor slice corresponding to data[0:b-1, indices_slice , :] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Examples 2, 3, 4 and 5 below)

This operator is the inverse of ScatterND.

Example 1

batch_dims = 0
data    = [[0,1],[2,3]]   # data_shape    = [2, 2]
indices = [[0,0],[1,1]]   # indices_shape = [2, 2]
output  = [0,3]           # output_shape  = [2]

Example 2

batch_dims = 0
data    = [[0,1],[2,3]]  # data_shape    = [2, 2]
indices = [[1],[0]]      # indices_shape = [2, 1]
output  = [[2,3],[0,1]]  # output_shape  = [2, 2]

Example 3

batch_dims = 0
data    = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape    = [2, 2, 2]
indices = [[0,1],[1,0]]                 # indices_shape = [2, 2]
output  = [[2,3],[4,5]]                 # output_shape  = [2, 2]

Example 4

batch_dims = 0
data    = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape    = [2, 2, 2]
indices = [[[0,1]],[[1,0]]]             # indices_shape = [2, 1, 2]
output  = [[[2,3]],[[4,5]]]             # output_shape  = [2, 1, 2]

Example 5

batch_dims = 1
data    = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape    = [2, 2, 2]
indices = [[1],[0]]                     # indices_shape = [2, 1]
output  = [[2,3],[4,5]]                 # output_shape  = [2, 2]

Attributes

  • batch_dims: The number of batch dimensions. The gather of indexing starts from dimension of data[batch_dims:] Default value is name: "batch_dims" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxGather_1#

class skl2onnx.algebra.onnx_ops.OnnxGather_1(*args, **kwargs)#

Version

Onnx name: Gather

This version of the operator has been available since version 1.

Summary

Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them in an output tensor of rank q + (r - 1). Example 1:

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]
indices = [
    [0, 1],
    [1, 2],
]
output = [
    [
        [1.0, 1.2],
        [2.3, 3.4],
    ],
    [
        [2.3, 3.4],
        [4.5, 5.7],
    ],
]

Example 2:

data = [
    [1.0, 1.2, 1.9],
    [2.3, 3.4, 3.9],
    [4.5, 5.7, 5.9],
]
indices = [
    [0, 2],
]
axis = 1,
output = [
    [[1.0, 1.9]],
    [[2.3, 3.9]],
    [[4.5, 5.9]],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + (r - 1).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGather_11#

class skl2onnx.algebra.onnx_ops.OnnxGather_11(*args, **kwargs)#

Version

Onnx name: Gather

This version of the operator has been available since version 11.

Summary

Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them in an output tensor of rank q + (r - 1).

axis = 0 :

Let k = indices[i_{0}, …, i_{q-1}] Then output[i_{0}, …, i_{q-1}, j_{0}, …, j_{r-2}] = input[k , j_{0}, …, j_{r-2}]

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]
indices = [
    [0, 1],
    [1, 2],
]
output = [
    [
        [1.0, 1.2],
        [2.3, 3.4],
    ],
    [
        [2.3, 3.4],
        [4.5, 5.7],
    ],
]

axis = 1 :

Let k = indices[i_{0}, …, i_{q-1}] Then output[j_{0}, i_{0}, …, i_{q-1}, j_{1}, …, j_{r-2}] = input[j_{0}, k, j_{1}, …, j_{r-2}]

data = [
    [1.0, 1.2, 1.9],
    [2.3, 3.4, 3.9],
    [4.5, 5.7, 5.9],
]
indices = [
    [0, 2],
]
axis = 1,
output = [
    [[1.0, 1.9]],
    [[2.3, 3.9]],
    [[4.5, 5.9]],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + (r - 1).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGather_13#

class skl2onnx.algebra.onnx_ops.OnnxGather_13(*args, **kwargs)#

Version

Onnx name: Gather

This version of the operator has been available since version 13.

Summary

Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them in an output tensor of rank q + (r - 1).

If axis = 0, let k = indices[i_{0}, …, i_{q-1}] then output[i_{0}, …, i_{q-1}, j_{0}, …, j_{r-2}] = input[k , j_{0}, …, j_{r-2}]:

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]
indices = [
    [0, 1],
    [1, 2],
]
output = [
    [
        [1.0, 1.2],
        [2.3, 3.4],
    ],
    [
        [2.3, 3.4],
        [4.5, 5.7],
    ],
]

If axis = 1, let k = indices[i_{0}, …, i_{q-1}] then output[j_{0}, i_{0}, …, i_{q-1}, j_{1}, …, j_{r-2}] = input[j_{0}, k, j_{1}, …, j_{r-2}]:

data = [
    [1.0, 1.2, 1.9],
    [2.3, 3.4, 3.9],
    [4.5, 5.7, 5.9],
]
indices = [
    [0, 2],
]
axis = 1,
output = [
        [[1.0, 1.9]],
        [[2.3, 3.9]],
        [[4.5, 5.9]],
]

Attributes

  • axis: Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

Outputs

  • output (heterogeneous)T: Tensor of rank q + (r - 1).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxGelu#

class skl2onnx.algebra.onnx_ops.OnnxGelu(*args, **kwargs)#

Version

Onnx name: Gelu

This version of the operator has been available since version 20.

Summary

Gelu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the gaussian error linear units function, $y = 0.5 * x * (1 + erf(x/sqrt(2)))$ is applied to the tensor elementwise. If the attribute “approximate” is set to “tanh”, the function estimation, $y = 0.5 * x * (1 + Tanh(sqrt(2/pi) * (x + 0.044715 * x^3)))$ is used and applied to the tensor elementwise.

Attributes

  • approximate: Gelu approximation algorithm: “tanh”, “none”`(default).”none”: do not use approximation.”tanh”: use tanh approximation. Default value is ``name: “approximate” type: STRING s: “none”`

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxGelu_20#

class skl2onnx.algebra.onnx_ops.OnnxGelu_20(*args, **kwargs)#

Version

Onnx name: Gelu

This version of the operator has been available since version 20.

Summary

Gelu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the gaussian error linear units function, $y = 0.5 * x * (1 + erf(x/sqrt(2)))$ is applied to the tensor elementwise. If the attribute “approximate” is set to “tanh”, the function estimation, $y = 0.5 * x * (1 + Tanh(sqrt(2/pi) * (x + 0.044715 * x^3)))$ is used and applied to the tensor elementwise.

Attributes

  • approximate: Gelu approximation algorithm: “tanh”, “none”`(default).”none”: do not use approximation.”tanh”: use tanh approximation. Default value is ``name: “approximate” type: STRING s: “none”`

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxGemm#

class skl2onnx.algebra.onnx_ops.OnnxGemm(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 13.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

  • A’ = transpose(A) if transA else A

  • B’ = transpose(B) if transB else B

Compute Y = alpha * A’ * B’ + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check Broadcasting in ONNX. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C. Default value is name: "beta" type: FLOAT f: 1

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

Between 2 and 3 inputs.

  • A (heterogeneous)T: Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.

  • B (heterogeneous)T: Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.

  • C (optional, heterogeneous)T: Optional input tensor C. If not specified, the computation is done as if C is a scalar 0. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

  • Y (heterogeneous)T: Output tensor of shape (M, N).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(bfloat16): Constrain input and output types to float/int tensors.

OnnxGemm_1#

class skl2onnx.algebra.onnx_ops.OnnxGemm_1(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 1.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3 Compute Y = alpha * A * B + beta * C, where input tensor A has dimension (M X K), input tensor B has dimension (K X N), input tensor C and output tensor Y have dimension (M X N). If attribute broadcast is non-zero, input tensor C will be broadcasted to match the dimension requirement. A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B, the default value is 1.0. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C, the default value is 1.0. Default value is name: "beta" type: FLOAT f: 1

  • broadcast: Whether C should be broadcasted Default value is name: "broadcast" type: INT i: 0

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

  • A (heterogeneous)T: Input tensor A

  • B (heterogeneous)T: Input tensor B

  • C (heterogeneous)T: Input tensor C, can be inplace.

Outputs

  • Y (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGemm_11#

class skl2onnx.algebra.onnx_ops.OnnxGemm_11(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 11.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

A’ = transpose(A) if transA else A

B’ = transpose(B) if transB else B

Compute Y = alpha * A’ * B’ + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check Broadcasting in ONNX. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C. Default value is name: "beta" type: FLOAT f: 1

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

Between 2 and 3 inputs.

  • A (heterogeneous)T: Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.

  • B (heterogeneous)T: Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.

  • C (optional, heterogeneous)T: Optional input tensor C. If not specified, the computation is done as if C is a scalar 0. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

  • Y (heterogeneous)T: Output tensor of shape (M, N).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64): Constrain input and output types to float/int tensors.

OnnxGemm_13#

class skl2onnx.algebra.onnx_ops.OnnxGemm_13(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 13.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

  • A’ = transpose(A) if transA else A

  • B’ = transpose(B) if transB else B

Compute Y = alpha * A’ * B’ + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check Broadcasting in ONNX. This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C. Default value is name: "beta" type: FLOAT f: 1

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

Between 2 and 3 inputs.

  • A (heterogeneous)T: Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.

  • B (heterogeneous)T: Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.

  • C (optional, heterogeneous)T: Optional input tensor C. If not specified, the computation is done as if C is a scalar 0. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

  • Y (heterogeneous)T: Output tensor of shape (M, N).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(bfloat16): Constrain input and output types to float/int tensors.

OnnxGemm_6#

class skl2onnx.algebra.onnx_ops.OnnxGemm_6(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 6.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3 Compute Y = alpha * A * B + beta * C, where input tensor A has dimension (M X K), input tensor B has dimension (K X N), input tensor C and output tensor Y have dimension (M X N). If attribute broadcast is non-zero, input tensor C will be broadcasted to match the dimension requirement. A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B, the default value is 1.0. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C, the default value is 1.0. Default value is name: "beta" type: FLOAT f: 1

  • broadcast: Whether C should be broadcasted Default value is name: "broadcast" type: INT i: 0

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

  • A (heterogeneous)T: Input tensor A

  • B (heterogeneous)T: Input tensor B

  • C (heterogeneous)T: Input tensor C

Outputs

  • Y (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGemm_7#

class skl2onnx.algebra.onnx_ops.OnnxGemm_7(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 7.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

A’ = transpose(A) if transA else A

B’ = transpose(B) if transB else B

Compute Y = alpha * A’ * B’ + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check Broadcasting in ONNX.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C. Default value is name: "beta" type: FLOAT f: 1

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

  • A (heterogeneous)T: Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.

  • B (heterogeneous)T: Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.

  • C (heterogeneous)T: Input tensor C. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

  • Y (heterogeneous)T: Output tensor of shape (M, N).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGemm_9#

class skl2onnx.algebra.onnx_ops.OnnxGemm_9(*args, **kwargs)#

Version

Onnx name: Gemm

This version of the operator has been available since version 9.

Summary

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

A’ = transpose(A) if transA else A

B’ = transpose(B) if transB else B

Compute Y = alpha * A’ * B’ + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check Broadcasting in ONNX.

Attributes

  • alpha: Scalar multiplier for the product of input tensors A * B. Default value is name: "alpha" type: FLOAT f: 1

  • beta: Scalar multiplier for input tensor C. Default value is name: "beta" type: FLOAT f: 1

  • transA: Whether A should be transposed Default value is name: "transA" type: INT i: 0

  • transB: Whether B should be transposed Default value is name: "transB" type: INT i: 0

Inputs

  • A (heterogeneous)T: Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.

  • B (heterogeneous)T: Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.

  • C (heterogeneous)T: Input tensor C. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

  • Y (heterogeneous)T: Output tensor of shape (M, N).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64): Constrain input and output types to float/int tensors.

OnnxGlobalAveragePool#

class skl2onnx.algebra.onnx_ops.OnnxGlobalAveragePool(*args, **kwargs)#

Version

Onnx name: GlobalAveragePool

This version of the operator has been available since version 1.

Summary

GlobalAveragePool consumes an input tensor X and applies average pooling across the values in the same channel. This is equivalent to AveragePool with kernel size equal to the spatial dimension of input tensor.

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGlobalAveragePool_1#

class skl2onnx.algebra.onnx_ops.OnnxGlobalAveragePool_1(*args, **kwargs)#

Version

Onnx name: GlobalAveragePool

This version of the operator has been available since version 1.

Summary

GlobalAveragePool consumes an input tensor X and applies average pooling across the values in the same channel. This is equivalent to AveragePool with kernel size equal to the spatial dimension of input tensor.

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGlobalLpPool#

class skl2onnx.algebra.onnx_ops.OnnxGlobalLpPool(*args, **kwargs)#

Version

Onnx name: GlobalLpPool

This version of the operator has been available since version 2.

Summary

GlobalLpPool consumes an input tensor X and applies lp pool pooling across the values in the same channel. This is equivalent to LpPool with kernel size equal to the spatial dimension of input tensor.

Attributes

  • p: p value of the Lp norm used to pool over the input data. Default value is name: "p" type: INT i: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGlobalLpPool_1#

class skl2onnx.algebra.onnx_ops.OnnxGlobalLpPool_1(*args, **kwargs)#

Version

Onnx name: GlobalLpPool

This version of the operator has been available since version 1.

Summary

GlobalLpPool consumes an input tensor X and applies lp pool pooling across the the values in the same channel. This is equivalent to LpPool with kernel size equal to the spatial dimension of input tensor.

Attributes

  • p: p value of the Lp norm used to pool over the input data, default is 2.0. Default value is name: "p" type: FLOAT f: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimension are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. Dimensions will be N x C x 1 x 1

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGlobalLpPool_2#

class skl2onnx.algebra.onnx_ops.OnnxGlobalLpPool_2(*args, **kwargs)#

Version

Onnx name: GlobalLpPool

This version of the operator has been available since version 2.

Summary

GlobalLpPool consumes an input tensor X and applies lp pool pooling across the values in the same channel. This is equivalent to LpPool with kernel size equal to the spatial dimension of input tensor.

Attributes

  • p: p value of the Lp norm used to pool over the input data. Default value is name: "p" type: INT i: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGlobalMaxPool#

class skl2onnx.algebra.onnx_ops.OnnxGlobalMaxPool(*args, **kwargs)#

Version

Onnx name: GlobalMaxPool

This version of the operator has been available since version 1.

Summary

GlobalMaxPool consumes an input tensor X and applies max pooling across the values in the same channel. This is equivalent to MaxPool with kernel size equal to the spatial dimension of input tensor.

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGlobalMaxPool_1#

class skl2onnx.algebra.onnx_ops.OnnxGlobalMaxPool_1(*args, **kwargs)#

Version

Onnx name: GlobalMaxPool

This version of the operator has been available since version 1.

Summary

GlobalMaxPool consumes an input tensor X and applies max pooling across the values in the same channel. This is equivalent to MaxPool with kernel size equal to the spatial dimension of input tensor.

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxGradient#

class skl2onnx.algebra.onnx_ops.OnnxGradient(*args, **kwargs)#

Version

Onnx name: Gradient

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Gradient operator computes the partial derivatives of a specific tensor w.r.t. some other tensors. This operator is widely used in gradient-based training algorithms. To illustrate its use, let’s consider a computation graph,

X -----.
       |
       v
W --> Conv --> H --> Gemm --> Y
                      ^
                      |
                      Z

, where W and Z are trainable tensors. Note that operators’ attributes are omitted for the sake of simplicity. Let dY/dW (dY/dZ) be the gradient of Y with respect to W (Z). The user can compute gradient by inserting Gradient operator to form another graph shown below.

W --> Conv --> H --> Gemm --> Y
|      ^              ^
|      |              |
|      X              Z
|      |              |
|      |   .----------'
|      |   |  (W/Z/X is the 1st/2nd/3rd input of Gradient as shown in
|      |   |   "xs" followed by "zs")
|      v   v
'---> Gradient(xs=["W", "Z"], zs=["X"], y="Y")
       |   |
       |   '-----------------------------------> dY/dW (1st output of Gradient)
       |
       '---------------------------------------> dY/dZ (2nd output of Gradient)

By definition, the tensor “y” is a function of independent variables in “xs” and “zs”. Since we only compute the gradient of “y” w.r.t. the differentiable variables in “xs”, this Gradient only outputs dY/dW and dY/dZ. Note that “H” cannot appear in “xs” and “zs”. The reason is that “H” can be determined by tensors “W” and “X” and therefore “H” is not an independent variable.

All outputs are optional. If needed, for example, user can assign an empty string to the 1st output name of that Gradient to skip the generation of dY/dW. Note that the concept of optional outputs can also be found in ONNX’s RNN, GRU, and LSTM.

Gradient operator can compute derivative against intermediate tensors. For example, the gradient of Y with respect to H can be done via

W --> Conv --> H --> Gemm --> Y
       ^       |      ^
       |       |      |
       X       |      Z
       .-------'      |
       |   .----------'
       |   | (H/Z is the 1st/2nd input of Gradient as shown in "xs")
       v   v
      Gradient(xs=["H", "Z"], y="Y")
       |   |
       |   '-----------------------------------> dY/dH (1st output of Gradient)
       |
       '---------------------------------------> dY/dZ (2nd output of Gradient)

It is possible to represent high-order differentiation using Gradient operators. For example, given the following linear model:

W --> Gemm --> Y --> Loss --> O
       ^              ^
       |              |
       X              L

To compute the 2nd order derivative of O with respect to W (denoted by d^2O/dW^2), one can do

W --> Gemm --> Y --> Loss --> O
|      ^              ^
|      |              |
|      X .------------L
|      | |            |
|      | |            v
+------+-+> Gradient(xs=["X", "W"], zs=["L"], y="O") ---> dO/dX (1st output of Gradient)
|      | |    |
|      | |    '---> dO/dW (2nd output of Gradient)
|      v v
'---> Gradient(xs=["X", "W"], zs=["L"], y="dO/dW") ---> d(dO/dW)dX (1st output of
       |                                                  Gradient)
       |
       |
       '---> d^2O/dW^2 (2nd output of Gradient)

The tensors named in attributes “xs”, “zs”, and “y” define the differentiated computation graph, and the inputs to Gradient node define the values at which the gradient is computed. We can feed different tensors to the identified graph. For example, one can compute the gradient of Y with respect to H at a specific value of H, H_1, by providing that value as an input to the Gradient node.

W --> Conv --> H --> Gemm --> Y
       ^              ^
       |              |
       X              Z

          Z_1 (2nd input of Gradient)
           |
           v
H_1 --> Gradient(xs=["H", "Z"], y="Y") ---> dY/dH when H = H_1 and Y = Y_1.
           |
           '------------------------------> dY/dZ (2nd output of Gradient)

When the inputs of Gradient are the tensors named in “xs” and “zs”, the computation can be optimized. More specifically, intermediate variables in forward pass can be reused if the gradient is computed via reverse-mode auto-differentiation.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • Inputs (variadic)T1: The values fed into graph identified by the attributes. The i-th input is the value of the i-th tensor specified in the concatenated list of the attribute “xs” and the attribute “zs”. For example, if xs=[“A”, “B”] and zs=[“C”], the first input is used as the value of symbol “A” and the 3rd input is substituted for all the occurrences of “C”.

Outputs

Between 1 and 2147483647 outputs.

  • Outputs (variadic)T2: The gradient of the tensor specified by the attribute “y” with respect to each of tensors specified in the attribute “xs”. The i-th output is the gradient of “y” with respect to the i-th tensor specified in the attribute “xs”.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Allow outputs to be any kind of tensor.

  • T2 tensor(float16), tensor(float), tensor(double): Allow inputs to be any kind of floating-point tensor.

OnnxGradient_1#

class skl2onnx.algebra.onnx_ops.OnnxGradient_1(*args, **kwargs)#

Version

Onnx name: Gradient

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Gradient operator computes the partial derivatives of a specific tensor w.r.t. some other tensors. This operator is widely used in gradient-based training algorithms. To illustrate its use, let’s consider a computation graph,

X -----.
       |
       v
W --> Conv --> H --> Gemm --> Y
                      ^
                      |
                      Z

, where W and Z are trainable tensors. Note that operators’ attributes are omitted for the sake of simplicity. Let dY/dW (dY/dZ) be the gradient of Y with respect to W (Z). The user can compute gradient by inserting Gradient operator to form another graph shown below.

W --> Conv --> H --> Gemm --> Y
|      ^              ^
|      |              |
|      X              Z
|      |              |
|      |   .----------'
|      |   |  (W/Z/X is the 1st/2nd/3rd input of Gradient as shown in
|      |   |   "xs" followed by "zs")
|      v   v
'---> Gradient(xs=["W", "Z"], zs=["X"], y="Y")
       |   |
       |   '-----------------------------------> dY/dW (1st output of Gradient)
       |
       '---------------------------------------> dY/dZ (2nd output of Gradient)

By definition, the tensor “y” is a function of independent variables in “xs” and “zs”. Since we only compute the gradient of “y” w.r.t. the differentiable variables in “xs”, this Gradient only outputs dY/dW and dY/dZ. Note that “H” cannot appear in “xs” and “zs”. The reason is that “H” can be determined by tensors “W” and “X” and therefore “H” is not an independent variable.

All outputs are optional. If needed, for example, user can assign an empty string to the 1st output name of that Gradient to skip the generation of dY/dW. Note that the concept of optional outputs can also be found in ONNX’s RNN, GRU, and LSTM.

Gradient operator can compute derivative against intermediate tensors. For example, the gradient of Y with respect to H can be done via

W --> Conv --> H --> Gemm --> Y
       ^       |      ^
       |       |      |
       X       |      Z
       .-------'      |
       |   .----------'
       |   | (H/Z is the 1st/2nd input of Gradient as shown in "xs")
       v   v
      Gradient(xs=["H", "Z"], y="Y")
       |   |
       |   '-----------------------------------> dY/dH (1st output of Gradient)
       |
       '---------------------------------------> dY/dZ (2nd output of Gradient)

It is possible to represent high-order differentiation using Gradient operators. For example, given the following linear model:

W --> Gemm --> Y --> Loss --> O
       ^              ^
       |              |
       X              L

To compute the 2nd order derivative of O with respect to W (denoted by d^2O/dW^2), one can do

W --> Gemm --> Y --> Loss --> O
|      ^              ^
|      |              |
|      X .------------L
|      | |            |
|      | |            v
+------+-+> Gradient(xs=["X", "W"], zs=["L"], y="O") ---> dO/dX (1st output of Gradient)
|      | |    |
|      | |    '---> dO/dW (2nd output of Gradient)
|      v v
'---> Gradient(xs=["X", "W"], zs=["L"], y="dO/dW") ---> d(dO/dW)dX (1st output of
       |                                                  Gradient)
       |
       |
       '---> d^2O/dW^2 (2nd output of Gradient)

The tensors named in attributes “xs”, “zs”, and “y” define the differentiated computation graph, and the inputs to Gradient node define the values at which the gradient is computed. We can feed different tensors to the identified graph. For example, one can compute the gradient of Y with respect to H at a specific value of H, H_1, by providing that value as an input to the Gradient node.

W --> Conv --> H --> Gemm --> Y
       ^              ^
       |              |
       X              Z

          Z_1 (2nd input of Gradient)
           |
           v
H_1 --> Gradient(xs=["H", "Z"], y="Y") ---> dY/dH when H = H_1 and Y = Y_1.
           |
           '------------------------------> dY/dZ (2nd output of Gradient)

When the inputs of Gradient are the tensors named in “xs” and “zs”, the computation can be optimized. More specifically, intermediate variables in forward pass can be reused if the gradient is computed via reverse-mode auto-differentiation.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • Inputs (variadic)T1: The values fed into graph identified by the attributes. The i-th input is the value of the i-th tensor specified in the concatenated list of the attribute “xs” and the attribute “zs”. For example, if xs=[“A”, “B”] and zs=[“C”], the first input is used as the value of symbol “A” and the 3rd input is substituted for all the occurrences of “C”.

Outputs

Between 1 and 2147483647 outputs.

  • Outputs (variadic)T2: The gradient of the tensor specified by the attribute “y” with respect to each of tensors specified in the attribute “xs”. The i-th output is the gradient of “y” with respect to the i-th tensor specified in the attribute “xs”.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Allow outputs to be any kind of tensor.

  • T2 tensor(float16), tensor(float), tensor(double): Allow inputs to be any kind of floating-point tensor.

OnnxGreater#

class skl2onnx.algebra.onnx_ops.OnnxGreater(*args, **kwargs)#

Version

Onnx name: Greater

This version of the operator has been available since version 13.

Summary

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreaterOrEqual#

class skl2onnx.algebra.onnx_ops.OnnxGreaterOrEqual(*args, **kwargs)#

Version

Onnx name: GreaterOrEqual

This version of the operator has been available since version 16.

Summary

Returns the tensor resulted from performing the greater_equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreaterOrEqual_12#

class skl2onnx.algebra.onnx_ops.OnnxGreaterOrEqual_12(*args, **kwargs)#

Version

Onnx name: GreaterOrEqual

This version of the operator has been available since version 12.

Summary

Returns the tensor resulted from performing the greater_equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreaterOrEqual_16#

class skl2onnx.algebra.onnx_ops.OnnxGreaterOrEqual_16(*args, **kwargs)#

Version

Onnx name: GreaterOrEqual

This version of the operator has been available since version 16.

Summary

Returns the tensor resulted from performing the greater_equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreater_1#

class skl2onnx.algebra.onnx_ops.OnnxGreater_1(*args, **kwargs)#

Version

Onnx name: Greater

This version of the operator has been available since version 1.

Summary

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Attributes

  • broadcast: Enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: Left input tensor for the logical operator.

  • B (heterogeneous)T: Right input tensor for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input to float tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreater_13#

class skl2onnx.algebra.onnx_ops.OnnxGreater_13(*args, **kwargs)#

Version

Onnx name: Greater

This version of the operator has been available since version 13.

Summary

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreater_7#

class skl2onnx.algebra.onnx_ops.OnnxGreater_7(*args, **kwargs)#

Version

Onnx name: Greater

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input to float tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGreater_9#

class skl2onnx.algebra.onnx_ops.OnnxGreater_9(*args, **kwargs)#

Version

Onnx name: Greater

This version of the operator has been available since version 9.

Summary

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxGridSample#

class skl2onnx.algebra.onnx_ops.OnnxGridSample(*args, **kwargs)#

Version

Onnx name: GridSample

This version of the operator has been available since version 20.

Summary

Given an input X and a flow-field grid, computes the output Y using X values and pixel locations from the grid. For spatial input X with shape (N, C, H, W), the grid will have shape (N, H_out, W_out, 2), the output Y will have shape (N, C, H_out, W_out). For volumetric input X with shape (N, C, D, H, W), the grid will have shape (N, D_out, H_out, W_out, 3), the output Y will have shape (N, C, D_out, H_out, W_out). More generally, for an input X of rank r+2 with shape (N, C, d1, d2, …, dr), the grid will have shape (N, D1_out, D2_out, …, Dr_out, r), the output Y will have shape (N, C, D1_out, D2_out, …, Dr_out).

The tensor X contains values at centers of square pixels (voxels, etc) locations such as (n, c, d1_in, d2_in, …, dr_in). The (n, d1_out, d2_out, …, dr_out, :) values from the tensor grid are the normalized positions for interpolating the values at the (n, c, d1_out, d2_out, …, dr_out) locations from the output tensor Y using a specified interpolation method (the mode) and a padding mode (for grid positions falling outside the 2-dimensional image).

For example, the values in grid[n, h_out, w_out, :] are size-2 vectors specifying normalized positions in the 2-dimensional space of X. They are used to interpolate output values of Y[n, c, h_out, w_out].

The GridSample operator is often used in doing grid generator and sampler in the [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025). See also in [torch.nn.functional.grid_sample](https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html).

Attributes

  • align_corners: If align_corners=1, the extrema (-1 and 1) are considered as referring to the center points of the input’s corner pixels (voxels, etc.). If align_corners=0, they are instead considered as referring to the corner points of the input’s corner pixels (voxels, etc.), making the sampling more resolution agnostic. Default value is name: "align_corners" type: INT i: 0

  • mode: Three interpolation modes: linear (default), nearest and cubic. The “linear” mode includes linear and N-linear interpolation modes depending on the number of spatial dimensions of the input tensor (i.e. linear for 1 spatial dimension, bilinear for 2 spatial dimensions, etc.). The “cubic” mode also includes N-cubic interpolation modes following the same rules. The “nearest” mode rounds to the nearest even index when the sampling point falls halfway between two indices. Default value is name: "mode" type: STRING s: "linear"

  • padding_mode: Support padding modes for outside grid values: zeros`(default), `border, reflection. zeros: use 0 for out-of-bound grid locations, border: use border values for out-of-bound grid locations, reflection: use values at locations reflected by the border for out-of-bound grid locations. If index 0 represents the margin pixel, the reflected value at index -1 will be the same as the value at index 1. For location far away from the border, it will keep being reflected until becoming in bound. If pixel location x = -3.5 reflects by border -1 and becomes x’ = 1.5, then reflects by border 1 and becomes x’’ = 0.5. Default value is name: "padding_mode" type: STRING s: "zeros"

Inputs

  • X (heterogeneous)T1: Input tensor of rank r+2 that has shape (N, C, D1, D2, …, Dr), where N is the batch size, C is the number of channels, D1, D2, …, Dr are the spatial dimensions.

  • grid (heterogeneous)T2: Input offset of shape (N, D1_out, D2_out, …, Dr_out, r), where D1_out, D2_out, …, Dr_out are the spatial dimensions of the grid and output, and r is the number of spatial dimensions. Grid specifies the sampling locations normalized by the input spatial dimensions. Therefore, it should have most values in the range of [-1, 1]. If the grid has values outside the range of [-1, 1], the corresponding outputs will be handled as defined by padding_mode. Following computer vision convention, the coordinates in the length-r location vector are listed from the innermost tensor dimension to the outermost, the opposite of regular tensor indexing.

Outputs

  • Y (heterogeneous)T1: Output tensor of rank r+2 that has shape (N, C, D1_out, D2_out, …, Dr_out) of the sampled values. For integer input types, intermediate values are computed as floating point and cast to integer at the end.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input X and output Y types to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain grid types to float tensors.

OnnxGridSample_16#

class skl2onnx.algebra.onnx_ops.OnnxGridSample_16(*args, **kwargs)#

Version

Onnx name: GridSample

This version of the operator has been available since version 16.

Summary

Given an input X and a flow-field grid, computes the output Y using X values and pixel locations from grid. Currently, only spatial (4-D) inputs are supported. For input X with shape (N, C, H, W) and grid with shape (N, H_out, W_out, 2), the output Y will have shape (N, C, H_out, W_out).

The tensor X contains values at centers of square pixels in a H by W 2-dimensional image. The tensor grid describes normalized positions where the output Y is to be computed using a specified interpolation method (the mode) and a padding mode (for grid positions falling outside the 2-dimensional image).

Elements in grid[N, H_out, W_out] are size-2 vectors specifying positions in the 2-dimensional space of X. They are used to interpolate output values of Y[N, C, H_out, W_out].

The GridSample operator is often used in doing grid generator and sampler in the [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025). See also in [torch.nn.functional.grid_sample](https://pytorch.org/docs/master/generated/torch.nn.functional.grid_sample.html#torch-nn-functional-grid-sample).

Attributes

  • align_corners: If align_corners=1, the extrema (-1 and 1) are considered as referring to the center points of the input’s corner pixels. If align_corners=0, they are instead considered as referring to the corner points of the input’s corner pixels, making the sampling more resolution agnostic. Default value is name: "align_corners" type: INT i: 0

  • mode: Three interpolation modes: bilinear (default), nearest and bicubic. Default value is name: "mode" type: STRING s: "bilinear"

  • padding_mode: Support padding modes for outside grid values: zeros`(default), `border, reflection. zeros: use 0 for out-of-bound grid locations, border: use border values for out-of-bound grid locations, reflection: use values at locations reflected by the border for out-of-bound grid locations. If index 0 represents the margin pixel, the reflected value at index -1 will be the same as the value at index 1. For location far away from the border, it will keep being reflected until becoming in bound. If pixel location x = -3.5 reflects by border -1 and becomes x’ = 1.5, then reflects by border 1 and becomes x’’ = 0.5. Default value is name: "padding_mode" type: STRING s: "zeros"

Inputs

  • X (heterogeneous)T1: 4-D tensor of shape (N, C, H, W), where N is the batch size, C is the numbers of channels, H and W are the height and width of the input data.

  • grid (heterogeneous)T2: Input offset, 4-D tensor of shape (N, H_out, W_out, 2), where H_out and W_out are the height and width of grid and output, Grid specifies the sampling pixel locations normalized by the input spatial dimensions. Therefore, it should have most values in the range of [-1, 1]. If grid has values outside the range of [-1, 1], the corresponding outputs will be handled as defined by padding_mode.

Outputs

  • Y (heterogeneous)T1: 4-D tensor of shape (N, C, H_out, W_out) of sampled values. For integer input types, intermediate values are computed as floating point and cast to integer at the end.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input X and output Y types to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain grid types to float tensors.

OnnxGridSample_20#

class skl2onnx.algebra.onnx_ops.OnnxGridSample_20(*args, **kwargs)#

Version

Onnx name: GridSample

This version of the operator has been available since version 20.

Summary

Given an input X and a flow-field grid, computes the output Y using X values and pixel locations from the grid. For spatial input X with shape (N, C, H, W), the grid will have shape (N, H_out, W_out, 2), the output Y will have shape (N, C, H_out, W_out). For volumetric input X with shape (N, C, D, H, W), the grid will have shape (N, D_out, H_out, W_out, 3), the output Y will have shape (N, C, D_out, H_out, W_out). More generally, for an input X of rank r+2 with shape (N, C, d1, d2, …, dr), the grid will have shape (N, D1_out, D2_out, …, Dr_out, r), the output Y will have shape (N, C, D1_out, D2_out, …, Dr_out).

The tensor X contains values at centers of square pixels (voxels, etc) locations such as (n, c, d1_in, d2_in, …, dr_in). The (n, d1_out, d2_out, …, dr_out, :) values from the tensor grid are the normalized positions for interpolating the values at the (n, c, d1_out, d2_out, …, dr_out) locations from the output tensor Y using a specified interpolation method (the mode) and a padding mode (for grid positions falling outside the 2-dimensional image).

For example, the values in grid[n, h_out, w_out, :] are size-2 vectors specifying normalized positions in the 2-dimensional space of X. They are used to interpolate output values of Y[n, c, h_out, w_out].

The GridSample operator is often used in doing grid generator and sampler in the [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025). See also in [torch.nn.functional.grid_sample](https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html).

Attributes

  • align_corners: If align_corners=1, the extrema (-1 and 1) are considered as referring to the center points of the input’s corner pixels (voxels, etc.). If align_corners=0, they are instead considered as referring to the corner points of the input’s corner pixels (voxels, etc.), making the sampling more resolution agnostic. Default value is name: "align_corners" type: INT i: 0

  • mode: Three interpolation modes: linear (default), nearest and cubic. The “linear” mode includes linear and N-linear interpolation modes depending on the number of spatial dimensions of the input tensor (i.e. linear for 1 spatial dimension, bilinear for 2 spatial dimensions, etc.). The “cubic” mode also includes N-cubic interpolation modes following the same rules. The “nearest” mode rounds to the nearest even index when the sampling point falls halfway between two indices. Default value is name: "mode" type: STRING s: "linear"

  • padding_mode: Support padding modes for outside grid values: zeros`(default), `border, reflection. zeros: use 0 for out-of-bound grid locations, border: use border values for out-of-bound grid locations, reflection: use values at locations reflected by the border for out-of-bound grid locations. If index 0 represents the margin pixel, the reflected value at index -1 will be the same as the value at index 1. For location far away from the border, it will keep being reflected until becoming in bound. If pixel location x = -3.5 reflects by border -1 and becomes x’ = 1.5, then reflects by border 1 and becomes x’’ = 0.5. Default value is name: "padding_mode" type: STRING s: "zeros"

Inputs

  • X (heterogeneous)T1: Input tensor of rank r+2 that has shape (N, C, D1, D2, …, Dr), where N is the batch size, C is the number of channels, D1, D2, …, Dr are the spatial dimensions.

  • grid (heterogeneous)T2: Input offset of shape (N, D1_out, D2_out, …, Dr_out, r), where D1_out, D2_out, …, Dr_out are the spatial dimensions of the grid and output, and r is the number of spatial dimensions. Grid specifies the sampling locations normalized by the input spatial dimensions. Therefore, it should have most values in the range of [-1, 1]. If the grid has values outside the range of [-1, 1], the corresponding outputs will be handled as defined by padding_mode. Following computer vision convention, the coordinates in the length-r location vector are listed from the innermost tensor dimension to the outermost, the opposite of regular tensor indexing.

Outputs

  • Y (heterogeneous)T1: Output tensor of rank r+2 that has shape (N, C, D1_out, D2_out, …, Dr_out) of the sampled values. For integer input types, intermediate values are computed as floating point and cast to integer at the end.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input X and output Y types to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain grid types to float tensors.

OnnxGroupNormalization#

class skl2onnx.algebra.onnx_ops.OnnxGroupNormalization(*args, **kwargs)#

Version

Onnx name: GroupNormalization

This version of the operator has been available since version 18.

Summary

A GroupNormalization function. Carries out group normalization as described in the paper https://arxiv.org/abs/1803.08494

This operator transforms input according to

y = scale * (x - mean) / sqrt(variance + epsilon) + bias,

where the mean and variance are computed per instance per group of channels, and scale and bias should be specified for each group of channels. The number of groups num_groups should be divisible by the number of channels so that there are an equal number of channels per group.

When the number of groups is the same as the number of channels, this operator is equivalent to InstanceNormalization. When there is only one group, this operator is equivalent to LayerNormalization.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

Inputs

  • X (heterogeneous)T: Input data tensor. Dimensions for image cases are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width of the data. Statistics are computed for every group of channels over C, H, and W. For non-image cases, the dimensions are in the form of (N x C x D1 x D2 … Dn).

  • scale (heterogeneous)T: Scale tensor of shape (num_groups).

  • bias (heterogeneous)T: Bias tensor of shape (num_groups).

Outputs

  • Y (heterogeneous)T: The output tensor of the same shape as X.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxGroupNormalization_18#

class skl2onnx.algebra.onnx_ops.OnnxGroupNormalization_18(*args, **kwargs)#

Version

Onnx name: GroupNormalization

This version of the operator has been available since version 18.

Summary

A GroupNormalization function. Carries out group normalization as described in the paper https://arxiv.org/abs/1803.08494

This operator transforms input according to

y = scale * (x - mean) / sqrt(variance + epsilon) + bias,

where the mean and variance are computed per instance per group of channels, and scale and bias should be specified for each group of channels. The number of groups num_groups should be divisible by the number of channels so that there are an equal number of channels per group.

When the number of groups is the same as the number of channels, this operator is equivalent to InstanceNormalization. When there is only one group, this operator is equivalent to LayerNormalization.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

Inputs

  • X (heterogeneous)T: Input data tensor. Dimensions for image cases are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width of the data. Statistics are computed for every group of channels over C, H, and W. For non-image cases, the dimensions are in the form of (N x C x D1 x D2 … Dn).

  • scale (heterogeneous)T: Scale tensor of shape (num_groups).

  • bias (heterogeneous)T: Bias tensor of shape (num_groups).

Outputs

  • Y (heterogeneous)T: The output tensor of the same shape as X.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxHammingWindow#

class skl2onnx.algebra.onnx_ops.OnnxHammingWindow(*args, **kwargs)#

Version

Onnx name: HammingWindow

This version of the operator has been available since version 17.

Summary

Generates a Hamming window as described in the paper https://ieeexplore.ieee.org/document/1455106.

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T2. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

  • periodic: If 1, returns a window to be used as periodic function. If 0, return a symmetric window. When ‘periodic’ is specified, hann computes a window of length size + 1 and returns the first size points. The default value is 1. Default value is name: "periodic" type: INT i: 1

Inputs

  • size (heterogeneous)T1: A scalar value indicating the length of the window.

Outputs

  • output (heterogeneous)T2: A Hamming window with length: size. The output has the shape: [size].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain the input size to int64_t.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain output types to numeric tensors.

OnnxHammingWindow_17#

class skl2onnx.algebra.onnx_ops.OnnxHammingWindow_17(*args, **kwargs)#

Version

Onnx name: HammingWindow

This version of the operator has been available since version 17.

Summary

Generates a Hamming window as described in the paper https://ieeexplore.ieee.org/document/1455106.

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T2. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

  • periodic: If 1, returns a window to be used as periodic function. If 0, return a symmetric window. When ‘periodic’ is specified, hann computes a window of length size + 1 and returns the first size points. The default value is 1. Default value is name: "periodic" type: INT i: 1

Inputs

  • size (heterogeneous)T1: A scalar value indicating the length of the window.

Outputs

  • output (heterogeneous)T2: A Hamming window with length: size. The output has the shape: [size].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain the input size to int64_t.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain output types to numeric tensors.

OnnxHannWindow#

class skl2onnx.algebra.onnx_ops.OnnxHannWindow(*args, **kwargs)#

Version

Onnx name: HannWindow

This version of the operator has been available since version 17.

Summary

Generates a Hann window as described in the paper https://ieeexplore.ieee.org/document/1455106.

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T2. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

  • periodic: If 1, returns a window to be used as periodic function. If 0, return a symmetric window. When ‘periodic’ is specified, hann computes a window of length size + 1 and returns the first size points. The default value is 1. Default value is name: "periodic" type: INT i: 1

Inputs

  • size (heterogeneous)T1: A scalar value indicating the length of the window.

Outputs

  • output (heterogeneous)T2: A Hann window with length: size. The output has the shape: [size].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain the input size to int64_t.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain output types to numeric tensors.

OnnxHannWindow_17#

class skl2onnx.algebra.onnx_ops.OnnxHannWindow_17(*args, **kwargs)#

Version

Onnx name: HannWindow

This version of the operator has been available since version 17.

Summary

Generates a Hann window as described in the paper https://ieeexplore.ieee.org/document/1455106.

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T2. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

  • periodic: If 1, returns a window to be used as periodic function. If 0, return a symmetric window. When ‘periodic’ is specified, hann computes a window of length size + 1 and returns the first size points. The default value is 1. Default value is name: "periodic" type: INT i: 1

Inputs

  • size (heterogeneous)T1: A scalar value indicating the length of the window.

Outputs

  • output (heterogeneous)T2: A Hann window with length: size. The output has the shape: [size].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain the input size to int64_t.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain output types to numeric tensors.

OnnxHardSigmoid#

class skl2onnx.algebra.onnx_ops.OnnxHardSigmoid(*args, **kwargs)#

Version

Onnx name: HardSigmoid

This version of the operator has been available since version 6.

Summary

HardSigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), is applied to the tensor elementwise.

Attributes

  • alpha: Value of alpha. Default value is name: "alpha" type: FLOAT f: 0.2

  • beta: Value of beta. Default value is name: "beta" type: FLOAT f: 0.5

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardSigmoid_1#

class skl2onnx.algebra.onnx_ops.OnnxHardSigmoid_1(*args, **kwargs)#

Version

Onnx name: HardSigmoid

This version of the operator has been available since version 1.

Summary

HardSigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), is applied to the tensor elementwise.

Attributes

  • alpha: Value of alpha default to 0.2 Default value is name: "alpha" type: FLOAT f: 0.2

  • beta: Value of beta default to 0.5 Default value is name: "beta" type: FLOAT f: 0.5

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardSigmoid_6#

class skl2onnx.algebra.onnx_ops.OnnxHardSigmoid_6(*args, **kwargs)#

Version

Onnx name: HardSigmoid

This version of the operator has been available since version 6.

Summary

HardSigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), is applied to the tensor elementwise.

Attributes

  • alpha: Value of alpha. Default value is name: "alpha" type: FLOAT f: 0.2

  • beta: Value of beta. Default value is name: "beta" type: FLOAT f: 0.5

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardSwish#

class skl2onnx.algebra.onnx_ops.OnnxHardSwish(*args, **kwargs)#

Version

Onnx name: HardSwish

This version of the operator has been available since version 14.

Summary

HardSwish takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the HardSwish function, y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid<alpha, beta>(x), where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardSwish_14#

class skl2onnx.algebra.onnx_ops.OnnxHardSwish_14(*args, **kwargs)#

Version

Onnx name: HardSwish

This version of the operator has been available since version 14.

Summary

HardSwish takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the HardSwish function, y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid<alpha, beta>(x), where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardmax#

class skl2onnx.algebra.onnx_ops.OnnxHardmax(*args, **kwargs)#

Version

Onnx name: Hardmax

This version of the operator has been available since version 13.

Summary

The operator computes the hardmax values for the given input:

Hardmax(element in input, axis) = 1 if the element is the first maximum value along the specified axis, 0 otherwise

The “axis” attribute indicates the dimension along which Hardmax will be performed. The output tensor has the same shape and contains the Hardmax values of the corresponding input.

Attributes

  • axis:

Describes the dimension Hardmax will be performed on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).

Default value is

name: "axis" type: INT i: -1

Inputs

  • input (heterogeneous)T: The input tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: The output values with the same shape as the input tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxHardmax_1#

class skl2onnx.algebra.onnx_ops.OnnxHardmax_1(*args, **kwargs)#

Version

Onnx name: Hardmax

This version of the operator has been available since version 1.

Summary

The operator computes the hardmax (1 for the first maximum value, and 0 for all others) values for each layer in the batch

of the given input. The input is a 2-D tensor (Tensor<float>) of size

(batch_size x input_feature_dimensions). The output tensor has the same shape and contains the hardmax values of the corresponding input.

Input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input in [a_0, a_1, …, a_{k-1}, a_k, …, a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * … * a_{k-1}, a_k * … * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * … * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * … * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Attributes

  • axis: Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: The input tensor that’s coerced into a 2D matrix of size (NxD) as described above.

Outputs

  • output (heterogeneous)T: The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardmax_11#

class skl2onnx.algebra.onnx_ops.OnnxHardmax_11(*args, **kwargs)#

Version

Onnx name: Hardmax

This version of the operator has been available since version 11.

Summary

The operator computes the hardmax (1 for the first maximum value, and 0 for all others) values for each layer in the batch

of the given input.

The input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input in [a_0, a_1, …, a_{k-1}, a_k, …, a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * … * a_{k-1}, a_k * … * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * … * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * … * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors. The output tensor has the same shape and contains the hardmax values of the corresponding input.

Attributes

  • axis: Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: The input tensor that’s coerced into a 2D matrix of size (NxD) as described above.

Outputs

  • output (heterogeneous)T: The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxHardmax_13#

class skl2onnx.algebra.onnx_ops.OnnxHardmax_13(*args, **kwargs)#

Version

Onnx name: Hardmax

This version of the operator has been available since version 13.

Summary

The operator computes the hardmax values for the given input:

Hardmax(element in input, axis) = 1 if the element is the first maximum value along the specified axis, 0 otherwise

The “axis” attribute indicates the dimension along which Hardmax will be performed. The output tensor has the same shape and contains the Hardmax values of the corresponding input.

Attributes

  • axis:

Describes the dimension Hardmax will be performed on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).

Default value is

name: "axis" type: INT i: -1

Inputs

  • input (heterogeneous)T: The input tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: The output values with the same shape as the input tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxIdentity#

class skl2onnx.algebra.onnx_ops.OnnxIdentity(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 21.

Summary

Identity operator

Inputs

  • input (heterogeneous)V: Input tensor

Outputs

  • output (heterogeneous)V: Tensor to copy input into.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain input and output types to all tensor, sequence, and optional types.

OnnxIdentity_1#

class skl2onnx.algebra.onnx_ops.OnnxIdentity_1(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 1.

Summary

Identity operator

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: Tensor to copy input into.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxIdentity_13#

class skl2onnx.algebra.onnx_ops.OnnxIdentity_13(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 13.

Summary

Identity operator

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: Tensor to copy input into.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxIdentity_14#

class skl2onnx.algebra.onnx_ops.OnnxIdentity_14(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 14.

Summary

Identity operator

Inputs

  • input (heterogeneous)V: Input tensor

Outputs

  • output (heterogeneous)V: Tensor to copy input into.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input and output types to all tensor and sequence types.

OnnxIdentity_16#

class skl2onnx.algebra.onnx_ops.OnnxIdentity_16(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 16.

Summary

Identity operator

Inputs

  • input (heterogeneous)V: Input tensor

Outputs

  • output (heterogeneous)V: Tensor to copy input into.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain input and output types to all tensor, sequence, and optional types.

OnnxIdentity_19#

class skl2onnx.algebra.onnx_ops.OnnxIdentity_19(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 19.

Summary

Identity operator

Inputs

  • input (heterogeneous)V: Input tensor

Outputs

  • output (heterogeneous)V: Tensor to copy input into.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain input and output types to all tensor, sequence, and optional types.

OnnxIdentity_21#

class skl2onnx.algebra.onnx_ops.OnnxIdentity_21(*args, **kwargs)#

Version

Onnx name: Identity

This version of the operator has been available since version 21.

Summary

Identity operator

Inputs

  • input (heterogeneous)V: Input tensor

Outputs

  • output (heterogeneous)V: Tensor to copy input into.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain input and output types to all tensor, sequence, and optional types.

OnnxIf#

class skl2onnx.algebra.onnx_ops.OnnxIf(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 21.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same data type. The then_branch and else_branch may produce tensors with the same element type and different shapes. If corresponding outputs from the then-branch and the else-branch have static shapes S1 and S2, then the shape of the corresponding output variable of the if-node (if present) must be compatible with both S1 and S2 as it represents the union of both possible shapes.For example, if in a model file, the first output of then_branch is typed float tensor with shape [2] and the first output of else_branch is another float tensor with shape [3], If’s first output should have (a) no shape set, or (b) a shape of rank 1 with neither dim_value nor dim_param set, or (c) a shape of rank 1 with a unique dim_param. In contrast, the first output cannot have the shape [2] since [2] and [3] are not compatible.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), seq(tensor(float8e4m3fn)), seq(tensor(float8e4m3fnuz)), seq(tensor(float8e5m2)), seq(tensor(float8e5m2fnuz)), seq(tensor(uint4)), seq(tensor(int4)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), optional(tensor(float8e4m3fn)), optional(tensor(float8e4m3fnuz)), optional(tensor(float8e5m2)), optional(tensor(float8e5m2fnuz)), optional(tensor(uint4)), optional(tensor(int4)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv10.

  • B tensor(bool): Only bool

OnnxIf_1#

class skl2onnx.algebra.onnx_ops.OnnxIf_1(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 1.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same shape and same data type.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

  • B tensor(bool): Only bool

OnnxIf_11#

class skl2onnx.algebra.onnx_ops.OnnxIf_11(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 11.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same data type. The then_branch and else_branch may produce tensors with the same element type and different shapes. If corresponding outputs from the then-branch and the else-branch have static shapes S1 and S2, then the shape of the corresponding output variable of the if-node (if present) must be compatible with both S1 and S2 as it represents the union of both possible shapes.For example, if in a model file, the first output of then_branch is typed float tensor with shape [2] and the first output of else_branch is another float tensor with shape [3], If’s first output should have (a) no shape set, or (b) a shape of rank 1 with neither dim_value nor dim_param set, or (c) a shape of rank 1 with a unique dim_param. In contrast, the first output cannot have the shape [2] since [2] and [3] are not compatible.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

  • B tensor(bool): Only bool

OnnxIf_13#

class skl2onnx.algebra.onnx_ops.OnnxIf_13(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 13.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same data type. The then_branch and else_branch may produce tensors with the same element type and different shapes. If corresponding outputs from the then-branch and the else-branch have static shapes S1 and S2, then the shape of the corresponding output variable of the if-node (if present) must be compatible with both S1 and S2 as it represents the union of both possible shapes.For example, if in a model file, the first output of then_branch is typed float tensor with shape [2] and the first output of else_branch is another float tensor with shape [3], If’s first output should have (a) no shape set, or (b) a shape of rank 1 with neither dim_value nor dim_param set, or (c) a shape of rank 1 with a unique dim_param. In contrast, the first output cannot have the shape [2] since [2] and [3] are not compatible.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): All Tensor and Sequence types

  • B tensor(bool): Only bool

OnnxIf_16#

class skl2onnx.algebra.onnx_ops.OnnxIf_16(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 16.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same data type. The then_branch and else_branch may produce tensors with the same element type and different shapes. If corresponding outputs from the then-branch and the else-branch have static shapes S1 and S2, then the shape of the corresponding output variable of the if-node (if present) must be compatible with both S1 and S2 as it represents the union of both possible shapes.For example, if in a model file, the first output of then_branch is typed float tensor with shape [2] and the first output of else_branch is another float tensor with shape [3], If’s first output should have (a) no shape set, or (b) a shape of rank 1 with neither dim_value nor dim_param set, or (c) a shape of rank 1 with a unique dim_param. In contrast, the first output cannot have the shape [2] since [2] and [3] are not compatible.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv4.

  • B tensor(bool): Only bool

OnnxIf_19#

class skl2onnx.algebra.onnx_ops.OnnxIf_19(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 19.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same data type. The then_branch and else_branch may produce tensors with the same element type and different shapes. If corresponding outputs from the then-branch and the else-branch have static shapes S1 and S2, then the shape of the corresponding output variable of the if-node (if present) must be compatible with both S1 and S2 as it represents the union of both possible shapes.For example, if in a model file, the first output of then_branch is typed float tensor with shape [2] and the first output of else_branch is another float tensor with shape [3], If’s first output should have (a) no shape set, or (b) a shape of rank 1 with neither dim_value nor dim_param set, or (c) a shape of rank 1 with a unique dim_param. In contrast, the first output cannot have the shape [2] since [2] and [3] are not compatible.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), seq(tensor(float8e4m3fn)), seq(tensor(float8e4m3fnuz)), seq(tensor(float8e5m2)), seq(tensor(float8e5m2fnuz)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), optional(tensor(float8e4m3fn)), optional(tensor(float8e4m3fnuz)), optional(tensor(float8e5m2)), optional(tensor(float8e5m2fnuz)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv9.

  • B tensor(bool): Only bool

OnnxIf_21#

class skl2onnx.algebra.onnx_ops.OnnxIf_21(*args, **kwargs)#

Version

Onnx name: If

This version of the operator has been available since version 21.

Summary

If conditional

Attributes

Inputs

  • cond (heterogeneous)B: Condition for the if. The tensor must contain a single element.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)V: Values that are live-out to the enclosing scope. The return values in the then_branch and else_branch must be of the same data type. The then_branch and else_branch may produce tensors with the same element type and different shapes. If corresponding outputs from the then-branch and the else-branch have static shapes S1 and S2, then the shape of the corresponding output variable of the if-node (if present) must be compatible with both S1 and S2 as it represents the union of both possible shapes.For example, if in a model file, the first output of then_branch is typed float tensor with shape [2] and the first output of else_branch is another float tensor with shape [3], If’s first output should have (a) no shape set, or (b) a shape of rank 1 with neither dim_value nor dim_param set, or (c) a shape of rank 1 with a unique dim_param. In contrast, the first output cannot have the shape [2] since [2] and [3] are not compatible.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), seq(tensor(float8e4m3fn)), seq(tensor(float8e4m3fnuz)), seq(tensor(float8e5m2)), seq(tensor(float8e5m2fnuz)), seq(tensor(uint4)), seq(tensor(int4)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), optional(tensor(float8e4m3fn)), optional(tensor(float8e4m3fnuz)), optional(tensor(float8e5m2)), optional(tensor(float8e5m2fnuz)), optional(tensor(uint4)), optional(tensor(int4)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv10.

  • B tensor(bool): Only bool

OnnxImageDecoder#

class skl2onnx.algebra.onnx_ops.OnnxImageDecoder(*args, **kwargs)#

Version

Onnx name: ImageDecoder

This version of the operator has been available since version 20.

Summary

Loads and decodes and image from a file. If it can’t decode for any reason (e.g. corrupted encoded stream, invalid format, it will return an empty matrix). The following image formats are supported: * BMP * JPEG (note: Lossless JPEG support is optional) * JPEG2000 * TIFF * PNG * WebP * Portable image format (PBM, PGM, PPM, PXM, PNM) Decoded images follow a channel-last layout: (Height, Width, Channels). JPEG chroma upsampling method: When upsampling the chroma components by a factor of 2, the pixels are linearly interpolated so that the centers of the output pixels are 1/4 and 3/4 of the way between input pixel centers. When rounding, 0.5 is rounded down and up at alternative pixels locations to prevent bias towards larger values (ordered dither pattern). Considering adjacent input pixels A, B, and C, B is upsampled to pixels B0 and B1 so that

B0 = round_half_down((1/4) * A + (3/4) * B)
B1 = round_half_up((3/4) * B + (1/4) * C)

This method, is the default chroma upsampling method in the well-established libjpeg-turbo library, also referred as “smooth” or “fancy” upsampling.

Attributes

  • pixel_format: Pixel format. Can be one of “RGB”, “BGR”, or “Grayscale”. Default value is name: "pixel_format" type: STRING s: "RGB"

Inputs

  • encoded_stream (heterogeneous)T1: Encoded stream

Outputs

  • image (heterogeneous)T2: Decoded image

Type Constraints

  • T1 tensor(uint8): Constrain input types to 8-bit unsigned integer tensor.

  • T2 tensor(uint8): Constrain output types to 8-bit unsigned integer tensor.

OnnxImageDecoder_20#

class skl2onnx.algebra.onnx_ops.OnnxImageDecoder_20(*args, **kwargs)#

Version

Onnx name: ImageDecoder

This version of the operator has been available since version 20.

Summary

Loads and decodes and image from a file. If it can’t decode for any reason (e.g. corrupted encoded stream, invalid format, it will return an empty matrix). The following image formats are supported: * BMP * JPEG (note: Lossless JPEG support is optional) * JPEG2000 * TIFF * PNG * WebP * Portable image format (PBM, PGM, PPM, PXM, PNM) Decoded images follow a channel-last layout: (Height, Width, Channels). JPEG chroma upsampling method: When upsampling the chroma components by a factor of 2, the pixels are linearly interpolated so that the centers of the output pixels are 1/4 and 3/4 of the way between input pixel centers. When rounding, 0.5 is rounded down and up at alternative pixels locations to prevent bias towards larger values (ordered dither pattern). Considering adjacent input pixels A, B, and C, B is upsampled to pixels B0 and B1 so that

B0 = round_half_down((1/4) * A + (3/4) * B)
B1 = round_half_up((3/4) * B + (1/4) * C)

This method, is the default chroma upsampling method in the well-established libjpeg-turbo library, also referred as “smooth” or “fancy” upsampling.

Attributes

  • pixel_format: Pixel format. Can be one of “RGB”, “BGR”, or “Grayscale”. Default value is name: "pixel_format" type: STRING s: "RGB"

Inputs

  • encoded_stream (heterogeneous)T1: Encoded stream

Outputs

  • image (heterogeneous)T2: Decoded image

Type Constraints

  • T1 tensor(uint8): Constrain input types to 8-bit unsigned integer tensor.

  • T2 tensor(uint8): Constrain output types to 8-bit unsigned integer tensor.

OnnxImputer#

class skl2onnx.algebra.onnx_ops.OnnxImputer(*args, **kwargs)#

Version

Onnx name: Imputer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Replaces inputs that equal one value with another, leaving all other elements alone.

This operator is typically used to replace missing values in situations where they have a canonical representation, such as -1, 0, NaN, or some extreme value.

One and only one of imputed_value_floats or imputed_value_int64s should be defined – floats if the input tensor holds floats, integers if the input tensor holds integers. The imputed values must all fit within the width of the tensor element type. One and only one of the replaced_value_float or replaced_value_int64 should be defined, which one depends on whether floats or integers are being processed.

The imputed_value attribute length can be 1 element, or it can have one element per input feature. In other words, if the input tensor has the shape [*,F], then the length of the attribute array may be 1 or F. If it is 1, then it is broadcast along the last dimension and applied to each feature.

Attributes

  • replaced_value_float: A value that needs replacing. Default value is name: "replaced_value_float" type: FLOAT f: 0

  • replaced_value_int64: A value that needs replacing. Default value is name: "replaced_value_int64" type: INT i: 0

Inputs

  • X (heterogeneous)T: Data to be processed.

Outputs

  • Y (heterogeneous)T: Imputed output data

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type, either [N,C] or [C]. The output type will be of the same tensor type and shape.

OnnxImputer_1#

class skl2onnx.algebra.onnx_ops.OnnxImputer_1(*args, **kwargs)#

Version

Onnx name: Imputer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Replaces inputs that equal one value with another, leaving all other elements alone.

This operator is typically used to replace missing values in situations where they have a canonical representation, such as -1, 0, NaN, or some extreme value.

One and only one of imputed_value_floats or imputed_value_int64s should be defined – floats if the input tensor holds floats, integers if the input tensor holds integers. The imputed values must all fit within the width of the tensor element type. One and only one of the replaced_value_float or replaced_value_int64 should be defined, which one depends on whether floats or integers are being processed.

The imputed_value attribute length can be 1 element, or it can have one element per input feature. In other words, if the input tensor has the shape [*,F], then the length of the attribute array may be 1 or F. If it is 1, then it is broadcast along the last dimension and applied to each feature.

Attributes

  • replaced_value_float: A value that needs replacing. Default value is name: "replaced_value_float" type: FLOAT f: 0

  • replaced_value_int64: A value that needs replacing. Default value is name: "replaced_value_int64" type: INT i: 0

Inputs

  • X (heterogeneous)T: Data to be processed.

Outputs

  • Y (heterogeneous)T: Imputed output data

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type, either [N,C] or [C]. The output type will be of the same tensor type and shape.

OnnxInstanceNormalization#

class skl2onnx.algebra.onnx_ops.OnnxInstanceNormalization(*args, **kwargs)#

Version

Onnx name: InstanceNormalization

This version of the operator has been available since version 6.

Summary

Carries out instance normalization as described in the paper https://arxiv.org/abs/1607.08022.

y = scale * (x - mean) / sqrt(variance + epsilon) + B, where mean and variance are computed per instance per channel.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

Inputs

  • input (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

  • scale (heterogeneous)T: The input 1-dimensional scale tensor of size C.

  • B (heterogeneous)T: The input 1-dimensional bias tensor of size C.

Outputs

  • output (heterogeneous)T: The output tensor of the same shape as input.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxInstanceNormalization_1#

class skl2onnx.algebra.onnx_ops.OnnxInstanceNormalization_1(*args, **kwargs)#

Version

Onnx name: InstanceNormalization

This version of the operator has been available since version 1.

Summary

Carries out instance normalization as described in the paper https://arxiv.org/abs/1607.08022.

y = scale * (x - mean) / sqrt(variance + epsilon) + B, where mean and variance are computed per instance per channel.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero, default is 1e-5f. Default value is name: "epsilon" type: FLOAT f: 1e-05

Inputs

  • input (heterogeneous)T: The input 4-dimensional tensor of shape NCHW.

  • scale (heterogeneous)T: The input 1-dimensional scale tensor of size C.

  • B (heterogeneous)T: The input 1-dimensional bias tensor of size C.

Outputs

  • output (heterogeneous)T: The output 4-dimensional tensor of the same shape as input.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxInstanceNormalization_6#

class skl2onnx.algebra.onnx_ops.OnnxInstanceNormalization_6(*args, **kwargs)#

Version

Onnx name: InstanceNormalization

This version of the operator has been available since version 6.

Summary

Carries out instance normalization as described in the paper https://arxiv.org/abs/1607.08022.

y = scale * (x - mean) / sqrt(variance + epsilon) + B, where mean and variance are computed per instance per channel.

Attributes

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

Inputs

  • input (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

  • scale (heterogeneous)T: The input 1-dimensional scale tensor of size C.

  • B (heterogeneous)T: The input 1-dimensional bias tensor of size C.

Outputs

  • output (heterogeneous)T: The output tensor of the same shape as input.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxIsInf#

class skl2onnx.algebra.onnx_ops.OnnxIsInf(*args, **kwargs)#

Version

Onnx name: IsInf

This version of the operator has been available since version 20.

Summary

Map infinity to true and other values to false.

Attributes

  • detect_negative: (Optional) Whether map negative infinity to true. Default to 1 so that negative infinity induces true. Set this attribute to 0 if negative infinity should be mapped to false. Default value is name: "detect_negative" type: INT i: 1

  • detect_positive: (Optional) Whether map positive infinity to true. Default to 1 so that positive infinity induces true. Set this attribute to 0 if positive infinity should be mapped to false. Default value is name: "detect_positive" type: INT i: 1

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxIsInf_10#

class skl2onnx.algebra.onnx_ops.OnnxIsInf_10(*args, **kwargs)#

Version

Onnx name: IsInf

This version of the operator has been available since version 10.

Summary

Map infinity to true and other values to false.

Attributes

  • detect_negative: (Optional) Whether map negative infinity to true. Default to 1 so that negative infinity induces true. Set this attribute to 0 if negative infinity should be mapped to false. Default value is name: "detect_negative" type: INT i: 1

  • detect_positive: (Optional) Whether map positive infinity to true. Default to 1 so that positive infinity induces true. Set this attribute to 0 if positive infinity should be mapped to false. Default value is name: "detect_positive" type: INT i: 1

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxIsInf_20#

class skl2onnx.algebra.onnx_ops.OnnxIsInf_20(*args, **kwargs)#

Version

Onnx name: IsInf

This version of the operator has been available since version 20.

Summary

Map infinity to true and other values to false.

Attributes

  • detect_negative: (Optional) Whether map negative infinity to true. Default to 1 so that negative infinity induces true. Set this attribute to 0 if negative infinity should be mapped to false. Default value is name: "detect_negative" type: INT i: 1

  • detect_positive: (Optional) Whether map positive infinity to true. Default to 1 so that positive infinity induces true. Set this attribute to 0 if positive infinity should be mapped to false. Default value is name: "detect_positive" type: INT i: 1

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxIsNaN#

class skl2onnx.algebra.onnx_ops.OnnxIsNaN(*args, **kwargs)#

Version

Onnx name: IsNaN

This version of the operator has been available since version 20.

Summary

Returns which elements of the input are NaN.

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxIsNaN_13#

class skl2onnx.algebra.onnx_ops.OnnxIsNaN_13(*args, **kwargs)#

Version

Onnx name: IsNaN

This version of the operator has been available since version 13.

Summary

Returns which elements of the input are NaN.

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxIsNaN_20#

class skl2onnx.algebra.onnx_ops.OnnxIsNaN_20(*args, **kwargs)#

Version

Onnx name: IsNaN

This version of the operator has been available since version 20.

Summary

Returns which elements of the input are NaN.

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxIsNaN_9#

class skl2onnx.algebra.onnx_ops.OnnxIsNaN_9(*args, **kwargs)#

Version

Onnx name: IsNaN

This version of the operator has been available since version 9.

Summary

Returns which elements of the input are NaN.

Inputs

  • X (heterogeneous)T1: input

Outputs

  • Y (heterogeneous)T2: output

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

  • T2 tensor(bool): Constrain output types to boolean tensors.

OnnxLRN#

class skl2onnx.algebra.onnx_ops.OnnxLRN(*args, **kwargs)#

Version

Onnx name: LRN

This version of the operator has been available since version 13.

Summary

Local Response Normalization proposed in the [AlexNet paper](https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf). It normalizes over local input regions. The local region is defined across the channels. For an element X[n, c, d1, …, dk] in a tensor of shape (N x C x D1 x D2, …, Dk), its region is {X[n, i, d1, …, dk] | max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2))}.

square_sum[n, c, d1, …, dk] = sum(X[n, i, d1, …, dk] ^ 2), where max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2)).

Y[n, c, d1, …, dk] = X[n, c, d1, …, dk] / (bias + alpha / size * square_sum[n, c, d1, …, dk] ) ^ beta

Attributes

  • alpha: Scaling parameter. Default value is name: "alpha" type: FLOAT f: 0.0001

  • beta: The exponent. Default value is name: "beta" type: FLOAT f: 0.75

  • bias: Default value is name: "bias" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output tensor, which has the shape and type as input tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxLRN_1#

class skl2onnx.algebra.onnx_ops.OnnxLRN_1(*args, **kwargs)#

Version

Onnx name: LRN

This version of the operator has been available since version 1.

Summary

Local Response Normalization proposed in the [AlexNet paper](https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf). It normalizes over local input regions. The local region is defined across the channels. For an element X[n, c, d1, …, dk] in a tensor of shape (N x C x D1 x D2, …, Dk), its region is {X[n, i, d1, …, dk] | max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2))}.

square_sum[n, c, d1, …, dk] = sum(X[n, i, d1, …, dk] ^ 2), where max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2)).

Y[n, c, d1, …, dk] = X[n, c, d1, …, dk] / (bias + alpha / size * square_sum[n, c, d1, …, dk] ) ^ beta

Attributes

  • alpha: Scaling parameter. Default value is name: "alpha" type: FLOAT f: 0.0001

  • beta: The exponent. Default value is name: "beta" type: FLOAT f: 0.75

  • bias: Default value is name: "bias" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output tensor, which has the shape and type as input tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLRN_13#

class skl2onnx.algebra.onnx_ops.OnnxLRN_13(*args, **kwargs)#

Version

Onnx name: LRN

This version of the operator has been available since version 13.

Summary

Local Response Normalization proposed in the [AlexNet paper](https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf). It normalizes over local input regions. The local region is defined across the channels. For an element X[n, c, d1, …, dk] in a tensor of shape (N x C x D1 x D2, …, Dk), its region is {X[n, i, d1, …, dk] | max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2))}.

square_sum[n, c, d1, …, dk] = sum(X[n, i, d1, …, dk] ^ 2), where max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2)).

Y[n, c, d1, …, dk] = X[n, c, d1, …, dk] / (bias + alpha / size * square_sum[n, c, d1, …, dk] ) ^ beta

Attributes

  • alpha: Scaling parameter. Default value is name: "alpha" type: FLOAT f: 0.0001

  • beta: The exponent. Default value is name: "beta" type: FLOAT f: 0.75

  • bias: Default value is name: "bias" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output tensor, which has the shape and type as input tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxLSTM#

class skl2onnx.algebra.onnx_ops.OnnxLSTM(*args, **kwargs)#

Version

Onnx name: LSTM

This version of the operator has been available since version 14.

Summary

Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

  • X - input tensor

  • i - input gate

  • o - output gate

  • f - forget gate

  • c - cell gate

  • t - time step (t-1 means previous time step)

  • W[iofc] - W parameter weight matrix for input, output, forget, and cell gates

  • R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates

  • Wb[iofc] - W bias vectors for input, output, forget, and cell gates

  • Rb[iofc] - R bias vectors for input, output, forget, and cell gates

  • P[iof] - P peephole weight vector for input, output, and forget gates

  • WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates

  • RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates

  • WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates

  • RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates

  • PB[iof] - P peephole weight vector for backward input, output, and forget gates

  • H - Hidden state

  • num_directions - 2 if direction == bidirectional else 1

Activation functions:

  • Relu(x) - max(0, x)

  • Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

  • Sigmoid(x) - 1/(1 + e^{-x})

NOTE: Below are optional

  • Affine(x) - alpha*x + beta

  • LeakyRelu(x) - x if x >= 0 else alpha * x

  • ThresholdedRelu(x) - x if x >= alpha else 0

  • ScaledTanh(x) - alpha*Tanh(beta*x)

  • HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

  • Elu(x) - x if x >= 0 else alpha*(e^x - 1)

  • Softsign(x) - x/(1 + |x|)

  • Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):

  • it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi)

  • ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf)

  • ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc)

  • Ct = ft (.) Ct-1 + it (.) ct

  • ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo)

  • Ht = ot (.) h(Ct)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • input_forget: Couple the input and forget gates if 1. Default value is name: "input_forget" type: INT i: 0

  • layout: The shape format of inputs X, initial_h, initial_c and outputs Y, Y_h, Y_c. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = [batch_size, num_directions, hidden_size]. Default value is name: "layout" type: INT i: 0

Inputs

Between 3 and 8 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[iofc] and WB[iofc] (if bidirectional) along dimension 0. The tensor has shape [num_directions, 4*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[iofc] and RB[iofc] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 4*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wb[iofc], Rb[iofc]], and [WBb[iofc], RBb[iofc]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 8*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • initial_c (optional, heterogeneous)T: Optional initial value of the cell. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • P (optional, heterogeneous)T: The weight tensor for peepholes. Concatenation of P[iof] and PB[iof] (if bidirectional) along dimension 0. It has shape [num_directions, 3*hidde_size]. Optional: If not specified - assumed to be 0.

Outputs

Between 0 and 3 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

  • Y_c (optional, heterogeneous)T: The last output value of the cell. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxLSTM_1#

class skl2onnx.algebra.onnx_ops.OnnxLSTM_1(*args, **kwargs)#

Version

Onnx name: LSTM

This version of the operator has been available since version 1.

Summary

Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

o - output gate

f - forget gate

c - cell gate

t - time step (t-1 means previous time step)

W[iofc] - W parameter weight matrix for input, output, forget, and cell gates

R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates

Wb[iofc] - W bias vectors for input, output, forget, and cell gates

Rb[iofc] - R bias vectors for input, output, forget, and cell gates

P[iof] - P peephole weight vector for input, output, and forget gates

WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates

RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates

WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates

RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates

PB[iof] - P peephole weight vector for backward input, output, and forget gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):

  • it = f(Xt*(Wi^T) + Ht-1*Ri + Pi (.) Ct-1 + Wbi + Rbi)

  • ft = f(Xt*(Wf^T) + Ht-1*Rf + Pf (.) Ct-1 + Wbf + Rbf)

  • ct = g(Xt*(Wc^T) + Ht-1*Rc + Wbc + Rbc)

  • Ct = ft (.) Ct-1 + it (.) ct

  • ot = f(Xt*(Wo^T) + Ht-1*Ro + Po (.) Ct + Wbo + Rbo)

  • Ht = ot (.) h(Ct)

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • input_forget: Couple the input and forget gates if 1, default 0. Default value is name: "input_forget" type: INT i: 0

  • output_sequence: The sequence output for the hidden is optional if 0. Default 0. Default value is name: "output_sequence" type: INT i: 0

Inputs

Between 3 and 8 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[iofc] and WB[iofc] (if bidirectional) along dimension 0. The tensor has shape [num_directions, 4*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[iofc] and RB[iofc] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 4*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wb[iofc], Rb[iofc]], and [WBb[iofc], RBb[iofc]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 8*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • initial_c (optional, heterogeneous)T: Optional initial value of the cell. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • P (optional, heterogeneous)T: The weight tensor for peepholes. Concatenation of P[iof] and PB[iof] (if bidirectional) along dimension 0. It has shape [num_directions, 3*hidde_size]. Optional: If not specified - assumed to be 0.

Outputs

Between 0 and 3 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size]. It is optional if output_sequence is 0.

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

  • Y_c (optional, heterogeneous)T: The last output value of the cell. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxLSTM_14#

class skl2onnx.algebra.onnx_ops.OnnxLSTM_14(*args, **kwargs)#

Version

Onnx name: LSTM

This version of the operator has been available since version 14.

Summary

Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

  • X - input tensor

  • i - input gate

  • o - output gate

  • f - forget gate

  • c - cell gate

  • t - time step (t-1 means previous time step)

  • W[iofc] - W parameter weight matrix for input, output, forget, and cell gates

  • R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates

  • Wb[iofc] - W bias vectors for input, output, forget, and cell gates

  • Rb[iofc] - R bias vectors for input, output, forget, and cell gates

  • P[iof] - P peephole weight vector for input, output, and forget gates

  • WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates

  • RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates

  • WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates

  • RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates

  • PB[iof] - P peephole weight vector for backward input, output, and forget gates

  • H - Hidden state

  • num_directions - 2 if direction == bidirectional else 1

Activation functions:

  • Relu(x) - max(0, x)

  • Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

  • Sigmoid(x) - 1/(1 + e^{-x})

NOTE: Below are optional

  • Affine(x) - alpha*x + beta

  • LeakyRelu(x) - x if x >= 0 else alpha * x

  • ThresholdedRelu(x) - x if x >= alpha else 0

  • ScaledTanh(x) - alpha*Tanh(beta*x)

  • HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

  • Elu(x) - x if x >= 0 else alpha*(e^x - 1)

  • Softsign(x) - x/(1 + |x|)

  • Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):

  • it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi)

  • ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf)

  • ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc)

  • Ct = ft (.) Ct-1 + it (.) ct

  • ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo)

  • Ht = ot (.) h(Ct)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • input_forget: Couple the input and forget gates if 1. Default value is name: "input_forget" type: INT i: 0

  • layout: The shape format of inputs X, initial_h, initial_c and outputs Y, Y_h, Y_c. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = [batch_size, num_directions, hidden_size]. Default value is name: "layout" type: INT i: 0

Inputs

Between 3 and 8 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[iofc] and WB[iofc] (if bidirectional) along dimension 0. The tensor has shape [num_directions, 4*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[iofc] and RB[iofc] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 4*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wb[iofc], Rb[iofc]], and [WBb[iofc], RBb[iofc]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 8*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • initial_c (optional, heterogeneous)T: Optional initial value of the cell. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • P (optional, heterogeneous)T: The weight tensor for peepholes. Concatenation of P[iof] and PB[iof] (if bidirectional) along dimension 0. It has shape [num_directions, 3*hidde_size]. Optional: If not specified - assumed to be 0.

Outputs

Between 0 and 3 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

  • Y_c (optional, heterogeneous)T: The last output value of the cell. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxLSTM_7#

class skl2onnx.algebra.onnx_ops.OnnxLSTM_7(*args, **kwargs)#

Version

Onnx name: LSTM

This version of the operator has been available since version 7.

Summary

Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

o - output gate

f - forget gate

c - cell gate

t - time step (t-1 means previous time step)

W[iofc] - W parameter weight matrix for input, output, forget, and cell gates

R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates

Wb[iofc] - W bias vectors for input, output, forget, and cell gates

Rb[iofc] - R bias vectors for input, output, forget, and cell gates

P[iof] - P peephole weight vector for input, output, and forget gates

WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates

RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates

WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates

RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates

PB[iof] - P peephole weight vector for backward input, output, and forget gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):

  • it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi)

  • ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf)

  • ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc)

  • Ct = ft (.) Ct-1 + it (.) ct

  • ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo)

  • Ht = ot (.) h(Ct)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • input_forget: Couple the input and forget gates if 1. Default value is name: "input_forget" type: INT i: 0

Inputs

Between 3 and 8 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for the gates. Concatenation of W[iofc] and WB[iofc] (if bidirectional) along dimension 0. The tensor has shape [num_directions, 4*hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of R[iofc] and RB[iofc] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 4*hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wb[iofc], Rb[iofc]], and [WBb[iofc], RBb[iofc]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 8*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • initial_c (optional, heterogeneous)T: Optional initial value of the cell. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

  • P (optional, heterogeneous)T: The weight tensor for peepholes. Concatenation of P[iof] and PB[iof] (if bidirectional) along dimension 0. It has shape [num_directions, 3*hidde_size]. Optional: If not specified - assumed to be 0.

Outputs

Between 0 and 3 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

  • Y_c (optional, heterogeneous)T: The last output value of the cell. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxLabelEncoder#

class skl2onnx.algebra.onnx_ops.OnnxLabelEncoder(*args, **kwargs)#

Version

Onnx name: LabelEncoder

This version of the operator has been available since version 4 of domain ai.onnx.ml.

Summary

Maps each element in the input tensor to another value.

The mapping is determined by the two parallel attributes, ‘keys_*’ and ‘values_*’ attribute. The i-th value in the specified ‘keys_*’ attribute would be mapped to the i-th value in the specified ‘values_*’ attribute. It implies that input’s element type and the element type of the specified ‘keys_*’ should be identical while the output type is identical to the specified ‘values_*’ attribute. Note that the ‘keys_*’ and ‘values_*’ attributes must have the same length. If an input element can not be found in the specified ‘keys_*’ attribute, the ‘default_*’ that matches the specified ‘values_*’ attribute may be used as its output value. The type of the ‘default_*’ attribute must match the ‘values_*’ attribute chosen.

Let’s consider an example which maps a string tensor to an integer tensor. Assume and ‘keys_strings’ is [“Amy”, “Sally”], ‘values_int64s’ is [5, 6], and ‘default_int64’ is ‘-1’. The input [“Dori”, “Amy”, “Amy”, “Sally”, “Sally”] would be mapped to [-1, 5, 5, 6, 6].

Since this operator is an one-to-one mapping, its input and output shapes are the same. Notice that only one of ‘keys_*’/’values_*’ can be set.

Float keys with value ‘NaN’ match any input ‘NaN’ value regardless of bit value. If a key is repeated, the last key takes precedence.

Attributes

  • default_float: A float. Default value is name: "default_float" type: FLOAT f: -0

  • default_int64: An integer. Default value is name: "default_int64" type: INT i: -1

  • default_string: A string. Default value is name: "default_string" type: STRING s: "_Unused"

  • default_tensor: A default tensor. Default value is name: "default_tensor" doc_string: "{\"_Unused\"} if values_* has string type, {-1} if values_* has integral type, and {-0.f} if values_* has float type." type: TENSOR

Inputs

  • X (heterogeneous)T1: Input data. It must have the same element type as the keys_* attribute set.

Outputs

  • Y (heterogeneous)T2: Output data. This tensor’s element type is based on the values_* attribute set.

Type Constraints

  • T1 tensor(string), tensor(int64), tensor(float), tensor(int32), tensor(int16), tensor(double): The input type is a tensor of any shape.

  • T2 tensor(string), tensor(int64), tensor(float), tensor(int32), tensor(int16), tensor(double): Output type is determined by the specified ‘values_*’ attribute.

OnnxLabelEncoder_1#

class skl2onnx.algebra.onnx_ops.OnnxLabelEncoder_1(*args, **kwargs)#

Version

Onnx name: LabelEncoder

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Converts strings to integers and vice versa.

If the string default value is set, it will convert integers to strings. If the int default value is set, it will convert strings to integers.

Each operator converts either integers to strings or strings to integers, depending on which default value attribute is provided. Only one default value attribute should be defined.

When converting from integers to strings, the string is fetched from the ‘classes_strings’ list, by simple indexing.

When converting from strings to integers, the string is looked up in the list and the index at which it is found is used as the converted value.

Attributes

  • default_int64: An integer to use when an input string value is not found in the map.<br>One and only one of the ‘default_*’ attributes must be defined. Default value is name: "default_int64" type: INT i: -1

  • default_string: A string to use when an input integer value is not found in the map.<br>One and only one of the ‘default_*’ attributes must be defined. Default value is name: "default_string" type: STRING s: "_Unused"

Inputs

  • X (heterogeneous)T1: Input data.

Outputs

  • Y (heterogeneous)T2: Output data. If strings are input, the output values are integers, and vice versa.

Type Constraints

  • T1 tensor(string), tensor(int64): The input type must be a tensor of integers or strings, of any shape.

  • T2 tensor(string), tensor(int64): The output type will be a tensor of strings or integers, and will have the same shape as the input.

OnnxLabelEncoder_2#

class skl2onnx.algebra.onnx_ops.OnnxLabelEncoder_2(*args, **kwargs)#

Version

Onnx name: LabelEncoder

This version of the operator has been available since version 2 of domain ai.onnx.ml.

Summary

Maps each element in the input tensor to another value.

The mapping is determined by the two parallel attributes, ‘keys_*’ and ‘values_*’ attribute. The i-th value in the specified ‘keys_*’ attribute would be mapped to the i-th value in the specified ‘values_*’ attribute. It implies that input’s element type and the element type of the specified ‘keys_*’ should be identical while the output type is identical to the specified ‘values_*’ attribute. If an input element can not be found in the specified ‘keys_*’ attribute, the ‘default_*’ that matches the specified ‘values_*’ attribute may be used as its output value.

Let’s consider an example which maps a string tensor to an integer tensor. Assume and ‘keys_strings’ is [“Amy”, “Sally”], ‘values_int64s’ is [5, 6], and ‘default_int64’ is ‘-1’. The input [“Dori”, “Amy”, “Amy”, “Sally”, “Sally”] would be mapped to [-1, 5, 5, 6, 6].

Since this operator is an one-to-one mapping, its input and output shapes are the same. Notice that only one of ‘keys_*’/’values_*’ can be set.

For key look-up, bit-wise comparison is used so even a float NaN can be mapped to a value in ‘values_*’ attribute.

Attributes

  • default_float: A float. Default value is name: "default_float" type: FLOAT f: -0

  • default_int64: An integer. Default value is name: "default_int64" type: INT i: -1

  • default_string: A string. Default value is name: "default_string" type: STRING s: "_Unused"

Inputs

  • X (heterogeneous)T1: Input data. It can be either tensor or scalar.

Outputs

  • Y (heterogeneous)T2: Output data.

Type Constraints

  • T1 tensor(string), tensor(int64), tensor(float): The input type is a tensor of any shape.

  • T2 tensor(string), tensor(int64), tensor(float): Output type is determined by the specified ‘values_*’ attribute.

OnnxLabelEncoder_4#

class skl2onnx.algebra.onnx_ops.OnnxLabelEncoder_4(*args, **kwargs)#

Version

Onnx name: LabelEncoder

This version of the operator has been available since version 4 of domain ai.onnx.ml.

Summary

Maps each element in the input tensor to another value.

The mapping is determined by the two parallel attributes, ‘keys_*’ and ‘values_*’ attribute. The i-th value in the specified ‘keys_*’ attribute would be mapped to the i-th value in the specified ‘values_*’ attribute. It implies that input’s element type and the element type of the specified ‘keys_*’ should be identical while the output type is identical to the specified ‘values_*’ attribute. Note that the ‘keys_*’ and ‘values_*’ attributes must have the same length. If an input element can not be found in the specified ‘keys_*’ attribute, the ‘default_*’ that matches the specified ‘values_*’ attribute may be used as its output value. The type of the ‘default_*’ attribute must match the ‘values_*’ attribute chosen.

Let’s consider an example which maps a string tensor to an integer tensor. Assume and ‘keys_strings’ is [“Amy”, “Sally”], ‘values_int64s’ is [5, 6], and ‘default_int64’ is ‘-1’. The input [“Dori”, “Amy”, “Amy”, “Sally”, “Sally”] would be mapped to [-1, 5, 5, 6, 6].

Since this operator is an one-to-one mapping, its input and output shapes are the same. Notice that only one of ‘keys_*’/’values_*’ can be set.

Float keys with value ‘NaN’ match any input ‘NaN’ value regardless of bit value. If a key is repeated, the last key takes precedence.

Attributes

  • default_float: A float. Default value is name: "default_float" type: FLOAT f: -0

  • default_int64: An integer. Default value is name: "default_int64" type: INT i: -1

  • default_string: A string. Default value is name: "default_string" type: STRING s: "_Unused"

  • default_tensor: A default tensor. Default value is name: "default_tensor" doc_string: "{\"_Unused\"} if values_* has string type, {-1} if values_* has integral type, and {-0.f} if values_* has float type." type: TENSOR

Inputs

  • X (heterogeneous)T1: Input data. It must have the same element type as the keys_* attribute set.

Outputs

  • Y (heterogeneous)T2: Output data. This tensor’s element type is based on the values_* attribute set.

Type Constraints

  • T1 tensor(string), tensor(int64), tensor(float), tensor(int32), tensor(int16), tensor(double): The input type is a tensor of any shape.

  • T2 tensor(string), tensor(int64), tensor(float), tensor(int32), tensor(int16), tensor(double): Output type is determined by the specified ‘values_*’ attribute.

OnnxLayerNormalization#

class skl2onnx.algebra.onnx_ops.OnnxLayerNormalization(*args, **kwargs)#

Version

Onnx name: LayerNormalization

This version of the operator has been available since version 17.

Summary

This is layer normalization defined in ONNX as function. The overall computation can be split into two stages. The first stage is standardization, which makes the normalized elements have zero mean and unit variances. The computation required by standardization can be described by the following equations.

Mean = ReduceMean<axes=normalized_axes>(X)
D = Sub(X, Mean)
DD = Mul(D, D)
Var = ReduceMean<axes=normalized_axes>(DD)
VarEps = Add(Var, epsilon)
StdDev = Sqrt(VarEps)
InvStdDev = Reciprocal(StdDev)
Normalized = Mul(D, InvStdDev)

where normalized_axes is [axis, …, rank of X - 1]. The variables Var and StdDev stand for variance and standard deviation, respectively. The second output is Mean and the last one is InvStdDev. Depending on stash_type attribute, the actual computation must happen in different floating-point precision. For example, if stash_type is 1, this operator casts all input variables to 32-bit float, perform the computation, and finally cast Normalized back to the original type of X. The second stage then scales and shifts the outcome of the first stage using

NormalizedScaled = Mul(Normalized, Scale)
Y = Add(NormalizedScaled, B)

The second stage doesn’t depends on stash_type. All equations are in [this syntax](https://github.com/onnx/onnx/blob/main/docs/Syntax.md). The same variable (i.e., input, output, and attribute) uses the same name in the equations above and this operator’s definition. Let d[i] indicate the i-th dimension of X. If X’s shape is [d[0], …, d[axis-1], d[axis], …, d[rank-1]], the shape of Mean and InvStdDev is [d[0], …, d[axis-1], 1, …, 1]. Y and X have the same shape. This operator supports unidirectional broadcasting (tensors Scale and B should be unidirectional broadcastable to tensor X); for more details please check Broadcasting in ONNX.

Attributes

  • axis: The first normalization dimension. If rank(X) is r, axis’ allowed range is [-r, r). Negative value means counting dimensions from the back. Default value is name: "axis" type: INT i: -1

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • stash_type: Type of Mean and InvStdDev. This also specifies stage one’s computation precision. Default value is name: "stash_type" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Tensor to be normalized.

  • Scale (heterogeneous)T: Scale tensor.

  • B (optional, heterogeneous)T: Bias tensor.

Outputs

Between 1 and 3 outputs.

  • Y (heterogeneous)T: Normalized tensor.

  • Mean (optional, heterogeneous)U: Saved mean used during training to speed up gradient computation

  • InvStdDev (optional, heterogeneous)U: Saved inverse standard deviation used during training to speed up gradient computation.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types and output Y type to float tensors.

  • U tensor(float), tensor(bfloat16): Type of Mean and InvStdDev tensors.

OnnxLayerNormalization_17#

class skl2onnx.algebra.onnx_ops.OnnxLayerNormalization_17(*args, **kwargs)#

Version

Onnx name: LayerNormalization

This version of the operator has been available since version 17.

Summary

This is layer normalization defined in ONNX as function. The overall computation can be split into two stages. The first stage is standardization, which makes the normalized elements have zero mean and unit variances. The computation required by standardization can be described by the following equations.

Mean = ReduceMean<axes=normalized_axes>(X)
D = Sub(X, Mean)
DD = Mul(D, D)
Var = ReduceMean<axes=normalized_axes>(DD)
VarEps = Add(Var, epsilon)
StdDev = Sqrt(VarEps)
InvStdDev = Reciprocal(StdDev)
Normalized = Mul(D, InvStdDev)

where normalized_axes is [axis, …, rank of X - 1]. The variables Var and StdDev stand for variance and standard deviation, respectively. The second output is Mean and the last one is InvStdDev. Depending on stash_type attribute, the actual computation must happen in different floating-point precision. For example, if stash_type is 1, this operator casts all input variables to 32-bit float, perform the computation, and finally cast Normalized back to the original type of X. The second stage then scales and shifts the outcome of the first stage using

NormalizedScaled = Mul(Normalized, Scale)
Y = Add(NormalizedScaled, B)

The second stage doesn’t depends on stash_type. All equations are in [this syntax](https://github.com/onnx/onnx/blob/main/docs/Syntax.md). The same variable (i.e., input, output, and attribute) uses the same name in the equations above and this operator’s definition. Let d[i] indicate the i-th dimension of X. If X’s shape is [d[0], …, d[axis-1], d[axis], …, d[rank-1]], the shape of Mean and InvStdDev is [d[0], …, d[axis-1], 1, …, 1]. Y and X have the same shape. This operator supports unidirectional broadcasting (tensors Scale and B should be unidirectional broadcastable to tensor X); for more details please check Broadcasting in ONNX.

Attributes

  • axis: The first normalization dimension. If rank(X) is r, axis’ allowed range is [-r, r). Negative value means counting dimensions from the back. Default value is name: "axis" type: INT i: -1

  • epsilon: The epsilon value to use to avoid division by zero. Default value is name: "epsilon" type: FLOAT f: 1e-05

  • stash_type: Type of Mean and InvStdDev. This also specifies stage one’s computation precision. Default value is name: "stash_type" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T: Tensor to be normalized.

  • Scale (heterogeneous)T: Scale tensor.

  • B (optional, heterogeneous)T: Bias tensor.

Outputs

Between 1 and 3 outputs.

  • Y (heterogeneous)T: Normalized tensor.

  • Mean (optional, heterogeneous)U: Saved mean used during training to speed up gradient computation

  • InvStdDev (optional, heterogeneous)U: Saved inverse standard deviation used during training to speed up gradient computation.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types and output Y type to float tensors.

  • U tensor(float), tensor(bfloat16): Type of Mean and InvStdDev tensors.

OnnxLeakyRelu#

class skl2onnx.algebra.onnx_ops.OnnxLeakyRelu(*args, **kwargs)#

Version

Onnx name: LeakyRelu

This version of the operator has been available since version 16.

Summary

LeakyRelu takes input data (Tensor<T>) and an argument alpha, and produces one output data (Tensor<T>) where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.

Attributes

  • alpha: Coefficient of leakage. Default value is name: "alpha" type: FLOAT f: 0.01

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(bfloat16), tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLeakyRelu_1#

class skl2onnx.algebra.onnx_ops.OnnxLeakyRelu_1(*args, **kwargs)#

Version

Onnx name: LeakyRelu

This version of the operator has been available since version 1.

Summary

LeakyRelu takes input data (Tensor<T>) and an argument alpha, and produces one output data (Tensor<T>) where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.

Attributes

  • alpha: Coefficient of leakage default to 0.01. Default value is name: "alpha" type: FLOAT f: 0.01

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLeakyRelu_16#

class skl2onnx.algebra.onnx_ops.OnnxLeakyRelu_16(*args, **kwargs)#

Version

Onnx name: LeakyRelu

This version of the operator has been available since version 16.

Summary

LeakyRelu takes input data (Tensor<T>) and an argument alpha, and produces one output data (Tensor<T>) where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.

Attributes

  • alpha: Coefficient of leakage. Default value is name: "alpha" type: FLOAT f: 0.01

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(bfloat16), tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLeakyRelu_6#

class skl2onnx.algebra.onnx_ops.OnnxLeakyRelu_6(*args, **kwargs)#

Version

Onnx name: LeakyRelu

This version of the operator has been available since version 6.

Summary

LeakyRelu takes input data (Tensor<T>) and an argument alpha, and produces one output data (Tensor<T>) where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.

Attributes

  • alpha: Coefficient of leakage. Default value is name: "alpha" type: FLOAT f: 0.01

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLess#

class skl2onnx.algebra.onnx_ops.OnnxLess(*args, **kwargs)#

Version

Onnx name: Less

This version of the operator has been available since version 13.

Summary

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLessOrEqual#

class skl2onnx.algebra.onnx_ops.OnnxLessOrEqual(*args, **kwargs)#

Version

Onnx name: LessOrEqual

This version of the operator has been available since version 16.

Summary

Returns the tensor resulted from performing the less_equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLessOrEqual_12#

class skl2onnx.algebra.onnx_ops.OnnxLessOrEqual_12(*args, **kwargs)#

Version

Onnx name: LessOrEqual

This version of the operator has been available since version 12.

Summary

Returns the tensor resulted from performing the less_equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLessOrEqual_16#

class skl2onnx.algebra.onnx_ops.OnnxLessOrEqual_16(*args, **kwargs)#

Version

Onnx name: LessOrEqual

This version of the operator has been available since version 16.

Summary

Returns the tensor resulted from performing the less_equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLess_1#

class skl2onnx.algebra.onnx_ops.OnnxLess_1(*args, **kwargs)#

Version

Onnx name: Less

This version of the operator has been available since version 1.

Summary

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Attributes

  • broadcast: Enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: Left input tensor for the logical operator.

  • B (heterogeneous)T: Right input tensor for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input to float tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLess_13#

class skl2onnx.algebra.onnx_ops.OnnxLess_13(*args, **kwargs)#

Version

Onnx name: Less

This version of the operator has been available since version 13.

Summary

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLess_7#

class skl2onnx.algebra.onnx_ops.OnnxLess_7(*args, **kwargs)#

Version

Onnx name: Less

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input to float tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLess_9#

class skl2onnx.algebra.onnx_ops.OnnxLess_9(*args, **kwargs)#

Version

Onnx name: Less

This version of the operator has been available since version 9.

Summary

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input types to all numeric tensors.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxLinearClassifier#

class skl2onnx.algebra.onnx_ops.OnnxLinearClassifier(*args, **kwargs)#

Version

Onnx name: LinearClassifier

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Linear classifier

Attributes

  • multi_class: Indicates whether to do OvR or multinomial (0=OvR is the default). Default value is name: "multi_class" type: INT i: 0

  • post_transform: Indicates the transform to apply to the scores vector.<br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Data to be classified.

Outputs

  • Y (heterogeneous)T2: Classification outputs (one class per example).

  • Z (heterogeneous)tensor(float): Classification scores ([N,E] - one score for each class and example

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type, and of shape [N,C] or [C]. In the latter case, it will be treated as [1,C]

  • T2 tensor(string), tensor(int64): The output will be a tensor of strings or integers.

OnnxLinearClassifier_1#

class skl2onnx.algebra.onnx_ops.OnnxLinearClassifier_1(*args, **kwargs)#

Version

Onnx name: LinearClassifier

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Linear classifier

Attributes

  • multi_class: Indicates whether to do OvR or multinomial (0=OvR is the default). Default value is name: "multi_class" type: INT i: 0

  • post_transform: Indicates the transform to apply to the scores vector.<br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Data to be classified.

Outputs

  • Y (heterogeneous)T2: Classification outputs (one class per example).

  • Z (heterogeneous)tensor(float): Classification scores ([N,E] - one score for each class and example

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type, and of shape [N,C] or [C]. In the latter case, it will be treated as [1,C]

  • T2 tensor(string), tensor(int64): The output will be a tensor of strings or integers.

OnnxLinearRegressor#

class skl2onnx.algebra.onnx_ops.OnnxLinearRegressor(*args, **kwargs)#

Version

Onnx name: LinearRegressor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Generalized linear regression evaluation.

If targets is set to 1 (default) then univariate regression is performed.

If targets is set to M then M sets of coefficients must be passed in as a sequence and M results will be output for each input n in N.

The coefficients array is of length n, and the coefficients for each target are contiguous. Intercepts are optional but if provided must match the number of targets.

Attributes

  • post_transform: Indicates the transform to apply to the regression output vector.<br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

  • targets: The total number of regression targets, 1 if not defined. Default value is name: "targets" type: INT i: 1

Inputs

  • X (heterogeneous)T: Data to be regressed.

Outputs

  • Y (heterogeneous)tensor(float): Regression outputs (one per target, per example).

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type.

OnnxLinearRegressor_1#

class skl2onnx.algebra.onnx_ops.OnnxLinearRegressor_1(*args, **kwargs)#

Version

Onnx name: LinearRegressor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Generalized linear regression evaluation.

If targets is set to 1 (default) then univariate regression is performed.

If targets is set to M then M sets of coefficients must be passed in as a sequence and M results will be output for each input n in N.

The coefficients array is of length n, and the coefficients for each target are contiguous. Intercepts are optional but if provided must match the number of targets.

Attributes

  • post_transform: Indicates the transform to apply to the regression output vector.<br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

  • targets: The total number of regression targets, 1 if not defined. Default value is name: "targets" type: INT i: 1

Inputs

  • X (heterogeneous)T: Data to be regressed.

Outputs

  • Y (heterogeneous)tensor(float): Regression outputs (one per target, per example).

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type.

OnnxLog#

class skl2onnx.algebra.onnx_ops.OnnxLog(*args, **kwargs)#

Version

Onnx name: Log

This version of the operator has been available since version 13.

Summary

Calculates the natural log of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The natural log of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxLogSoftmax#

class skl2onnx.algebra.onnx_ops.OnnxLogSoftmax(*args, **kwargs)#

Version

Onnx name: LogSoftmax

This version of the operator has been available since version 13.

Summary

The operator computes the log of softmax values for the given input:

LogSoftmax(input, axis) = Log(Softmax(input, axis=axis))

The “axis” attribute indicates the dimension along which LogSoftmax will be performed. The output tensor has the same shape and contains the LogSoftmax values of the corresponding input.

Attributes

  • axis:

Describes the dimension LogSoftmax will be performed on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).

Default value is

name: "axis" type: INT i: -1

Inputs

  • input (heterogeneous)T: The input tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: The output values with the same shape as the input tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxLogSoftmax_1#

class skl2onnx.algebra.onnx_ops.OnnxLogSoftmax_1(*args, **kwargs)#

Version

Onnx name: LogSoftmax

This version of the operator has been available since version 1.

Summary

The operator computes the logsoftmax (log of softmax) values for each layer in the batch

of the given input. The input is a 2-D tensor (Tensor<float>) of size

(batch_size x input_feature_dimensions). The output tensor has the same shape and contains the logsoftmax values of the corresponding input.

Input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input in [a_0, a_1, …, a_{k-1}, a_k, …, a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * … * a_{k-1}, a_k * … * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * … * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * … * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Attributes

  • axis: Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: The input tensor that’s coerced into a 2D matrix of size (NxD) as described above.

Outputs

  • output (heterogeneous)T: The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLogSoftmax_11#

class skl2onnx.algebra.onnx_ops.OnnxLogSoftmax_11(*args, **kwargs)#

Version

Onnx name: LogSoftmax

This version of the operator has been available since version 11.

Summary

The operator computes the logsoftmax (log of softmax) values for each layer in the batch

of the given input.

The input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input in [a_0, a_1, …, a_{k-1}, a_k, …, a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * … * a_{k-1}, a_k * … * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * … * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * … * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors. The output tensor has the same shape and contains the logsoftmax values of the corresponding input.

Attributes

  • axis: Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: The input tensor that’s coerced into a 2D matrix of size (NxD) as described above.

Outputs

  • output (heterogeneous)T: The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLogSoftmax_13#

class skl2onnx.algebra.onnx_ops.OnnxLogSoftmax_13(*args, **kwargs)#

Version

Onnx name: LogSoftmax

This version of the operator has been available since version 13.

Summary

The operator computes the log of softmax values for the given input:

LogSoftmax(input, axis) = Log(Softmax(input, axis=axis))

The “axis” attribute indicates the dimension along which LogSoftmax will be performed. The output tensor has the same shape and contains the LogSoftmax values of the corresponding input.

Attributes

  • axis:

Describes the dimension LogSoftmax will be performed on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).

Default value is

name: "axis" type: INT i: -1

Inputs

  • input (heterogeneous)T: The input tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: The output values with the same shape as the input tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxLog_1#

class skl2onnx.algebra.onnx_ops.OnnxLog_1(*args, **kwargs)#

Version

Onnx name: Log

This version of the operator has been available since version 1.

Summary

Calculates the natural log of the given input tensor, element-wise.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The natural log of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLog_13#

class skl2onnx.algebra.onnx_ops.OnnxLog_13(*args, **kwargs)#

Version

Onnx name: Log

This version of the operator has been available since version 13.

Summary

Calculates the natural log of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The natural log of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxLog_6#

class skl2onnx.algebra.onnx_ops.OnnxLog_6(*args, **kwargs)#

Version

Onnx name: Log

This version of the operator has been available since version 6.

Summary

Calculates the natural log of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The natural log of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLoop#

class skl2onnx.algebra.onnx_ops.OnnxLoop(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 21.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

  • input (“”, “”):
    for (int i=0; ; ++i) {

    cond = … // Note this value is ignored, but is required in the body

    }

  • input (“”, cond) // Note this is analogous to a while loop

    bool cond = …; for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (“”, 1) // Note this is analogous to a do-while loop

    bool cond = true for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (trip_count, “”) // Note this is analogous to a for loop

    int trip_count = … for (int i=0; i < trip_count; ++i) {

    cond = …; // ignored

    }

  • input (trip_count, cond)

    int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

    cond = …;

    }

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] // iteration number %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used %b_in[INT32, scalar] // incoming value of loop-carried-dependency b

) {

%my_local = Add(%a, %b_in) %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated return %keepgoing_out, %b_out, %user_defined_val

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code / / initialize loop-carried variables and scan-output variables */ bool keepgoing_out = keepgoing int b_out = b

for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
/* Implicitly-defined code: bind actual parameter values

to formal parameter variables of loop-body */

bool keepgoing_in = keepgoing_out; bool b_in = b_out;

/* User-defined code (loop body) / int my_local = a + b_in; // Reading value “a” from the enclosing scope is fine b_out = a - b_in; keepgoing_out = my_local > b_out; user_defined_val = b_in + b_in; // b_in and b_out are different variables / End user-defined code */

/* Implicitly defined-code */ user_defined_vals[i] = user_defined_val // accumulate scan-output values

} // int t = my_local; // Can’t do this. my_local is not accessible here.

// The values below are bound to the output variables of the loop and therefore accessible // b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable “a” here) are in scope and can be referenced in the inputs of the loop.

  2. Any values computed in the loop body that needs to be used in a subsequent iteration or after the loop are modelled using a pair of variables in the loop-body, consisting of an input variable (eg., b_in) and an output variable (eg., b_out). These are referred to as loop-carried dependences. The loop operation node supplies the input value of the input variable for the first iteration, and returns the output value of the output variable produced by the final iteration.

  3. Scan_output variables are used to implicitly concatenate values computed across all the iterations. In the above example, the value of user_defined_val computed over all iterations are concatenated and returned as the value of user_defined_vals after the loop.

  4. Values created in the body cannot be accessed in the enclosing scope, except using the mechanism described above.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

The input/output of subgraph (produced by loop node) matching is based on order instead of name. The implementation will figure out the names based on this order.

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs. Scan outputs must be Tensors.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), seq(tensor(float8e4m3fn)), seq(tensor(float8e4m3fnuz)), seq(tensor(float8e5m2)), seq(tensor(float8e5m2fnuz)), seq(tensor(uint4)), seq(tensor(int4)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), optional(tensor(float8e4m3fn)), optional(tensor(float8e4m3fnuz)), optional(tensor(float8e5m2)), optional(tensor(float8e5m2fnuz)), optional(tensor(uint4)), optional(tensor(int4)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv10.

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLoop_1#

class skl2onnx.algebra.onnx_ops.OnnxLoop_1(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 1.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

input (“”, “”):
for (int i=0; ; ++i) {

cond = … // Note this value is ignored, but is required in the body

}

input (“”, cond) // Note this is analogous to a while loop

bool cond = …; for (int i=0; cond; ++i) {

cond = …;

}

input (“”, 1) // Note this is analogous to a do-while loop

bool cond = true for (int i=0; cond; ++i) {

cond = …;

}

input (trip_count, “”) // Note this is analogous to a for loop

int trip_count = … for (int i=0; i < trip_count; ++i) {

cond = …; // ignored

}

input (trip_count, cond)

int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

cond = …;

}

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] %keepgoing[BOOL, scalar] %b[INT32, scalar]

) {

%my_local = Add(%a, %b) %b_out = Sub(%a, %b) %keepgoing_out = Greater(%my_local, %b_out) %user_defined_vals = Add(%b, %b) return %keepgoing_out, %b_out, %user_defined_vals

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code */ for (int i=0; i < max_trip_count && keepgoing; ++i) {

/* User-defined code (loop body) / int my_local = a + b; // Reading values in the enclosing scope is fine b = a - b; // writes fine if we specify b as a loop-carried dependency keepgoing = my_local > b; // keepgoing is a loop-carried dependency user_defined_vals[i] = b + b; / End user-defined code */

} // my_local = 123; // Can’t do this. my_local was defined in the body

// These below values are live-out from the loop and therefore accessible b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable a here) are in scope and can be referenced in the inputs of the loop.

  2. Any variables which you wish to make available in the enclosing scope (i.e. the variables b and keepgoing) must be declared as either loop-carried dependencies (both at the op inputs and output and at the body net input and output) or scan_outputs.

  3. Values created in the body cannot be accessed in the enclosing scope.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

Attributes

Inputs

Between 3 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLoop_11#

class skl2onnx.algebra.onnx_ops.OnnxLoop_11(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 11.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

input (“”, “”):
for (int i=0; ; ++i) {

cond = … // Note this value is ignored, but is required in the body

}

input (“”, cond) // Note this is analogous to a while loop

bool cond = …; for (int i=0; cond; ++i) {

cond = …;

}

input (“”, 1) // Note this is analogous to a do-while loop

bool cond = true for (int i=0; cond; ++i) {

cond = …;

}

input (trip_count, “”) // Note this is analogous to a for loop

int trip_count = … for (int i=0; i < trip_count; ++i) {

cond = …; // ignored

}

input (trip_count, cond)

int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

cond = …;

}

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] // iteration number %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used %b_in[INT32, scalar] // incoming value of loop-carried-dependency b

) {

%my_local = Add(%a, %b_in) %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated return %keepgoing_out, %b_out, %user_defined_val

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code / / initialize loop-carried variables and scan-output variables */ bool keepgoing_out = keepgoing int b_out = b

for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
/* Implicitly-defined code: bind actual parameter values

to formal parameter variables of loop-body */

bool keepgoing_in = keepgoing_out; bool b_in = b_out;

/* User-defined code (loop body) / int my_local = a + b_in; // Reading value “a” from the enclosing scope is fine b_out = a - b_in; keepgoing_out = my_local > b_out; user_defined_val = b_in + b_in; // b_in and b_out are different variables / End user-defined code */

/* Implicitly defined-code */ user_defined_vals[i] = user_defined_val // accumulate scan-output values

} // int t = my_local; // Can’t do this. my_local is not accessible here.

// The values below are bound to the output variables of the loop and therefore accessible // b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable “a” here) are in scope and can be referenced in the inputs of the loop.

  2. Any values computed in the loop body that needs to be used in a subsequent iteration or after the loop are modelled using a pair of variables in the loop-body, consisting of an input variable (eg., b_in) and an output variable (eg., b_out). These are referred to as loop-carried dependences. The loop operation node supplies the input value of the input variable for the first iteration, and returns the output value of the output variable produced by the final iteration.

  3. Scan_output variables are used to implicitly concatenate values computed across all the iterations. In the above example, the value of user_defined_val computed over all iterations are concatenated and returned as the value of user_defined_vals after the loop.

  4. Values created in the body cannot be accessed in the enclosing scope, except using the mechanism described above.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLoop_13#

class skl2onnx.algebra.onnx_ops.OnnxLoop_13(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 13.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

input (“”, “”):
for (int i=0; ; ++i) {

cond = … // Note this value is ignored, but is required in the body

}

input (“”, cond) // Note this is analogous to a while loop

bool cond = …; for (int i=0; cond; ++i) {

cond = …;

}

input (“”, 1) // Note this is analogous to a do-while loop

bool cond = true for (int i=0; cond; ++i) {

cond = …;

}

input (trip_count, “”) // Note this is analogous to a for loop

int trip_count = … for (int i=0; i < trip_count; ++i) {

cond = …; // ignored

}

input (trip_count, cond)

int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

cond = …;

}

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] // iteration number %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used %b_in[INT32, scalar] // incoming value of loop-carried-dependency b

) {

%my_local = Add(%a, %b_in) %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated return %keepgoing_out, %b_out, %user_defined_val

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code / / initialize loop-carried variables and scan-output variables */ bool keepgoing_out = keepgoing int b_out = b

for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
/* Implicitly-defined code: bind actual parameter values

to formal parameter variables of loop-body */

bool keepgoing_in = keepgoing_out; bool b_in = b_out;

/* User-defined code (loop body) / int my_local = a + b_in; // Reading value “a” from the enclosing scope is fine b_out = a - b_in; keepgoing_out = my_local > b_out; user_defined_val = b_in + b_in; // b_in and b_out are different variables / End user-defined code */

/* Implicitly defined-code */ user_defined_vals[i] = user_defined_val // accumulate scan-output values

} // int t = my_local; // Can’t do this. my_local is not accessible here.

// The values below are bound to the output variables of the loop and therefore accessible // b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable “a” here) are in scope and can be referenced in the inputs of the loop.

  2. Any values computed in the loop body that needs to be used in a subsequent iteration or after the loop are modelled using a pair of variables in the loop-body, consisting of an input variable (eg., b_in) and an output variable (eg., b_out). These are referred to as loop-carried dependences. The loop operation node supplies the input value of the input variable for the first iteration, and returns the output value of the output variable produced by the final iteration.

  3. Scan_output variables are used to implicitly concatenate values computed across all the iterations. In the above example, the value of user_defined_val computed over all iterations are concatenated and returned as the value of user_defined_vals after the loop.

  4. Values created in the body cannot be accessed in the enclosing scope, except using the mechanism described above.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

The input/output of subgraph (produced by loop node) matching is based on order instead of name. The implementation will figure out the names based on this order.

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs. Scan outputs must be Tensors.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): All Tensor and Sequence types

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLoop_16#

class skl2onnx.algebra.onnx_ops.OnnxLoop_16(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 16.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

  • input (“”, “”):
    for (int i=0; ; ++i) {

    cond = … // Note this value is ignored, but is required in the body

    }

  • input (“”, cond) // Note this is analogous to a while loop

    bool cond = …; for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (“”, 1) // Note this is analogous to a do-while loop

    bool cond = true for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (trip_count, “”) // Note this is analogous to a for loop

    int trip_count = … for (int i=0; i < trip_count; ++i) {

    cond = …; // ignored

    }

  • input (trip_count, cond)

    int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

    cond = …;

    }

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] // iteration number %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used %b_in[INT32, scalar] // incoming value of loop-carried-dependency b

) {

%my_local = Add(%a, %b_in) %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated return %keepgoing_out, %b_out, %user_defined_val

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code / / initialize loop-carried variables and scan-output variables */ bool keepgoing_out = keepgoing int b_out = b

for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
/* Implicitly-defined code: bind actual parameter values

to formal parameter variables of loop-body */

bool keepgoing_in = keepgoing_out; bool b_in = b_out;

/* User-defined code (loop body) / int my_local = a + b_in; // Reading value “a” from the enclosing scope is fine b_out = a - b_in; keepgoing_out = my_local > b_out; user_defined_val = b_in + b_in; // b_in and b_out are different variables / End user-defined code */

/* Implicitly defined-code */ user_defined_vals[i] = user_defined_val // accumulate scan-output values

} // int t = my_local; // Can’t do this. my_local is not accessible here.

// The values below are bound to the output variables of the loop and therefore accessible // b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable “a” here) are in scope and can be referenced in the inputs of the loop.

  2. Any values computed in the loop body that needs to be used in a subsequent iteration or after the loop are modelled using a pair of variables in the loop-body, consisting of an input variable (eg., b_in) and an output variable (eg., b_out). These are referred to as loop-carried dependences. The loop operation node supplies the input value of the input variable for the first iteration, and returns the output value of the output variable produced by the final iteration.

  3. Scan_output variables are used to implicitly concatenate values computed across all the iterations. In the above example, the value of user_defined_val computed over all iterations are concatenated and returned as the value of user_defined_vals after the loop.

  4. Values created in the body cannot be accessed in the enclosing scope, except using the mechanism described above.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

The input/output of subgraph (produced by loop node) matching is based on order instead of name. The implementation will figure out the names based on this order.

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs. Scan outputs must be Tensors.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv4.

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLoop_19#

class skl2onnx.algebra.onnx_ops.OnnxLoop_19(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 19.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

  • input (“”, “”):
    for (int i=0; ; ++i) {

    cond = … // Note this value is ignored, but is required in the body

    }

  • input (“”, cond) // Note this is analogous to a while loop

    bool cond = …; for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (“”, 1) // Note this is analogous to a do-while loop

    bool cond = true for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (trip_count, “”) // Note this is analogous to a for loop

    int trip_count = … for (int i=0; i < trip_count; ++i) {

    cond = …; // ignored

    }

  • input (trip_count, cond)

    int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

    cond = …;

    }

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] // iteration number %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used %b_in[INT32, scalar] // incoming value of loop-carried-dependency b

) {

%my_local = Add(%a, %b_in) %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated return %keepgoing_out, %b_out, %user_defined_val

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code / / initialize loop-carried variables and scan-output variables */ bool keepgoing_out = keepgoing int b_out = b

for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
/* Implicitly-defined code: bind actual parameter values

to formal parameter variables of loop-body */

bool keepgoing_in = keepgoing_out; bool b_in = b_out;

/* User-defined code (loop body) / int my_local = a + b_in; // Reading value “a” from the enclosing scope is fine b_out = a - b_in; keepgoing_out = my_local > b_out; user_defined_val = b_in + b_in; // b_in and b_out are different variables / End user-defined code */

/* Implicitly defined-code */ user_defined_vals[i] = user_defined_val // accumulate scan-output values

} // int t = my_local; // Can’t do this. my_local is not accessible here.

// The values below are bound to the output variables of the loop and therefore accessible // b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable “a” here) are in scope and can be referenced in the inputs of the loop.

  2. Any values computed in the loop body that needs to be used in a subsequent iteration or after the loop are modelled using a pair of variables in the loop-body, consisting of an input variable (eg., b_in) and an output variable (eg., b_out). These are referred to as loop-carried dependences. The loop operation node supplies the input value of the input variable for the first iteration, and returns the output value of the output variable produced by the final iteration.

  3. Scan_output variables are used to implicitly concatenate values computed across all the iterations. In the above example, the value of user_defined_val computed over all iterations are concatenated and returned as the value of user_defined_vals after the loop.

  4. Values created in the body cannot be accessed in the enclosing scope, except using the mechanism described above.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

The input/output of subgraph (produced by loop node) matching is based on order instead of name. The implementation will figure out the names based on this order.

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs. Scan outputs must be Tensors.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), seq(tensor(float8e4m3fn)), seq(tensor(float8e4m3fnuz)), seq(tensor(float8e5m2)), seq(tensor(float8e5m2fnuz)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), optional(tensor(float8e4m3fn)), optional(tensor(float8e4m3fnuz)), optional(tensor(float8e5m2)), optional(tensor(float8e5m2fnuz)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv9.

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLoop_21#

class skl2onnx.algebra.onnx_ops.OnnxLoop_21(*args, **kwargs)#

Version

Onnx name: Loop

This version of the operator has been available since version 21.

Summary

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.

  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

Operator inputs defined as (max_trip_count, condition_var).

  • input (“”, “”):
    for (int i=0; ; ++i) {

    cond = … // Note this value is ignored, but is required in the body

    }

  • input (“”, cond) // Note this is analogous to a while loop

    bool cond = …; for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (“”, 1) // Note this is analogous to a do-while loop

    bool cond = true for (int i=0; cond; ++i) {

    cond = …;

    }

  • input (trip_count, “”) // Note this is analogous to a for loop

    int trip_count = … for (int i=0; i < trip_count; ++i) {

    cond = …; // ignored

    }

  • input (trip_count, cond)

    int trip_count = …; bool cond = …; for (int i=0; i < trip_count && cond; ++i) {

    cond = …;

    }

Sample usage - cond as well as trip count

graph predict-net {

%a = Constant[value = <Scalar Tensor [3]>]() %b = Constant[value = <Scalar Tensor [6]>]() %keepgoing = Constant[value = <Scalar Tensor [1]>]() %max_trip_count = Constant[value = <Scalar Tensor [10]>]() %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b) return

}

graph body-net (

%i[INT32, scalar] // iteration number %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used %b_in[INT32, scalar] // incoming value of loop-carried-dependency b

) {

%my_local = Add(%a, %b_in) %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated return %keepgoing_out, %b_out, %user_defined_val

}

Sample equivalent C code

{

/* User-defined code (enclosing scope) / int a = 3, b = 6; bool keepgoing = true; // Analogous to input cond / End user-defined code */

/* Implicitly-defined code / const int max_trip_count = 10; // Analogous to input M int user_defined_vals[]; // Imagine this is resizable / End implicitly-defined code / / initialize loop-carried variables and scan-output variables */ bool keepgoing_out = keepgoing int b_out = b

for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
/* Implicitly-defined code: bind actual parameter values

to formal parameter variables of loop-body */

bool keepgoing_in = keepgoing_out; bool b_in = b_out;

/* User-defined code (loop body) / int my_local = a + b_in; // Reading value “a” from the enclosing scope is fine b_out = a - b_in; keepgoing_out = my_local > b_out; user_defined_val = b_in + b_in; // b_in and b_out are different variables / End user-defined code */

/* Implicitly defined-code */ user_defined_vals[i] = user_defined_val // accumulate scan-output values

} // int t = my_local; // Can’t do this. my_local is not accessible here.

// The values below are bound to the output variables of the loop and therefore accessible // b_out; user_defined_vals; keepgoing_out;

}

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable “a” here) are in scope and can be referenced in the inputs of the loop.

  2. Any values computed in the loop body that needs to be used in a subsequent iteration or after the loop are modelled using a pair of variables in the loop-body, consisting of an input variable (eg., b_in) and an output variable (eg., b_out). These are referred to as loop-carried dependences. The loop operation node supplies the input value of the input variable for the first iteration, and returns the output value of the output variable produced by the final iteration.

  3. Scan_output variables are used to implicitly concatenate values computed across all the iterations. In the above example, the value of user_defined_val computed over all iterations are concatenated and returned as the value of user_defined_vals after the loop.

  4. Values created in the body cannot be accessed in the enclosing scope, except using the mechanism described above.

Note that the semantics of this op support “diagonal” or “wavefront” execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

The input/output of subgraph (produced by loop node) matching is based on order instead of name. The implementation will figure out the names based on this order.

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • M (optional, heterogeneous)I: A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.

  • cond (optional, heterogeneous)B: A boolean termination condition. Optional. Pass empty string to skip.

  • v_initial (variadic)V: The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs

Between 1 and 2147483647 outputs.

  • v_final_and_scan_outputs (variadic)V: Final N loop carried dependency values then K scan_outputs. Scan outputs must be Tensors.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(bfloat16)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)), seq(tensor(float8e4m3fn)), seq(tensor(float8e4m3fnuz)), seq(tensor(float8e5m2)), seq(tensor(float8e5m2fnuz)), seq(tensor(uint4)), seq(tensor(int4)), optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(bfloat16))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(bfloat16)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), optional(tensor(float8e4m3fn)), optional(tensor(float8e4m3fnuz)), optional(tensor(float8e5m2)), optional(tensor(float8e5m2fnuz)), optional(tensor(uint4)), optional(tensor(int4)): All Tensor, Sequence(Tensor), Optional(Tensor), and Optional(Sequence(Tensor)) types up to IRv10.

  • I tensor(int64): tensor of int64, which should be a scalar.

  • B tensor(bool): tensor of bool, which should be a scalar.

OnnxLpNormalization#

class skl2onnx.algebra.onnx_ops.OnnxLpNormalization(*args, **kwargs)#

Version

Onnx name: LpNormalization

This version of the operator has been available since version 1.

Summary

Given a matrix, apply Lp-normalization along the provided axis.

Attributes

  • axis: The axis on which to apply normalization, -1 mean last axis. Default value is name: "axis" type: INT i: -1

  • p: The order of the normalization, only 1 or 2 are supported. Default value is name: "p" type: INT i: 2

Inputs

  • input (heterogeneous)T: Input matrix

Outputs

  • output (heterogeneous)T: Matrix after normalization

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLpNormalization_1#

class skl2onnx.algebra.onnx_ops.OnnxLpNormalization_1(*args, **kwargs)#

Version

Onnx name: LpNormalization

This version of the operator has been available since version 1.

Summary

Given a matrix, apply Lp-normalization along the provided axis.

Attributes

  • axis: The axis on which to apply normalization, -1 mean last axis. Default value is name: "axis" type: INT i: -1

  • p: The order of the normalization, only 1 or 2 are supported. Default value is name: "p" type: INT i: 2

Inputs

  • input (heterogeneous)T: Input matrix

Outputs

  • output (heterogeneous)T: Matrix after normalization

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLpPool#

class skl2onnx.algebra.onnx_ops.OnnxLpPool(*args, **kwargs)#

Version

Onnx name: LpPool

This version of the operator has been available since version 18.

Summary

LpPool consumes an input tensor X and applies Lp pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled pad_shape[i] is the sum of pads along axis i.

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - {kernelSpatialShape} + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + {kernelSpatialShape} - input_spatial_shape[i]

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • p: p value of the Lp norm used to pool over the input data. Default value is name: "p" type: INT i: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLpPool_1#

class skl2onnx.algebra.onnx_ops.OnnxLpPool_1(*args, **kwargs)#

Version

Onnx name: LpPool

This version of the operator has been available since version 1.

Summary

LpPool consumes an input tensor X and applies Lp pooling across the the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. DEPRECATION NOTE: auto_pad is only intended to support legacy uses, and for framework authors, one is explicitly encouraged to use explicit padding specified in the pads attribute. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • p: p value of the Lp norm used to pool over the input data, default is 2.0. Default value is name: "p" type: FLOAT f: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimension are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLpPool_11#

class skl2onnx.algebra.onnx_ops.OnnxLpPool_11(*args, **kwargs)#

Version

Onnx name: LpPool

This version of the operator has been available since version 11.

Summary

LpPool consumes an input tensor X and applies Lp pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • p: p value of the Lp norm used to pool over the input data. Default value is name: "p" type: INT i: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLpPool_18#

class skl2onnx.algebra.onnx_ops.OnnxLpPool_18(*args, **kwargs)#

Version

Onnx name: LpPool

This version of the operator has been available since version 18.

Summary

LpPool consumes an input tensor X and applies Lp pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled pad_shape[i] is the sum of pads along axis i.

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - {kernelSpatialShape} + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + {kernelSpatialShape} - input_spatial_shape[i]

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • p: p value of the Lp norm used to pool over the input data. Default value is name: "p" type: INT i: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxLpPool_2#

class skl2onnx.algebra.onnx_ops.OnnxLpPool_2(*args, **kwargs)#

Version

Onnx name: LpPool

This version of the operator has been available since version 2.

Summary

LpPool consumes an input tensor X and applies Lp pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • p: p value of the Lp norm used to pool over the input data. Default value is name: "p" type: INT i: 2

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.

Outputs

  • Y (heterogeneous)T: Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMatMul#

class skl2onnx.algebra.onnx_ops.OnnxMatMul(*args, **kwargs)#

Version

Onnx name: MatMul

This version of the operator has been available since version 13.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

Inputs

  • A (heterogeneous)T: N-dimensional matrix A

  • B (heterogeneous)T: N-dimensional matrix B

Outputs

  • Y (heterogeneous)T: Matrix multiply results from A * B

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(bfloat16): Constrain input and output types to float/int tensors.

OnnxMatMulInteger#

class skl2onnx.algebra.onnx_ops.OnnxMatMulInteger(*args, **kwargs)#

Version

Onnx name: MatMulInteger

This version of the operator has been available since version 10.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html. The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.

Inputs

Between 2 and 4 inputs.

  • A (heterogeneous)T1: N-dimensional matrix A

  • B (heterogeneous)T2: N-dimensional matrix B

  • a_zero_point (optional, heterogeneous)T1: Zero point tensor for input ‘A’. It’s optional and default value is 0. It could be a scalar or N-D tensor. Scalar refers to per tensor quantization whereas N-D refers to per row quantization. If the input is 2D of shape [M, K] then zero point tensor may be an M element vector [zp_1, zp_2, …, zp_M]. If the input is N-D tensor with shape [D1, D2, M, K] then zero point tensor may have shape [D1, D2, M, 1].

  • b_zero_point (optional, heterogeneous)T2: Zero point tensor for input ‘B’. It’s optional and default value is 0. It could be a scalar or a N-D tensor, Scalar refers to per tensor quantization whereas N-D refers to per col quantization. If the input is 2D of shape [K, N] then zero point tensor may be an N element vector [zp_1, zp_2, …, zp_N]. If the input is N-D tensor with shape [D1, D2, K, N] then zero point tensor may have shape [D1, D2, 1, N].

Outputs

  • Y (heterogeneous)T3: Matrix multiply results from A * B

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input A data type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain input B data type to 8-bit integer tensor.

  • T3 tensor(int32): Constrain output Y data type as 32-bit integer tensor.

OnnxMatMulInteger_10#

class skl2onnx.algebra.onnx_ops.OnnxMatMulInteger_10(*args, **kwargs)#

Version

Onnx name: MatMulInteger

This version of the operator has been available since version 10.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html. The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.

Inputs

Between 2 and 4 inputs.

  • A (heterogeneous)T1: N-dimensional matrix A

  • B (heterogeneous)T2: N-dimensional matrix B

  • a_zero_point (optional, heterogeneous)T1: Zero point tensor for input ‘A’. It’s optional and default value is 0. It could be a scalar or N-D tensor. Scalar refers to per tensor quantization whereas N-D refers to per row quantization. If the input is 2D of shape [M, K] then zero point tensor may be an M element vector [zp_1, zp_2, …, zp_M]. If the input is N-D tensor with shape [D1, D2, M, K] then zero point tensor may have shape [D1, D2, M, 1].

  • b_zero_point (optional, heterogeneous)T2: Zero point tensor for input ‘B’. It’s optional and default value is 0. It could be a scalar or a N-D tensor, Scalar refers to per tensor quantization whereas N-D refers to per col quantization. If the input is 2D of shape [K, N] then zero point tensor may be an N element vector [zp_1, zp_2, …, zp_N]. If the input is N-D tensor with shape [D1, D2, K, N] then zero point tensor may have shape [D1, D2, 1, N].

Outputs

  • Y (heterogeneous)T3: Matrix multiply results from A * B

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input A data type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain input B data type to 8-bit integer tensor.

  • T3 tensor(int32): Constrain output Y data type as 32-bit integer tensor.

OnnxMatMul_1#

class skl2onnx.algebra.onnx_ops.OnnxMatMul_1(*args, **kwargs)#

Version

Onnx name: MatMul

This version of the operator has been available since version 1.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

Inputs

  • A (heterogeneous)T: N-dimensional matrix A

  • B (heterogeneous)T: N-dimensional matrix B

Outputs

  • Y (heterogeneous)T: Matrix multiply results from A * B

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMatMul_13#

class skl2onnx.algebra.onnx_ops.OnnxMatMul_13(*args, **kwargs)#

Version

Onnx name: MatMul

This version of the operator has been available since version 13.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

Inputs

  • A (heterogeneous)T: N-dimensional matrix A

  • B (heterogeneous)T: N-dimensional matrix B

Outputs

  • Y (heterogeneous)T: Matrix multiply results from A * B

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(bfloat16): Constrain input and output types to float/int tensors.

OnnxMatMul_9#

class skl2onnx.algebra.onnx_ops.OnnxMatMul_9(*args, **kwargs)#

Version

Onnx name: MatMul

This version of the operator has been available since version 9.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

Inputs

  • A (heterogeneous)T: N-dimensional matrix A

  • B (heterogeneous)T: N-dimensional matrix B

Outputs

  • Y (heterogeneous)T: Matrix multiply results from A * B

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64): Constrain input and output types to float/int tensors.

OnnxMax#

class skl2onnx.algebra.onnx_ops.OnnxMax(*args, **kwargs)#

Version

Onnx name: Max

This version of the operator has been available since version 13.

Summary

Element-wise max of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for max.

Outputs

  • max (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxMaxPool#

class skl2onnx.algebra.onnx_ops.OnnxMaxPool(*args, **kwargs)#

Version

Onnx name: MaxPool

This version of the operator has been available since version 12.

Summary

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape is calculated differently depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d):

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled. pad_shape[i] is the sum of pads along axis i.

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D):

VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. This attribute is used only to convert an n-tuple index value into a single integer value for producing the second output. Default value is name: "storage_order" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

Between 1 and 2 outputs.

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

  • Indices (optional, heterogeneous)I: Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(uint8): Constrain input and output types to float and 8 bit tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxMaxPool_1#

class skl2onnx.algebra.onnx_ops.OnnxMaxPool_1(*args, **kwargs)#

Version

Onnx name: MaxPool

This version of the operator has been available since version 1.

Summary

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMaxPool_10#

class skl2onnx.algebra.onnx_ops.OnnxMaxPool_10(*args, **kwargs)#

Version

Onnx name: MaxPool

This version of the operator has been available since version 10.

Summary

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. Default value is name: "storage_order" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

Between 1 and 2 outputs.

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

  • Indices (optional, heterogeneous)I: Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxMaxPool_11#

class skl2onnx.algebra.onnx_ops.OnnxMaxPool_11(*args, **kwargs)#

Version

Onnx name: MaxPool

This version of the operator has been available since version 11.

Summary

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. Default value is name: "storage_order" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

Between 1 and 2 outputs.

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

  • Indices (optional, heterogeneous)I: Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxMaxPool_12#

class skl2onnx.algebra.onnx_ops.OnnxMaxPool_12(*args, **kwargs)#

Version

Onnx name: MaxPool

This version of the operator has been available since version 12.

Summary

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape is calculated differently depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d):

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

or#

output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)

if ceil_mode is enabled. pad_shape[i] is the sum of pads along axis i.

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D):

VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is name: "ceil_mode" type: INT i: 0

  • storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. This attribute is used only to convert an n-tuple index value into a single integer value for producing the second output. Default value is name: "storage_order" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

Between 1 and 2 outputs.

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

  • Indices (optional, heterogeneous)I: Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(uint8): Constrain input and output types to float and 8 bit tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxMaxPool_8#

class skl2onnx.algebra.onnx_ops.OnnxMaxPool_8(*args, **kwargs)#

Version

Onnx name: MaxPool

This version of the operator has been available since version 8.

Summary

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. Default value is name: "storage_order" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

Outputs

Between 1 and 2 outputs.

  • Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

  • Indices (optional, heterogeneous)I: Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxMaxRoiPool#

class skl2onnx.algebra.onnx_ops.OnnxMaxRoiPool(*args, **kwargs)#

Version

Onnx name: MaxRoiPool

This version of the operator has been available since version 1.

Summary

ROI max pool consumes an input tensor X and region of interests (RoIs) to apply max pooling across each RoI, to produce output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).

Attributes

  • spatial_scale: Multiplicative spatial scale factor to translate ROI coordinates from their input scale to the scale used when pooling. Default value is name: "spatial_scale" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.

  • rois (heterogeneous)T: RoIs (Regions of Interest) to pool over. Should be a 2-D tensor of shape (num_rois, 5) given as [[batch_id, x1, y1, x2, y2], …].

Outputs

  • Y (heterogeneous)T: RoI pooled output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMaxRoiPool_1#

class skl2onnx.algebra.onnx_ops.OnnxMaxRoiPool_1(*args, **kwargs)#

Version

Onnx name: MaxRoiPool

This version of the operator has been available since version 1.

Summary

ROI max pool consumes an input tensor X and region of interests (RoIs) to apply max pooling across each RoI, to produce output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).

Attributes

  • spatial_scale: Multiplicative spatial scale factor to translate ROI coordinates from their input scale to the scale used when pooling. Default value is name: "spatial_scale" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.

  • rois (heterogeneous)T: RoIs (Regions of Interest) to pool over. Should be a 2-D tensor of shape (num_rois, 5) given as [[batch_id, x1, y1, x2, y2], …].

Outputs

  • Y (heterogeneous)T: RoI pooled output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMaxUnpool#

class skl2onnx.algebra.onnx_ops.OnnxMaxUnpool(*args, **kwargs)#

Version

Onnx name: MaxUnpool

This version of the operator has been available since version 11.

Summary

MaxUnpool essentially computes the partial inverse of the MaxPool op.

The input information to this op is typically the output information from a MaxPool op. The first input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) from MaxPool. The second input tensor, I, contains the indices to the (locally maximal) elements corresponding to the elements in the first input tensor X. Input tensor I is typically the second output of the MaxPool op. The third (optional) input is a tensor that specifies the output size of the unpooling operation.

MaxUnpool is intended to do ‘partial’ inverse of the MaxPool op. ‘Partial’ because all the non-maximal

values from the original input to MaxPool are set to zero in the output of the MaxUnpool op. Pooling the result of an unpooling operation should give back the original input to the unpooling op.

MaxUnpool can produce the same output size for several input sizes, which makes unpooling op ambiguous.

The third input argument, output_size, is meant to disambiguate the op and produce output tensor of known/predictable size.

In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape, strides, and pads,

which define the exact unpooling op. The attributes typically have the same values as the corresponding pooling op that the unpooling op is trying to invert.

Attributes

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T1: Input data tensor that has to be unpooled. This tensor is typically the first output of the MaxPool op.Dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non-image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • I (heterogeneous)T2: Input data tensor containing the indices corresponding to elements in the first input tensor X.This tensor is typically the second output of the MaxPool op.Dimensions must be the same as input tensor X. The indices are linear, i.e. computed considering the tensor as flattened 1-D tensor, assuming row-major storage. Also, the linear indices should not consider padding. So the values in indices are in the range [0, N x C x D1 x … x Dn).

  • output_shape (optional, heterogeneous)T2: The shape of the output can be explicitly set which will cause pads values to be auto generated. If ‘output_shape’ is specified, ‘pads’ values are ignored.

Outputs

  • output (heterogeneous)T1: Output data tensor that contains the result of the unpooling.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T2 tensor(int64): Constrain index tensor to int64

OnnxMaxUnpool_11#

class skl2onnx.algebra.onnx_ops.OnnxMaxUnpool_11(*args, **kwargs)#

Version

Onnx name: MaxUnpool

This version of the operator has been available since version 11.

Summary

MaxUnpool essentially computes the partial inverse of the MaxPool op.

The input information to this op is typically the output information from a MaxPool op. The first input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) from MaxPool. The second input tensor, I, contains the indices to the (locally maximal) elements corresponding to the elements in the first input tensor X. Input tensor I is typically the second output of the MaxPool op. The third (optional) input is a tensor that specifies the output size of the unpooling operation.

MaxUnpool is intended to do ‘partial’ inverse of the MaxPool op. ‘Partial’ because all the non-maximal

values from the original input to MaxPool are set to zero in the output of the MaxUnpool op. Pooling the result of an unpooling operation should give back the original input to the unpooling op.

MaxUnpool can produce the same output size for several input sizes, which makes unpooling op ambiguous.

The third input argument, output_size, is meant to disambiguate the op and produce output tensor of known/predictable size.

In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape, strides, and pads,

which define the exact unpooling op. The attributes typically have the same values as the corresponding pooling op that the unpooling op is trying to invert.

Attributes

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T1: Input data tensor that has to be unpooled. This tensor is typically the first output of the MaxPool op.Dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non-image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • I (heterogeneous)T2: Input data tensor containing the indices corresponding to elements in the first input tensor X.This tensor is typically the second output of the MaxPool op.Dimensions must be the same as input tensor X. The indices are linear, i.e. computed considering the tensor as flattened 1-D tensor, assuming row-major storage. Also, the linear indices should not consider padding. So the values in indices are in the range [0, N x C x D1 x … x Dn).

  • output_shape (optional, heterogeneous)T2: The shape of the output can be explicitly set which will cause pads values to be auto generated. If ‘output_shape’ is specified, ‘pads’ values are ignored.

Outputs

  • output (heterogeneous)T1: Output data tensor that contains the result of the unpooling.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T2 tensor(int64): Constrain index tensor to int64

OnnxMaxUnpool_9#

class skl2onnx.algebra.onnx_ops.OnnxMaxUnpool_9(*args, **kwargs)#

Version

Onnx name: MaxUnpool

This version of the operator has been available since version 9.

Summary

MaxUnpool essentially computes the partial inverse of the MaxPool op.

The input information to this op is typically the output information from a MaxPool op. The first input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) from MaxPool. The second input tensor, I, contains the indices to the (locally maximal) elements corresponding to the elements in the first input tensor X. Input tensor I is typically the second output of the MaxPool op. The third (optional) input is a tensor that specifies the output size of the unpooling operation.

MaxUnpool is intended to do ‘partial’ inverse of the MaxPool op. ‘Partial’ because all the non-maximal

values from the original input to MaxPool are set to zero in the output of the MaxUnpool op. Pooling the result of an unpooling operation should give back the original input to the unpooling op.

MaxUnpool can produce the same output size for several input sizes, which makes unpooling op ambiguous.

The third input argument, output_size, is meant to disambiguate the op and produce output tensor of known/predictable size.

In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape, strides, and pads,

which define the exact unpooling op. The attributes typically have the same values as the corresponding pooling op that the unpooling op is trying to invert.

Attributes

Inputs

Between 2 and 3 inputs.

  • X (heterogeneous)T1: Input data tensor that has to be unpooled. This tensor is typically the first output of the MaxPool op.Dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non-image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • I (heterogeneous)T2: Input data tensor containing the indices corresponding to elements in the first input tensor X.This tensor is typically the second output of the MaxPool op.Dimensions must be the same as input tensor X. The indices are linear, i.e. computed considering the tensor as flattened 1-D tensor, assuming row-major storage. Also, the linear indices should not consider padding. So the values in indices are in the range [0, N x C x D1 x … x Dn).

  • output_shape (optional, heterogeneous)T2: The shape of the output can be explicitly set which will cause pads values to be auto generated. If ‘output_shape’ is specified, ‘pads’ values are ignored.

Outputs

  • output (heterogeneous)T1: Output data tensor that contains the result of the unpooling.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T2 tensor(int64): Constrain index tensor to int64

OnnxMax_1#

class skl2onnx.algebra.onnx_ops.OnnxMax_1(*args, **kwargs)#

Version

Onnx name: Max

This version of the operator has been available since version 1.

Summary

Element-wise max of each of the input tensors. All inputs and outputs must have the same shape and data type.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Max.

Outputs

  • max (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMax_12#

class skl2onnx.algebra.onnx_ops.OnnxMax_12(*args, **kwargs)#

Version

Onnx name: Max

This version of the operator has been available since version 12.

Summary

Element-wise max of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for max.

Outputs

  • max (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to numeric tensors.

OnnxMax_13#

class skl2onnx.algebra.onnx_ops.OnnxMax_13(*args, **kwargs)#

Version

Onnx name: Max

This version of the operator has been available since version 13.

Summary

Element-wise max of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for max.

Outputs

  • max (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxMax_6#

class skl2onnx.algebra.onnx_ops.OnnxMax_6(*args, **kwargs)#

Version

Onnx name: Max

This version of the operator has been available since version 6.

Summary

Element-wise max of each of the input tensors. All inputs and outputs must have the same shape and data type.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Max.

Outputs

  • max (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMax_8#

class skl2onnx.algebra.onnx_ops.OnnxMax_8(*args, **kwargs)#

Version

Onnx name: Max

This version of the operator has been available since version 8.

Summary

Element-wise max of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for max.

Outputs

  • max (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMean#

class skl2onnx.algebra.onnx_ops.OnnxMean(*args, **kwargs)#

Version

Onnx name: Mean

This version of the operator has been available since version 13.

Summary

Element-wise mean of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for mean.

Outputs

  • mean (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxMeanVarianceNormalization#

class skl2onnx.algebra.onnx_ops.OnnxMeanVarianceNormalization(*args, **kwargs)#

Version

Onnx name: MeanVarianceNormalization

This version of the operator has been available since version 13.

Summary

A MeanVarianceNormalization Function: Perform mean variance normalization on the input tensor X using formula: (X-EX)/sqrt(E(X-EX)^2)

Attributes

  • axes: A list of integers, along which to reduce. The default is to calculate along axes [0,2,3] for calculating mean and variance along each channel. Two variables with the same C-coordinate are associated with the same mean and variance. Default value is name: "axes" type: INTS ints: 0 ints: 2 ints: 3

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxMeanVarianceNormalization_13#

class skl2onnx.algebra.onnx_ops.OnnxMeanVarianceNormalization_13(*args, **kwargs)#

Version

Onnx name: MeanVarianceNormalization

This version of the operator has been available since version 13.

Summary

A MeanVarianceNormalization Function: Perform mean variance normalization on the input tensor X using formula: (X-EX)/sqrt(E(X-EX)^2)

Attributes

  • axes: A list of integers, along which to reduce. The default is to calculate along axes [0,2,3] for calculating mean and variance along each channel. Two variables with the same C-coordinate are associated with the same mean and variance. Default value is name: "axes" type: INTS ints: 0 ints: 2 ints: 3

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxMeanVarianceNormalization_9#

class skl2onnx.algebra.onnx_ops.OnnxMeanVarianceNormalization_9(*args, **kwargs)#

Version

Onnx name: MeanVarianceNormalization

This version of the operator has been available since version 9.

Summary

A MeanVarianceNormalization Function: Perform mean variance normalization on the input tensor X using formula: <br/> ` (X-EX)/sqrt(E(X-EX)^2) `

Attributes

  • axes: A list of integers, along which to reduce. The default is to calculate along axes [0,2,3] for calculating mean and variance along each channel. Two variables with the same C-coordinate are associated with the same mean and variance. Default value is name: "axes" type: INTS ints: 0 ints: 2 ints: 3

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxMean_1#

class skl2onnx.algebra.onnx_ops.OnnxMean_1(*args, **kwargs)#

Version

Onnx name: Mean

This version of the operator has been available since version 1.

Summary

Element-wise mean of each of the input tensors. All inputs and outputs must have the same shape and data type.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Mean.

Outputs

  • mean (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMean_13#

class skl2onnx.algebra.onnx_ops.OnnxMean_13(*args, **kwargs)#

Version

Onnx name: Mean

This version of the operator has been available since version 13.

Summary

Element-wise mean of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for mean.

Outputs

  • mean (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxMean_6#

class skl2onnx.algebra.onnx_ops.OnnxMean_6(*args, **kwargs)#

Version

Onnx name: Mean

This version of the operator has been available since version 6.

Summary

Element-wise mean of each of the input tensors. All inputs and outputs must have the same shape and data type.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Mean.

Outputs

  • mean (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMean_8#

class skl2onnx.algebra.onnx_ops.OnnxMean_8(*args, **kwargs)#

Version

Onnx name: Mean

This version of the operator has been available since version 8.

Summary

Element-wise mean of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for mean.

Outputs

  • mean (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMelWeightMatrix#

class skl2onnx.algebra.onnx_ops.OnnxMelWeightMatrix(*args, **kwargs)#

Version

Onnx name: MelWeightMatrix

This version of the operator has been available since version 17.

Summary

Generate a MelWeightMatrix that can be used to re-weight a Tensor containing a linearly sampled frequency spectra (from DFT or STFT) into num_mel_bins frequency information based on the [lower_edge_hertz, upper_edge_hertz] range on the mel scale. This function defines the mel scale in terms of a frequency in hertz according to the following formula:

mel(f) = 2595 * log10(1 + f/700)

In the returned matrix, all the triangles (filterbanks) have a peak value of 1.0.

The returned MelWeightMatrix can be used to right-multiply a spectrogram S of shape [frames, num_spectrogram_bins] of linear scale spectrum values (e.g. STFT magnitudes) to generate a “mel spectrogram” M of shape [frames, num_mel_bins].

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T3. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

Inputs

  • num_mel_bins (heterogeneous)T1: The number of bands in the mel spectrum.

  • dft_length (heterogeneous)T1: The size of the original DFT. The size of the original DFT is used to infer the size of the onesided DFT, which is understood to be floor(dft_length/2) + 1, i.e. the spectrogram only contains the nonredundant DFT bins.

  • sample_rate (heterogeneous)T1: Samples per second of the input signal used to create the spectrogram. Used to figure out the frequencies corresponding to each spectrogram bin, which dictates how they are mapped into the mel scale.

  • lower_edge_hertz (heterogeneous)T2: Lower bound on the frequencies to be included in the mel spectrum. This corresponds to the lower edge of the lowest triangular band.

  • upper_edge_hertz (heterogeneous)T2: The desired top edge of the highest frequency band.

Outputs

  • output (heterogeneous)T3: The Mel Weight Matrix. The output has the shape: [floor(dft_length/2) + 1][num_mel_bins].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain to integer tensors.

  • T2 tensor(float), tensor(float16), tensor(double), tensor(bfloat16): Constrain to float tensors

  • T3 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain to any numerical types.

OnnxMelWeightMatrix_17#

class skl2onnx.algebra.onnx_ops.OnnxMelWeightMatrix_17(*args, **kwargs)#

Version

Onnx name: MelWeightMatrix

This version of the operator has been available since version 17.

Summary

Generate a MelWeightMatrix that can be used to re-weight a Tensor containing a linearly sampled frequency spectra (from DFT or STFT) into num_mel_bins frequency information based on the [lower_edge_hertz, upper_edge_hertz] range on the mel scale. This function defines the mel scale in terms of a frequency in hertz according to the following formula:

mel(f) = 2595 * log10(1 + f/700)

In the returned matrix, all the triangles (filterbanks) have a peak value of 1.0.

The returned MelWeightMatrix can be used to right-multiply a spectrogram S of shape [frames, num_spectrogram_bins] of linear scale spectrum values (e.g. STFT magnitudes) to generate a “mel spectrogram” M of shape [frames, num_mel_bins].

Attributes

  • output_datatype: The data type of the output tensor. Strictly must be one of the values from DataType enum in TensorProto whose values correspond to T3. The default value is 1 = FLOAT. Default value is name: "output_datatype" type: INT i: 1

Inputs

  • num_mel_bins (heterogeneous)T1: The number of bands in the mel spectrum.

  • dft_length (heterogeneous)T1: The size of the original DFT. The size of the original DFT is used to infer the size of the onesided DFT, which is understood to be floor(dft_length/2) + 1, i.e. the spectrogram only contains the nonredundant DFT bins.

  • sample_rate (heterogeneous)T1: Samples per second of the input signal used to create the spectrogram. Used to figure out the frequencies corresponding to each spectrogram bin, which dictates how they are mapped into the mel scale.

  • lower_edge_hertz (heterogeneous)T2: Lower bound on the frequencies to be included in the mel spectrum. This corresponds to the lower edge of the lowest triangular band.

  • upper_edge_hertz (heterogeneous)T2: The desired top edge of the highest frequency band.

Outputs

  • output (heterogeneous)T3: The Mel Weight Matrix. The output has the shape: [floor(dft_length/2) + 1][num_mel_bins].

Type Constraints

  • T1 tensor(int32), tensor(int64): Constrain to integer tensors.

  • T2 tensor(float), tensor(float16), tensor(double), tensor(bfloat16): Constrain to float tensors

  • T3 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain to any numerical types.

OnnxMin#

class skl2onnx.algebra.onnx_ops.OnnxMin(*args, **kwargs)#

Version

Onnx name: Min

This version of the operator has been available since version 13.

Summary

Element-wise min of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for min.

Outputs

  • min (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxMin_1#

class skl2onnx.algebra.onnx_ops.OnnxMin_1(*args, **kwargs)#

Version

Onnx name: Min

This version of the operator has been available since version 1.

Summary

Element-wise min of each of the input tensors. All inputs and outputs must have the same shape and data type.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Min

Outputs

  • min (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMin_12#

class skl2onnx.algebra.onnx_ops.OnnxMin_12(*args, **kwargs)#

Version

Onnx name: Min

This version of the operator has been available since version 12.

Summary

Element-wise min of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for min.

Outputs

  • min (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to numeric tensors.

OnnxMin_13#

class skl2onnx.algebra.onnx_ops.OnnxMin_13(*args, **kwargs)#

Version

Onnx name: Min

This version of the operator has been available since version 13.

Summary

Element-wise min of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for min.

Outputs

  • min (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxMin_6#

class skl2onnx.algebra.onnx_ops.OnnxMin_6(*args, **kwargs)#

Version

Onnx name: Min

This version of the operator has been available since version 6.

Summary

Element-wise min of each of the input tensors. All inputs and outputs must have the same shape and data type.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Min

Outputs

  • min (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMin_8#

class skl2onnx.algebra.onnx_ops.OnnxMin_8(*args, **kwargs)#

Version

Onnx name: Min

This version of the operator has been available since version 8.

Summary

Element-wise min of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for min.

Outputs

  • min (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMish#

class skl2onnx.algebra.onnx_ops.OnnxMish(*args, **kwargs)#

Version

Onnx name: Mish

This version of the operator has been available since version 18.

Summary

Mish: A Self Regularized Non-Monotonic Neural Activation Function.

Perform the linear unit element-wise on the input tensor X using formula:

mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^{x}))

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input X and output types to float tensors.

OnnxMish_18#

class skl2onnx.algebra.onnx_ops.OnnxMish_18(*args, **kwargs)#

Version

Onnx name: Mish

This version of the operator has been available since version 18.

Summary

Mish: A Self Regularized Non-Monotonic Neural Activation Function.

Perform the linear unit element-wise on the input tensor X using formula:

mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^{x}))

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input X and output types to float tensors.

OnnxMod#

class skl2onnx.algebra.onnx_ops.OnnxMod(*args, **kwargs)#

Version

Onnx name: Mod

This version of the operator has been available since version 13.

Summary

Performs element-wise binary modulus (with Numpy-style broadcasting support). The sign of the remainder is the same as that of the Divisor.

Mod operator can also behave like C fmod() or numpy.fmod. In this case, the sign of the remainder however, will be the same as the Dividend (in contrast to integer mod). To force a behavior like numpy.fmod() an ‘fmod’ Attribute is provided. This attribute is set to 0 by default causing the behavior to be like integer mod. Setting this attribute to 1 causes the remainder to be calculated similar to that of numpy.fmod().

If the input type is floating point, then fmod attribute must be set to 1.

In case of dividend being zero, the results will be platform dependent.

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Attributes

  • fmod: Whether the operator should behave like fmod (default=0 meaning it will do integer mods); Set this to 1 to force fmod treatment Default value is name: "fmod" type: INT i: 0

Inputs

  • A (heterogeneous)T: Dividend tensor

  • B (heterogeneous)T: Divisor tensor

Outputs

  • C (heterogeneous)T: Remainder tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

OnnxMod_10#

class skl2onnx.algebra.onnx_ops.OnnxMod_10(*args, **kwargs)#

Version

Onnx name: Mod

This version of the operator has been available since version 10.

Summary

Performs element-wise binary modulus (with Numpy-style broadcasting support).

The sign of the remainder is the same as that of the Divisor.

Mod operator can also behave like C fmod() or numpy.fmod. In this case, the sign of the remainder however, will be the same as the Dividend (in contrast to integer mod). To force a behavior like numpy.fmod() an ‘fmod’ Attribute is provided. This attribute is set to 0 by default causing the behavior to be like integer mod. Setting this attribute to 1 causes the remainder to be calculated similar to that of numpy.fmod().

If the input type is floating point, then fmod attribute must be set to 1.

In case of dividend being zero, the results will be platform dependent.

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Attributes

  • fmod: Whether the operator should behave like fmod (default=0 meaning it will do integer mods); Set this to 1 to force fmod treatment Default value is name: "fmod" type: INT i: 0

Inputs

  • A (heterogeneous)T: Dividend tensor

  • B (heterogeneous)T: Divisor tensor

Outputs

  • C (heterogeneous)T: Remainder tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxMod_13#

class skl2onnx.algebra.onnx_ops.OnnxMod_13(*args, **kwargs)#

Version

Onnx name: Mod

This version of the operator has been available since version 13.

Summary

Performs element-wise binary modulus (with Numpy-style broadcasting support). The sign of the remainder is the same as that of the Divisor.

Mod operator can also behave like C fmod() or numpy.fmod. In this case, the sign of the remainder however, will be the same as the Dividend (in contrast to integer mod). To force a behavior like numpy.fmod() an ‘fmod’ Attribute is provided. This attribute is set to 0 by default causing the behavior to be like integer mod. Setting this attribute to 1 causes the remainder to be calculated similar to that of numpy.fmod().

If the input type is floating point, then fmod attribute must be set to 1.

In case of dividend being zero, the results will be platform dependent.

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Attributes

  • fmod: Whether the operator should behave like fmod (default=0 meaning it will do integer mods); Set this to 1 to force fmod treatment Default value is name: "fmod" type: INT i: 0

Inputs

  • A (heterogeneous)T: Dividend tensor

  • B (heterogeneous)T: Divisor tensor

Outputs

  • C (heterogeneous)T: Remainder tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

OnnxMomentum#

class skl2onnx.algebra.onnx_ops.OnnxMomentum(*args, **kwargs)#

Version

Onnx name: Momentum

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Compute one iteration of stochastic gradient update with momentum. This operator can conduct the optimization of multiple tensor variables.

Let’s define the behavior of this operator. As you can imagine, SG with momentum requires several parameters:

  • The learning-rate “R”.

  • The update count “T”. That is, the number of conducted training iterations. It should be zero in the first training iteration.

  • A L2-norm regularization coefficient “norm_coefficient”.

  • A decay coefficient of previous accumulated gradient (i.e., momentum) “alpha”.

  • The scaling coefficient of current gradient “beta”.

  • An attribute to choose either standard momentum or Nesterov’s momentum “mode” should be used.

For the sake of simplicity, assume that there is only one tensor (called “X”) to be optimized. Other necessary inputs are “X“‘s gradient (called “G”) and “X“‘s momentum (called “V”). This Momentum operator maps all these inputs to the new value of “X” (called “X_new”) and its new momentum (called “V_new”).

This operator supports two different momentum algorithms. Set the attribute “mode” to “nesterov” if Nesterov’s momentum is desired. Otherwise, set the attribute “model” to “standard” to use standard momentum. Computation details are described subsequently.

Let “+”, “-”, “*”, and “/” are all element-wise operations with numpy-style broadcasting.

Pseudo code for SG with standard momentum:

// Add gradient of 0.5 * norm_coefficient * ||X||^2, where ||X|| is the sum of squared // values of all elements in X. G_regularized = norm_coefficient * X + G

// In the first training iteration, beta should always be 1. beta_adjusted = T > 0 ? beta : 1

// Compute the current momentum based on previous momentum and the current gradient. V_new = alpha * V + beta_adjusted * G_regularized

// Update X. X_new = X - R * V_new

Pseudo code for SG with Nesterov’s momentum:

// Add gradient of 0.5 * norm_coefficient * ||X||^2, where ||X|| is the sum of squared // values of all elements in X. G_regularized = norm_coefficient * X + G;

// In the first training iteration, beta should always be 1. beta_adjusted = T > 0 ? beta : 1

// Compute the current momentum based on previous momentum and the current gradient. V_new = alpha * V + beta_adjusted * G_regularized;

// Compute final update direction and then update X. X_new = X - R * (G_regularized + alpha * V_new)

If one assign this operators to optimize multiple inputs, for example, “X_1” and “X_2”. The same pseudo code would be extended to handle all tensors jointly. More specifically, we can view “X” as a concatenation of “X_1” and “X_2” (of course, their gradient and accumulate gradient should be concatenated too) and then our pseudo code becomes applicable.

Attributes

Inputs

Between 3 and 2147483647 inputs.

  • R (heterogeneous)T1: The learning rate.

  • T (heterogeneous)T2: Update count of “X”. It should be a scalar.

  • inputs (variadic)T3: It sequentially contains the current values of optimized tensors, then their gradient tensors, and finally their momentum tensors. For example, if two tensors “X_1” and “X_2” are optimized, The expected input list would be [“X_1”, “X_2”, gradient of “X_1”, gradient of “X_2”, momentum of “X_1”, momentum of “X_2”].

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)T3: It sequentially contains the new values of optimized tensors and then the new values of their momentum tensors. For example, if two tensors “X_1” and “X_2” are optimized, the output list would be [new value of “X_1,” new value of “X_2” new momentum of “X_1”, new momentum of “X_2”].

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float scalars.

  • T2 tensor(int64): Constrain input types to 64-bit integer scalars.

  • T3 tensor(float), tensor(double): Constrain input types to float tensors.

OnnxMomentum_1#

class skl2onnx.algebra.onnx_ops.OnnxMomentum_1(*args, **kwargs)#

Version

Onnx name: Momentum

This version of the operator has been available since version 1 of domain ai.onnx.preview.training.

Summary

Compute one iteration of stochastic gradient update with momentum. This operator can conduct the optimization of multiple tensor variables.

Let’s define the behavior of this operator. As you can imagine, SG with momentum requires several parameters:

  • The learning-rate “R”.

  • The update count “T”. That is, the number of conducted training iterations. It should be zero in the first training iteration.

  • A L2-norm regularization coefficient “norm_coefficient”.

  • A decay coefficient of previous accumulated gradient (i.e., momentum) “alpha”.

  • The scaling coefficient of current gradient “beta”.

  • An attribute to choose either standard momentum or Nesterov’s momentum “mode” should be used.

For the sake of simplicity, assume that there is only one tensor (called “X”) to be optimized. Other necessary inputs are “X“‘s gradient (called “G”) and “X“‘s momentum (called “V”). This Momentum operator maps all these inputs to the new value of “X” (called “X_new”) and its new momentum (called “V_new”).

This operator supports two different momentum algorithms. Set the attribute “mode” to “nesterov” if Nesterov’s momentum is desired. Otherwise, set the attribute “model” to “standard” to use standard momentum. Computation details are described subsequently.

Let “+”, “-”, “*”, and “/” are all element-wise operations with numpy-style broadcasting.

Pseudo code for SG with standard momentum:

// Add gradient of 0.5 * norm_coefficient * ||X||^2, where ||X|| is the sum of squared // values of all elements in X. G_regularized = norm_coefficient * X + G

// In the first training iteration, beta should always be 1. beta_adjusted = T > 0 ? beta : 1

// Compute the current momentum based on previous momentum and the current gradient. V_new = alpha * V + beta_adjusted * G_regularized

// Update X. X_new = X - R * V_new

Pseudo code for SG with Nesterov’s momentum:

// Add gradient of 0.5 * norm_coefficient * ||X||^2, where ||X|| is the sum of squared // values of all elements in X. G_regularized = norm_coefficient * X + G;

// In the first training iteration, beta should always be 1. beta_adjusted = T > 0 ? beta : 1

// Compute the current momentum based on previous momentum and the current gradient. V_new = alpha * V + beta_adjusted * G_regularized;

// Compute final update direction and then update X. X_new = X - R * (G_regularized + alpha * V_new)

If one assign this operators to optimize multiple inputs, for example, “X_1” and “X_2”. The same pseudo code would be extended to handle all tensors jointly. More specifically, we can view “X” as a concatenation of “X_1” and “X_2” (of course, their gradient and accumulate gradient should be concatenated too) and then our pseudo code becomes applicable.

Attributes

Inputs

Between 3 and 2147483647 inputs.

  • R (heterogeneous)T1: The learning rate.

  • T (heterogeneous)T2: Update count of “X”. It should be a scalar.

  • inputs (variadic)T3: It sequentially contains the current values of optimized tensors, then their gradient tensors, and finally their momentum tensors. For example, if two tensors “X_1” and “X_2” are optimized, The expected input list would be [“X_1”, “X_2”, gradient of “X_1”, gradient of “X_2”, momentum of “X_1”, momentum of “X_2”].

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic)T3: It sequentially contains the new values of optimized tensors and then the new values of their momentum tensors. For example, if two tensors “X_1” and “X_2” are optimized, the output list would be [new value of “X_1,” new value of “X_2” new momentum of “X_1”, new momentum of “X_2”].

Type Constraints

  • T1 tensor(float), tensor(double): Constrain input types to float scalars.

  • T2 tensor(int64): Constrain input types to 64-bit integer scalars.

  • T3 tensor(float), tensor(double): Constrain input types to float tensors.

OnnxMul#

class skl2onnx.algebra.onnx_ops.OnnxMul(*args, **kwargs)#

Version

Onnx name: Mul

This version of the operator has been available since version 14.

Summary

Performs element-wise binary multiplication (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxMul_1#

class skl2onnx.algebra.onnx_ops.OnnxMul_1(*args, **kwargs)#

Version

Onnx name: Mul

This version of the operator has been available since version 1.

Summary

Performs element-wise binary multiplication (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxMul_13#

class skl2onnx.algebra.onnx_ops.OnnxMul_13(*args, **kwargs)#

Version

Onnx name: Mul

This version of the operator has been available since version 13.

Summary

Performs element-wise binary multiplication (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

OnnxMul_14#

class skl2onnx.algebra.onnx_ops.OnnxMul_14(*args, **kwargs)#

Version

Onnx name: Mul

This version of the operator has been available since version 14.

Summary

Performs element-wise binary multiplication (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxMul_6#

class skl2onnx.algebra.onnx_ops.OnnxMul_6(*args, **kwargs)#

Version

Onnx name: Mul

This version of the operator has been available since version 6.

Summary

Performs element-wise binary multiplication (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxMul_7#

class skl2onnx.algebra.onnx_ops.OnnxMul_7(*args, **kwargs)#

Version

Onnx name: Mul

This version of the operator has been available since version 7.

Summary

Performs element-wise binary multiplication (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxMultinomial#

class skl2onnx.algebra.onnx_ops.OnnxMultinomial(*args, **kwargs)#

Version

Onnx name: Multinomial

This version of the operator has been available since version 7.

Summary

Generate a tensor of samples from a multinomial distribution according to the probabilities of each of the possible outcomes.

Attributes

  • dtype: (Optional) The data type for the elements of the output tensor, if not specified, we will use int32. Default value is name: "dtype" type: INT i: 6

  • sample_size: Number of times to sample. Default value is name: "sample_size" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor with shape [batch_size, class_size], where class_size is the number of all possible outcomes. Each value along the axis zero represents the unnormalized log-probability of each corresponding outcome in a batch.

Outputs

  • output (heterogeneous)T2: Output tensor with shape [batch_size, sample_size], where sample_size is the number of times to sample. Each value along the axis zero represents the outcome of the corresponding sample in a batch.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain output types to integral tensors.

OnnxMultinomial_7#

class skl2onnx.algebra.onnx_ops.OnnxMultinomial_7(*args, **kwargs)#

Version

Onnx name: Multinomial

This version of the operator has been available since version 7.

Summary

Generate a tensor of samples from a multinomial distribution according to the probabilities of each of the possible outcomes.

Attributes

  • dtype: (Optional) The data type for the elements of the output tensor, if not specified, we will use int32. Default value is name: "dtype" type: INT i: 6

  • sample_size: Number of times to sample. Default value is name: "sample_size" type: INT i: 1

Inputs

  • input (heterogeneous)T1: Input tensor with shape [batch_size, class_size], where class_size is the number of all possible outcomes. Each value along the axis zero represents the unnormalized log-probability of each corresponding outcome in a batch.

Outputs

  • output (heterogeneous)T2: Output tensor with shape [batch_size, sample_size], where sample_size is the number of times to sample. Each value along the axis zero represents the outcome of the corresponding sample in a batch.

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain output types to integral tensors.

OnnxNeg#

class skl2onnx.algebra.onnx_ops.OnnxNeg(*args, **kwargs)#

Version

Onnx name: Neg

This version of the operator has been available since version 13.

Summary

Neg takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where each element flipped sign, y = -x, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float), tensor(int32), tensor(int8), tensor(int16), tensor(int64), tensor(float16), tensor(double), tensor(bfloat16): Constrain input and output types to signed numeric tensors.

OnnxNeg_1#

class skl2onnx.algebra.onnx_ops.OnnxNeg_1(*args, **kwargs)#

Version

Onnx name: Neg

This version of the operator has been available since version 1.

Summary

Neg takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where each element flipped sign, y = -x, is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxNeg_13#

class skl2onnx.algebra.onnx_ops.OnnxNeg_13(*args, **kwargs)#

Version

Onnx name: Neg

This version of the operator has been available since version 13.

Summary

Neg takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where each element flipped sign, y = -x, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float), tensor(int32), tensor(int8), tensor(int16), tensor(int64), tensor(float16), tensor(double), tensor(bfloat16): Constrain input and output types to signed numeric tensors.

OnnxNeg_6#

class skl2onnx.algebra.onnx_ops.OnnxNeg_6(*args, **kwargs)#

Version

Onnx name: Neg

This version of the operator has been available since version 6.

Summary

Neg takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where each element flipped sign, y = -x, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float), tensor(int32), tensor(int8), tensor(int16), tensor(int64), tensor(float16), tensor(double): Constrain input and output types to signed numeric tensors.

OnnxNegativeLogLikelihoodLoss#

class skl2onnx.algebra.onnx_ops.OnnxNegativeLogLikelihoodLoss(*args, **kwargs)#

Version

Onnx name: NegativeLogLikelihoodLoss

This version of the operator has been available since version 13.

Summary

A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. Its “input” tensor has the shape of (N, C, d1, d2, …, dk) where k >= 0. The “input” tensor contains log-probabilities for input[n, :, d_1, d_2,…, d_k] being in a class of [0, C). The operator’s “target” input tensor has the shape of (N, d1, d2, …, dk). It encodes class labels (one of C classes) or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x … x dk samples. The loss value for input[n, :, d_1, d_2,…d_k] being classified as class c = target[n][d_1][d_2]…[d_k] is computed as:

loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k].

When an optional “weight” is provided, the sample loss is calculated as:

loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k] * weight[c].

loss is zero for the case when target-value equals ignore_index.

loss[n][d_1][d_2]...[d_k] = 0, when target[n][d_1][d_2]...[d_k] = ignore_index

If “reduction” attribute is set to “none”, the operator’s output will be the above loss with shape (N, d1, d2, …, dk). If “reduction” attribute is set to “mean” (the default attribute value), the output loss is (weight) averaged:

mean(loss), if "weight" is not provided,

or if weight is provided,

sum(loss) / sum(weight[target[n][d_1][d_2]...[d_k]]]), for all samples.

If “reduction” attribute is set to “sum”, the output is a scalar: sum(loss).

See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss.

Example 1:

// negative log likelihood loss, "none" reduction
N, C, d1 = 2, 3, 2
input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],
          [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]
target = [[2, 1], [0, 2]]

loss = np.zeros((N, d1))
for n in range(N):
    for d_1 in range(d1):
        c = target[n][d_1]
        loss[n][d_1] = -input[n][c][d_1]

// print(loss)
// [[-3. -2.]
//  [-0. -2.]]

Example 2:

// weighted negative log likelihood loss, sum reduction
N, C, d1 = 2, 3, 2
input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],
        [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]
target = [[2, 1], [0, 2]]
weight = [0.2, 0.3, 0.1]
loss = np.zeros((N, d1))
for n in range(N):
    for d_1 in range(d1):
        c = target[n][d_1]
        loss[n][d_1] = -input[n][c][d_1] * weight[c]

loss = np.sum(loss)
// print(loss)
// -1.1

Example 3:

// weighted negative log likelihood loss, mean reduction
N, C, d1 = 2, 3, 2
input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],
        [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]
target = [[2, 1], [0, 2]]
weight = [0.2, 0.3, 0.1]
loss = np.zeros((N, d1))
weight_total = 0
for n in range(N):
    for d_1 in range(d1):
        c = target[n][d_1]
        loss[n][d_1] = -input[n][c][d_1] * weight[c]
        weight_total = weight_total + weight[c]

loss = np.sum(loss) / weight_total
// print(loss)
// -1.57

Attributes

  • reduction: Type of reduction to apply to loss: none, sum, mean (default). ‘none’: the output is the loss for each sample. ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the sum of applied weights. Default value is name: "reduction" type: STRING s: "mean"

Inputs

Between 2 and 3 inputs.

  • input (heterogeneous)T: Input tensor of shape (N, C) or (N, C, d1, d2, …, dk).

  • target (heterogeneous)Tind: Target tensor of shape (N) or (N, d1, d2, …, dk). Target element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the target values should either be in the range [0, C) or have the value ignore_index.

  • weight (optional, heterogeneous)T: Optional rescaling weight tensor. If given, it has to be a tensor of size C. Otherwise, it is treated as if having all ones.

Outputs

  • loss (heterogeneous)T: The negative log likelihood loss

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input, weight, and output types to floating-point tensors.

  • Tind tensor(int32), tensor(int64): Constrain target to integer types

OnnxNegativeLogLikelihoodLoss_12#

class skl2onnx.algebra.onnx_ops.OnnxNegativeLogLikelihoodLoss_12(*args, **kwargs)#

Version

Onnx name: NegativeLogLikelihoodLoss

This version of the operator has been available since version 12.

Summary

A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. Its “input” tensor has the shape of (N, C, d1, d2, …, dk) where k >= 0. The “input” tensor contains log-probabilities for input[n, :, d_1, d_2,…, d_k] being in a class of [0, C). The operator’s “target” input tensor has the shape of (N, d1, d2, …, dk). It encodes class labels (one of C classes) or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x … x dk samples. The loss value for input[n, :, d_1, d_2,…d_k] being classified as class c = target[n][d_1][d_2]…[d_k] is computed as:

loss[n][d_1][d_2]…[d_k] = -input[n][c][d_1][d_2]…[d_k].

When an optional “weight” is provided, the sample loss is calculated as:

loss[n][d_1][d_2]…[d_k] = -input[n][c][d_1][d_2]…[d_k] * weight[c].

loss is zero for the case when target-value equals ignore_index.

loss[n][d_1][d_2]…[d_k] = 0, when target[n][d_1][d_2]…[d_k] = ignore_index

If “reduction” attribute is set to “none”, the operator’s output will be the above loss with shape (N, d1, d2, …, dk). If “reduction” attribute is set to “mean” (the default attribute value), the output loss is (weight) averaged:

mean(loss), if “weight” is not provided,

or if weight is provided,

sum(loss) / sum(weight[target[n][d_1][d_2]…[d_k]]]), for all samples.

If “reduction” attribute is set to “sum”, the output is a scalar:

sum(loss).

See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss. Example 1:

// negative log likelihood loss, “none” reduction N, C, d1 = 2, 3, 2 input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],

[[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]

target = [[2, 1], [0, 2]] loss = np.zeros((N, d1)) for n in range(N):

for d_1 in range(d1):

c = target[n][d_1] loss[n][d_1] = -input[n][c][d_1]

// print(loss) // [[-3. -2.] // [-0. -2.]]

Example 2:

// weighted negative log likelihood loss, sum reduction N, C, d1 = 2, 3, 2 input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],

[[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]

target = [[2, 1], [0, 2]] weight = [0.2, 0.3, 0.1] loss = np.zeros((N, d1)) for n in range(N):

for d_1 in range(d1):

c = target[n][d_1] loss[n][d_1] = -input[n][c][d_1] * weight[c]

loss = np.sum(loss) // print(loss) // -1.1

Example 3:

// weighted negative log likelihood loss, mean reduction N, C, d1 = 2, 3, 2 input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],

[[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]

target = [[2, 1], [0, 2]] weight = [0.2, 0.3, 0.1] loss = np.zeros((N, d1)) weight_total = 0 for n in range(N):

for d_1 in range(d1):

c = target[n][d_1] loss[n][d_1] = -input[n][c][d_1] * weight[c] weight_total = weight_total + weight[c]

loss = np.sum(loss) / weight_total // print(loss) // -1.57

Attributes

  • reduction: Type of reduction to apply to loss: none, sum, mean (default). ‘none’: the output is the loss for each sample. ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the sum of applied weights. Default value is name: "reduction" type: STRING s: "mean"

Inputs

Between 2 and 3 inputs.

  • input (heterogeneous)T: Input tensor of shape (N, C) or (N, C, d1, d2, …, dk).

  • target (heterogeneous)Tind: Target tensor of shape (N) or (N, d1, d2, …, dk). Target element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the target values should either be in the range [0, C) or have the value ignore_index.

  • weight (optional, heterogeneous)T: Optional rescaling weight tensor. If given, it has to be a tensor of size C. Otherwise, it is treated as if having all ones.

Outputs

  • loss (heterogeneous)T: The negative log likelihood loss

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input, weight, and output types to floating-point tensors.

  • Tind tensor(int32), tensor(int64): Constrain target to integer types

OnnxNegativeLogLikelihoodLoss_13#

class skl2onnx.algebra.onnx_ops.OnnxNegativeLogLikelihoodLoss_13(*args, **kwargs)#

Version

Onnx name: NegativeLogLikelihoodLoss

This version of the operator has been available since version 13.

Summary

A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. Its “input” tensor has the shape of (N, C, d1, d2, …, dk) where k >= 0. The “input” tensor contains log-probabilities for input[n, :, d_1, d_2,…, d_k] being in a class of [0, C). The operator’s “target” input tensor has the shape of (N, d1, d2, …, dk). It encodes class labels (one of C classes) or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x … x dk samples. The loss value for input[n, :, d_1, d_2,…d_k] being classified as class c = target[n][d_1][d_2]…[d_k] is computed as:

loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k].

When an optional “weight” is provided, the sample loss is calculated as:

loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k] * weight[c].

loss is zero for the case when target-value equals ignore_index.

loss[n][d_1][d_2]...[d_k] = 0, when target[n][d_1][d_2]...[d_k] = ignore_index

If “reduction” attribute is set to “none”, the operator’s output will be the above loss with shape (N, d1, d2, …, dk). If “reduction” attribute is set to “mean” (the default attribute value), the output loss is (weight) averaged:

mean(loss), if "weight" is not provided,

or if weight is provided,

sum(loss) / sum(weight[target[n][d_1][d_2]...[d_k]]]), for all samples.

If “reduction” attribute is set to “sum”, the output is a scalar: sum(loss).

See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss.

Example 1:

// negative log likelihood loss, "none" reduction
N, C, d1 = 2, 3, 2
input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],
          [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]
target = [[2, 1], [0, 2]]

loss = np.zeros((N, d1))
for n in range(N):
    for d_1 in range(d1):
        c = target[n][d_1]
        loss[n][d_1] = -input[n][c][d_1]

// print(loss)
// [[-3. -2.]
//  [-0. -2.]]

Example 2:

// weighted negative log likelihood loss, sum reduction
N, C, d1 = 2, 3, 2
input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],
        [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]
target = [[2, 1], [0, 2]]
weight = [0.2, 0.3, 0.1]
loss = np.zeros((N, d1))
for n in range(N):
    for d_1 in range(d1):
        c = target[n][d_1]
        loss[n][d_1] = -input[n][c][d_1] * weight[c]

loss = np.sum(loss)
// print(loss)
// -1.1

Example 3:

// weighted negative log likelihood loss, mean reduction
N, C, d1 = 2, 3, 2
input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]],
        [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]]
target = [[2, 1], [0, 2]]
weight = [0.2, 0.3, 0.1]
loss = np.zeros((N, d1))
weight_total = 0
for n in range(N):
    for d_1 in range(d1):
        c = target[n][d_1]
        loss[n][d_1] = -input[n][c][d_1] * weight[c]
        weight_total = weight_total + weight[c]

loss = np.sum(loss) / weight_total
// print(loss)
// -1.57

Attributes

  • reduction: Type of reduction to apply to loss: none, sum, mean (default). ‘none’: the output is the loss for each sample. ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the sum of applied weights. Default value is name: "reduction" type: STRING s: "mean"

Inputs

Between 2 and 3 inputs.

  • input (heterogeneous)T: Input tensor of shape (N, C) or (N, C, d1, d2, …, dk).

  • target (heterogeneous)Tind: Target tensor of shape (N) or (N, d1, d2, …, dk). Target element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the target values should either be in the range [0, C) or have the value ignore_index.

  • weight (optional, heterogeneous)T: Optional rescaling weight tensor. If given, it has to be a tensor of size C. Otherwise, it is treated as if having all ones.

Outputs

  • loss (heterogeneous)T: The negative log likelihood loss

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input, weight, and output types to floating-point tensors.

  • Tind tensor(int32), tensor(int64): Constrain target to integer types

OnnxNonMaxSuppression#

class skl2onnx.algebra.onnx_ops.OnnxNonMaxSuppression(*args, **kwargs)#

Version

Onnx name: NonMaxSuppression

This version of the operator has been available since version 11.

Summary

Filter out boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than score_threshold are removed. Bounding box format is indicated by attribute center_point_box. Note that this algorithm is agnostic to where the origin is in the coordinate system and more generally is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The selected_indices output is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the Gather or GatherND operation.

Attributes

  • center_point_box: Integer indicate the format of the box data. The default is 0. 0 - the box data is supplied as [y1, x1, y2, x2] where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Mostly used for TF models. 1 - the box data is supplied as [x_center, y_center, width, height]. Mostly used for Pytorch models. Default value is name: "center_point_box" type: INT i: 0

Inputs

Between 2 and 5 inputs.

  • boxes (heterogeneous)tensor(float): An input tensor with shape [num_batches, spatial_dimension, 4]. The single box data format is indicated by center_point_box.

  • scores (heterogeneous)tensor(float): An input tensor with shape [num_batches, num_classes, spatial_dimension]

  • max_output_boxes_per_class (optional, heterogeneous)tensor(int64): Integer representing the maximum number of boxes to be selected per batch per class. It is a scalar. Default to 0, which means no output.

  • iou_threshold (optional, heterogeneous)tensor(float): Float representing the threshold for deciding whether boxes overlap too much with respect to IOU. It is scalar. Value range [0, 1]. Default to 0.

  • score_threshold (optional, heterogeneous)tensor(float): Float representing the threshold for deciding when to remove boxes based on score. It is a scalar.

Outputs

  • selected_indices (heterogeneous)tensor(int64): selected indices from the boxes tensor. [num_selected_indices, 3], the selected index format is [batch_index, class_index, box_index].

OnnxNonMaxSuppression_10#

class skl2onnx.algebra.onnx_ops.OnnxNonMaxSuppression_10(*args, **kwargs)#

Version

Onnx name: NonMaxSuppression

This version of the operator has been available since version 10.

Summary

Filter out boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than score_threshold are removed. Bounding box format is indicated by attribute center_point_box. Note that this algorithm is agnostic to where the origin is in the coordinate system and more generally is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The selected_indices output is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the Gather or GatherND operation.

Attributes

  • center_point_box: Integer indicate the format of the box data. The default is 0. 0 - the box data is supplied as [y1, x1, y2, x2] where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Mostly used for TF models. 1 - the box data is supplied as [x_center, y_center, width, height]. Mostly used for Pytorch models. Default value is name: "center_point_box" type: INT i: 0

Inputs

Between 2 and 5 inputs.

  • boxes (heterogeneous)tensor(float): An input tensor with shape [num_batches, spatial_dimension, 4]. The single box data format is indicated by center_point_box.

  • scores (heterogeneous)tensor(float): An input tensor with shape [num_batches, num_classes, spatial_dimension]

  • max_output_boxes_per_class (optional, heterogeneous)tensor(int64): Integer representing the maximum number of boxes to be selected per batch per class. It is a scalar. Default to 0, which means no output.

  • iou_threshold (optional, heterogeneous)tensor(float): Float representing the threshold for deciding whether boxes overlap too much with respect to IOU. It is scalar. Value range [0, 1]. Default to 0.

  • score_threshold (optional, heterogeneous)tensor(float): Float representing the threshold for deciding when to remove boxes based on score. It is a scalar.

Outputs

  • selected_indices (heterogeneous)tensor(int64): selected indices from the boxes tensor. [num_selected_indices, 3], the selected index format is [batch_index, class_index, box_index].

OnnxNonMaxSuppression_11#

class skl2onnx.algebra.onnx_ops.OnnxNonMaxSuppression_11(*args, **kwargs)#

Version

Onnx name: NonMaxSuppression

This version of the operator has been available since version 11.

Summary

Filter out boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than score_threshold are removed. Bounding box format is indicated by attribute center_point_box. Note that this algorithm is agnostic to where the origin is in the coordinate system and more generally is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The selected_indices output is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the Gather or GatherND operation.

Attributes

  • center_point_box: Integer indicate the format of the box data. The default is 0. 0 - the box data is supplied as [y1, x1, y2, x2] where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Mostly used for TF models. 1 - the box data is supplied as [x_center, y_center, width, height]. Mostly used for Pytorch models. Default value is name: "center_point_box" type: INT i: 0

Inputs

Between 2 and 5 inputs.

  • boxes (heterogeneous)tensor(float): An input tensor with shape [num_batches, spatial_dimension, 4]. The single box data format is indicated by center_point_box.

  • scores (heterogeneous)tensor(float): An input tensor with shape [num_batches, num_classes, spatial_dimension]

  • max_output_boxes_per_class (optional, heterogeneous)tensor(int64): Integer representing the maximum number of boxes to be selected per batch per class. It is a scalar. Default to 0, which means no output.

  • iou_threshold (optional, heterogeneous)tensor(float): Float representing the threshold for deciding whether boxes overlap too much with respect to IOU. It is scalar. Value range [0, 1]. Default to 0.

  • score_threshold (optional, heterogeneous)tensor(float): Float representing the threshold for deciding when to remove boxes based on score. It is a scalar.

Outputs

  • selected_indices (heterogeneous)tensor(int64): selected indices from the boxes tensor. [num_selected_indices, 3], the selected index format is [batch_index, class_index, box_index].

OnnxNonZero#

class skl2onnx.algebra.onnx_ops.OnnxNonZero(*args, **kwargs)#

Version

Onnx name: NonZero

This version of the operator has been available since version 13.

Summary

Returns the indices of the elements that are non-zero (in row-major order - by dimension). NonZero behaves similar to numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html, but for scalar input, NonZero produces output shape (0, N) instead of (1, N), which is different from Numpy’s behavior.

Inputs

  • X (heterogeneous)T: input

Outputs

  • Y (heterogeneous)tensor(int64): output

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to all tensor types.

OnnxNonZero_13#

class skl2onnx.algebra.onnx_ops.OnnxNonZero_13(*args, **kwargs)#

Version

Onnx name: NonZero

This version of the operator has been available since version 13.

Summary

Returns the indices of the elements that are non-zero (in row-major order - by dimension). NonZero behaves similar to numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html, but for scalar input, NonZero produces output shape (0, N) instead of (1, N), which is different from Numpy’s behavior.

Inputs

  • X (heterogeneous)T: input

Outputs

  • Y (heterogeneous)tensor(int64): output

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to all tensor types.

OnnxNonZero_9#

class skl2onnx.algebra.onnx_ops.OnnxNonZero_9(*args, **kwargs)#

Version

Onnx name: NonZero

This version of the operator has been available since version 9.

Summary

Returns the indices of the elements that are non-zero (in row-major order - by dimension). NonZero behaves similar to numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html, but for scalar input, NonZero produces output shape (0, N) instead of (1, N), which is different from Numpy’s behavior.

Inputs

  • X (heterogeneous)T: input

Outputs

  • Y (heterogeneous)tensor(int64): output

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to all tensor types.

OnnxNormalizer#

class skl2onnx.algebra.onnx_ops.OnnxNormalizer(*args, **kwargs)#

Version

Onnx name: Normalizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Normalize the input. There are three normalization modes, which have the corresponding formulas, defined using element-wise infix operators ‘/’ and ‘^’ and tensor-wide functions ‘max’ and ‘sum’:

Max: Y = X / max(X)

L1: Y = X / sum(X)

L2: Y = sqrt(X^2 / sum(X^2)}

In all modes, if the divisor is zero, Y == X.

For batches, that is, [N,C] tensors, normalization is done along the C axis. In other words, each row of the batch is normalized independently.

Attributes

  • norm: One of ‘MAX,’ ‘L1,’ ‘L2’ Default value is name: "norm" type: STRING s: "MAX"

Inputs

  • X (heterogeneous)T: Data to be encoded, a tensor of shape [N,C] or [C]

Outputs

  • Y (heterogeneous)tensor(float): Encoded output data

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type.

OnnxNormalizer_1#

class skl2onnx.algebra.onnx_ops.OnnxNormalizer_1(*args, **kwargs)#

Version

Onnx name: Normalizer

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Normalize the input. There are three normalization modes, which have the corresponding formulas, defined using element-wise infix operators ‘/’ and ‘^’ and tensor-wide functions ‘max’ and ‘sum’:

Max: Y = X / max(X)

L1: Y = X / sum(X)

L2: Y = sqrt(X^2 / sum(X^2)}

In all modes, if the divisor is zero, Y == X.

For batches, that is, [N,C] tensors, normalization is done along the C axis. In other words, each row of the batch is normalized independently.

Attributes

  • norm: One of ‘MAX,’ ‘L1,’ ‘L2’ Default value is name: "norm" type: STRING s: "MAX"

Inputs

  • X (heterogeneous)T: Data to be encoded, a tensor of shape [N,C] or [C]

Outputs

  • Y (heterogeneous)tensor(float): Encoded output data

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type.

OnnxNot#

class skl2onnx.algebra.onnx_ops.OnnxNot(*args, **kwargs)#

Version

Onnx name: Not

This version of the operator has been available since version 1.

Summary

Returns the negation of the input tensor element-wise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(bool): Constrain input/output to boolean tensors.

OnnxNot_1#

class skl2onnx.algebra.onnx_ops.OnnxNot_1(*args, **kwargs)#

Version

Onnx name: Not

This version of the operator has been available since version 1.

Summary

Returns the negation of the input tensor element-wise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(bool): Constrain input/output to boolean tensors.

OnnxOneHot#

class skl2onnx.algebra.onnx_ops.OnnxOneHot(*args, **kwargs)#

Version

Onnx name: OneHot

This version of the operator has been available since version 11.

Summary

Produces a one-hot tensor based on inputs. The locations represented by the index values in the ‘indices’ input tensor will have ‘on_value’ and the other locations will have ‘off_value’ in the output tensor, where ‘on_value’ and ‘off_value’ are specified as part of required input argument ‘values’, which is a two-element tensor of format [off_value, on_value]. The rank of the output tensor will be one greater than the rank of the input tensor. The additional dimension is for one-hot representation. The additional dimension will be inserted at the position specified by ‘axis’. If ‘axis’ is not specified then then additional dimension will be inserted as the innermost dimension, i.e. axis=-1. The size of the additional dimension is specified by required scalar input ‘depth’. The type of the output tensor is the same as the type of the ‘values’ input. Any entries in the ‘indices’ input tensor with values outside the range [-depth, depth-1] will result in one-hot representation with all ‘off_value’ values in the output tensor.

when axis = 0: output[input[i, j, k], i, j, k] = 1 for all i, j, k and 0 otherwise.

when axis = -1: output[i, j, k, input[i, j, k]] = 1 for all i, j, k and 0 otherwise.

Attributes

  • axis: (Optional) Axis along which one-hot representation in added. Default: axis=-1. axis=-1 means that the additional dimension will be inserted as the innermost/last dimension in the output tensor. Negative value means counting dimensions from the back. Accepted range is [-r-1, r] where r = rank(indices). Default value is name: "axis" type: INT i: -1

Inputs

  • indices (heterogeneous)T1: Input tensor containing indices. Any entries in the ‘indices’ input tensor with values outside the range [-depth, depth-1] will result in one-hot representation with all ‘off_value’ values in the output tensor.In case ‘indices’ is of non-integer type, the values will be casted to int64 before use.

  • depth (heterogeneous)T2: Scalar or Rank 1 tensor containing exactly one element, specifying the number of classes in one-hot tensor. This is also the size of the one-hot dimension (specified by ‘axis’ attribute) added on in the output tensor. The values in the ‘indices’ input tensor are expected to be in the range [-depth, depth-1]. In case ‘depth’ is of non-integer type, it will be casted to int64 before use.

  • values (heterogeneous)T3: Rank 1 tensor containing exactly two elements, in the format [off_value, on_value], where ‘on_value’ is the value used for filling locations specified in ‘indices’ input tensor, and ‘off_value’ is the value used for filling locations other than those specified in ‘indices’ input tensor.

Outputs

  • output (heterogeneous)T3: Tensor of rank one greater than input tensor ‘indices’, i.e. rank(output) = rank(indices) + 1. The data type for the elements of the output tensor is the same as the type of input ‘values’ is used.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

  • T3 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

OnnxOneHotEncoder#

class skl2onnx.algebra.onnx_ops.OnnxOneHotEncoder(*args, **kwargs)#

Version

Onnx name: OneHotEncoder

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Replace each input element with an array of ones and zeros, where a single one is placed at the index of the category that was passed in. The total category count will determine the size of the extra dimension of the output array Y.

For example, if we pass a tensor with a single value of 4, and a category count of 8, the output will be a tensor with [0,0,0,0,1,0,0,0].

This operator assumes every input feature is from the same set of categories.

If the input is a tensor of float, int32, or double, the data will be cast to integers and the cats_int64s category list will be used for the lookups.

Attributes

  • zeros: If true and category is not present, will return all zeros; if false and a category if not found, the operator will fail. Default value is name: "zeros" type: INT i: 1

Inputs

  • X (heterogeneous)T: Data to be encoded.

Outputs

  • Y (heterogeneous)tensor(float): Encoded output data, having one more dimension than X.

Type Constraints

  • T tensor(string), tensor(int64), tensor(int32), tensor(float), tensor(double): The input must be a tensor of a numeric type.

OnnxOneHotEncoder_1#

class skl2onnx.algebra.onnx_ops.OnnxOneHotEncoder_1(*args, **kwargs)#

Version

Onnx name: OneHotEncoder

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Replace each input element with an array of ones and zeros, where a single one is placed at the index of the category that was passed in. The total category count will determine the size of the extra dimension of the output array Y.

For example, if we pass a tensor with a single value of 4, and a category count of 8, the output will be a tensor with [0,0,0,0,1,0,0,0].

This operator assumes every input feature is from the same set of categories.

If the input is a tensor of float, int32, or double, the data will be cast to integers and the cats_int64s category list will be used for the lookups.

Attributes

  • zeros: If true and category is not present, will return all zeros; if false and a category if not found, the operator will fail. Default value is name: "zeros" type: INT i: 1

Inputs

  • X (heterogeneous)T: Data to be encoded.

Outputs

  • Y (heterogeneous)tensor(float): Encoded output data, having one more dimension than X.

Type Constraints

  • T tensor(string), tensor(int64), tensor(int32), tensor(float), tensor(double): The input must be a tensor of a numeric type.

OnnxOneHot_11#

class skl2onnx.algebra.onnx_ops.OnnxOneHot_11(*args, **kwargs)#

Version

Onnx name: OneHot

This version of the operator has been available since version 11.

Summary

Produces a one-hot tensor based on inputs. The locations represented by the index values in the ‘indices’ input tensor will have ‘on_value’ and the other locations will have ‘off_value’ in the output tensor, where ‘on_value’ and ‘off_value’ are specified as part of required input argument ‘values’, which is a two-element tensor of format [off_value, on_value]. The rank of the output tensor will be one greater than the rank of the input tensor. The additional dimension is for one-hot representation. The additional dimension will be inserted at the position specified by ‘axis’. If ‘axis’ is not specified then then additional dimension will be inserted as the innermost dimension, i.e. axis=-1. The size of the additional dimension is specified by required scalar input ‘depth’. The type of the output tensor is the same as the type of the ‘values’ input. Any entries in the ‘indices’ input tensor with values outside the range [-depth, depth-1] will result in one-hot representation with all ‘off_value’ values in the output tensor.

when axis = 0: output[input[i, j, k], i, j, k] = 1 for all i, j, k and 0 otherwise.

when axis = -1: output[i, j, k, input[i, j, k]] = 1 for all i, j, k and 0 otherwise.

Attributes

  • axis: (Optional) Axis along which one-hot representation in added. Default: axis=-1. axis=-1 means that the additional dimension will be inserted as the innermost/last dimension in the output tensor. Negative value means counting dimensions from the back. Accepted range is [-r-1, r] where r = rank(indices). Default value is name: "axis" type: INT i: -1

Inputs

  • indices (heterogeneous)T1: Input tensor containing indices. Any entries in the ‘indices’ input tensor with values outside the range [-depth, depth-1] will result in one-hot representation with all ‘off_value’ values in the output tensor.In case ‘indices’ is of non-integer type, the values will be casted to int64 before use.

  • depth (heterogeneous)T2: Scalar or Rank 1 tensor containing exactly one element, specifying the number of classes in one-hot tensor. This is also the size of the one-hot dimension (specified by ‘axis’ attribute) added on in the output tensor. The values in the ‘indices’ input tensor are expected to be in the range [-depth, depth-1]. In case ‘depth’ is of non-integer type, it will be casted to int64 before use.

  • values (heterogeneous)T3: Rank 1 tensor containing exactly two elements, in the format [off_value, on_value], where ‘on_value’ is the value used for filling locations specified in ‘indices’ input tensor, and ‘off_value’ is the value used for filling locations other than those specified in ‘indices’ input tensor.

Outputs

  • output (heterogeneous)T3: Tensor of rank one greater than input tensor ‘indices’, i.e. rank(output) = rank(indices) + 1. The data type for the elements of the output tensor is the same as the type of input ‘values’ is used.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

  • T3 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

OnnxOneHot_9#

class skl2onnx.algebra.onnx_ops.OnnxOneHot_9(*args, **kwargs)#

Version

Onnx name: OneHot

This version of the operator has been available since version 9.

Summary

Produces a one-hot tensor based on inputs. The locations represented by the index values in the ‘indices’ input tensor will have ‘on_value’ and the other locations will have ‘off_value’ in the output tensor, where ‘on_value’ and ‘off_value’ are specified as part of required input argument ‘values’, which is a two-element tensor of format [off_value, on_value]. The rank of the output tensor will be one greater than the rank of the input tensor. The additional dimension is for one-hot representation. The additional dimension will be inserted at the position specified by ‘axis’. If ‘axis’ is not specified then then additional dimension will be inserted as the innermost dimension, i.e. axis=-1. The size of the additional dimension is specified by required scalar input ‘depth’. The type of the output tensor is the same as the type of the ‘values’ input. Any entries in the ‘indices’ input tensor with values outside the range [0, depth) will result in one-hot representation with all ‘off_value’ values in the output tensor.

Attributes

  • axis: (Optional) Axis along which one-hot representation in added. Default: axis=-1. axis=-1 means that the additional dimension will be inserted as the innermost/last dimension in the output tensor. Default value is name: "axis" type: INT i: -1

Inputs

  • indices (heterogeneous)T1: Input tensor containing indices. The values must be non-negative integers. Any entries in the ‘indices’ input tensor with values outside the range [0, depth) will result in one-hot representation with all ‘off_value’ values in the output tensor.In case ‘indices’ is of non-integer type, the values will be casted to int64 before use.

  • depth (heterogeneous)T2: Scalar or rank 1 tensor containing exactly one element, specifying the number of classes in one-hot tensor. This is also the size of the one-hot dimension (specified by ‘axis’ attribute) added on in the output tensor. The values in the ‘indices’ input tensor are expected to be in the range [0, depth). In case ‘depth’ is of non-integer type, it will be casted to int64 before use.

  • values (heterogeneous)T3: Rank 1 tensor containing exactly two elements, in the format [off_value, on_value], where ‘on_value’ is the value used for filling locations specified in ‘indices’ input tensor, and ‘off_value’ is the value used for filling locations other than those specified in ‘indices’ input tensor.

Outputs

  • output (heterogeneous)T3: Tensor of rank one greater than input tensor ‘indices’, i.e. rank(output) = rank(indices) + 1. The data type for the elements of the output tensor is the same as the type of input ‘values’ is used.

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

  • T2 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

  • T3 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

OnnxOptional#

class skl2onnx.algebra.onnx_ops.OnnxOptional(*args, **kwargs)#

Version

Onnx name: Optional

This version of the operator has been available since version 15.

Summary

Constructs an optional-type value containing either an empty optional of a certain type specified by the attribute, or a non-empty value containing the input element.

Attributes

Inputs

Between 0 and 1 inputs.

  • input (optional, heterogeneous)V: The input element.

Outputs

  • output (heterogeneous)O: The optional output enclosing the input element.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input type to all tensor and sequence types.

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain output type to all optional tensor or optional sequence types.

OnnxOptionalGetElement#

class skl2onnx.algebra.onnx_ops.OnnxOptionalGetElement(*args, **kwargs)#

Version

Onnx name: OptionalGetElement

This version of the operator has been available since version 18.

Summary

If the input is a tensor or sequence type, it returns the input. If the input is an optional type, it outputs the element in the input. It is an error if the input is an empty optional-type (i.e. does not have an element) and the behavior is undefined in this case.

Inputs

  • input (heterogeneous)O: The optional input.

Outputs

  • output (heterogeneous)V: Output element in the optional input.

Type Constraints

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input type to optional tensor and optional sequence types.

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output type to all tensor or sequence types.

OnnxOptionalGetElement_15#

class skl2onnx.algebra.onnx_ops.OnnxOptionalGetElement_15(*args, **kwargs)#

Version

Onnx name: OptionalGetElement

This version of the operator has been available since version 15.

Summary

Outputs the element in the optional-type input. It is an error if the input value does not have an element and the behavior is undefined in this case.

Inputs

  • input (heterogeneous)O: The optional input.

Outputs

  • output (heterogeneous)V: Output element in the optional input.

Type Constraints

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain input type to optional tensor and optional sequence types.

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output type to all tensor or sequence types.

OnnxOptionalGetElement_18#

class skl2onnx.algebra.onnx_ops.OnnxOptionalGetElement_18(*args, **kwargs)#

Version

Onnx name: OptionalGetElement

This version of the operator has been available since version 18.

Summary

If the input is a tensor or sequence type, it returns the input. If the input is an optional type, it outputs the element in the input. It is an error if the input is an empty optional-type (i.e. does not have an element) and the behavior is undefined in this case.

Inputs

  • input (heterogeneous)O: The optional input.

Outputs

  • output (heterogeneous)V: Output element in the optional input.

Type Constraints

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input type to optional tensor and optional sequence types.

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output type to all tensor or sequence types.

OnnxOptionalHasElement#

class skl2onnx.algebra.onnx_ops.OnnxOptionalHasElement(*args, **kwargs)#

Version

Onnx name: OptionalHasElement

This version of the operator has been available since version 18.

Summary

Returns true if (1) the input is an optional-type and contains an element, or, (2) the input is a tensor or sequence type. If the input is not provided or is an empty optional-type, this op returns false.

Inputs

Between 0 and 1 inputs.

  • input (optional, heterogeneous)O: The optional input.

Outputs

  • output (heterogeneous)B: A scalar boolean tensor. If true, it indicates that optional-type input contains an element. Otherwise, it is empty.

Type Constraints

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input type to optional tensor and optional sequence types.

  • B tensor(bool): Constrain output to a boolean tensor.

OnnxOptionalHasElement_15#

class skl2onnx.algebra.onnx_ops.OnnxOptionalHasElement_15(*args, **kwargs)#

Version

Onnx name: OptionalHasElement

This version of the operator has been available since version 15.

Summary

Returns true if the optional-type input contains an element. If it is an empty optional-type, this op returns false.

Inputs

  • input (heterogeneous)O: The optional input.

Outputs

  • output (heterogeneous)B: A scalar boolean tensor. If true, it indicates that optional-type input contains an element. Otherwise, it is empty.

Type Constraints

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain input type to optional tensor and optional sequence types.

  • B tensor(bool): Constrain output to a boolean tensor.

OnnxOptionalHasElement_18#

class skl2onnx.algebra.onnx_ops.OnnxOptionalHasElement_18(*args, **kwargs)#

Version

Onnx name: OptionalHasElement

This version of the operator has been available since version 18.

Summary

Returns true if (1) the input is an optional-type and contains an element, or, (2) the input is a tensor or sequence type. If the input is not provided or is an empty optional-type, this op returns false.

Inputs

Between 0 and 1 inputs.

  • input (optional, heterogeneous)O: The optional input.

Outputs

  • output (heterogeneous)B: A scalar boolean tensor. If true, it indicates that optional-type input contains an element. Otherwise, it is empty.

Type Constraints

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input type to optional tensor and optional sequence types.

  • B tensor(bool): Constrain output to a boolean tensor.

OnnxOptional_15#

class skl2onnx.algebra.onnx_ops.OnnxOptional_15(*args, **kwargs)#

Version

Onnx name: Optional

This version of the operator has been available since version 15.

Summary

Constructs an optional-type value containing either an empty optional of a certain type specified by the attribute, or a non-empty value containing the input element.

Attributes

Inputs

Between 0 and 1 inputs.

  • input (optional, heterogeneous)V: The input element.

Outputs

  • output (heterogeneous)O: The optional output enclosing the input element.

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input type to all tensor and sequence types.

  • O optional(seq(tensor(uint8))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(int8))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(float16))), optional(seq(tensor(float))), optional(seq(tensor(double))), optional(seq(tensor(string))), optional(seq(tensor(bool))), optional(seq(tensor(complex64))), optional(seq(tensor(complex128))), optional(tensor(uint8)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(int8)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(float16)), optional(tensor(float)), optional(tensor(double)), optional(tensor(string)), optional(tensor(bool)), optional(tensor(complex64)), optional(tensor(complex128)): Constrain output type to all optional tensor or optional sequence types.

OnnxOr#

class skl2onnx.algebra.onnx_ops.OnnxOr(*args, **kwargs)#

Version

Onnx name: Or

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the or logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxOr_1#

class skl2onnx.algebra.onnx_ops.OnnxOr_1(*args, **kwargs)#

Version

Onnx name: Or

This version of the operator has been available since version 1.

Summary

Returns the tensor resulted from performing the or logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Attributes

  • broadcast: Enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: Left input tensor for the logical operator.

  • B (heterogeneous)T: Right input tensor for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxOr_7#

class skl2onnx.algebra.onnx_ops.OnnxOr_7(*args, **kwargs)#

Version

Onnx name: Or

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the or logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxPRelu#

class skl2onnx.algebra.onnx_ops.OnnxPRelu(*args, **kwargs)#

Version

Onnx name: PRelu

This version of the operator has been available since version 16.

Summary

PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one output data (Tensor<T>) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise. This operator supports unidirectional broadcasting (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: Input tensor

  • slope (heterogeneous)T: Slope tensor. The shape of slope can be smaller than first input X; if so, its shape must be unidirectional broadcastable to X

Outputs

  • Y (heterogeneous)T: Output tensor (same size as X)

Type Constraints

  • T tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64): Constrain input and output types to float/int tensors.

OnnxPRelu_1#

class skl2onnx.algebra.onnx_ops.OnnxPRelu_1(*args, **kwargs)#

Version

Onnx name: PRelu

This version of the operator has been available since version 1.

Summary

PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one output data (Tensor<T>) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

  • slope (heterogeneous)T: Slope tensor. If Slope is of size 1, the value is sharedacross different channels

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxPRelu_16#

class skl2onnx.algebra.onnx_ops.OnnxPRelu_16(*args, **kwargs)#

Version

Onnx name: PRelu

This version of the operator has been available since version 16.

Summary

PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one output data (Tensor<T>) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise. This operator supports unidirectional broadcasting (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: Input tensor

  • slope (heterogeneous)T: Slope tensor. The shape of slope can be smaller than first input X; if so, its shape must be unidirectional broadcastable to X

Outputs

  • Y (heterogeneous)T: Output tensor (same size as X)

Type Constraints

  • T tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64): Constrain input and output types to float/int tensors.

OnnxPRelu_6#

class skl2onnx.algebra.onnx_ops.OnnxPRelu_6(*args, **kwargs)#

Version

Onnx name: PRelu

This version of the operator has been available since version 6.

Summary

PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one output data (Tensor<T>) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

  • slope (heterogeneous)T: Slope tensor. If Slope is of size 1, the value is sharedacross different channels

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxPRelu_7#

class skl2onnx.algebra.onnx_ops.OnnxPRelu_7(*args, **kwargs)#

Version

Onnx name: PRelu

This version of the operator has been available since version 7.

Summary

PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one output data (Tensor<T>) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise. This operator supports unidirectional broadcasting (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: Input tensor

  • slope (heterogeneous)T: Slope tensor. The shape of slope can be smaller than first input X; if so, its shape must be unidirectional broadcastable to X

Outputs

  • Y (heterogeneous)T: Output tensor (same size as X)

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxPRelu_9#

class skl2onnx.algebra.onnx_ops.OnnxPRelu_9(*args, **kwargs)#

Version

Onnx name: PRelu

This version of the operator has been available since version 9.

Summary

PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one output data (Tensor<T>) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise. This operator supports unidirectional broadcasting (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: Input tensor

  • slope (heterogeneous)T: Slope tensor. The shape of slope can be smaller than first input X; if so, its shape must be unidirectional broadcastable to X

Outputs

  • Y (heterogeneous)T: Output tensor (same size as X)

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64): Constrain input and output types to float/int tensors.

OnnxPad#

class skl2onnx.algebra.onnx_ops.OnnxPad(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 21.

Summary

Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value, a padded tensor (output) is generated.

The three supported modes are (similar to corresponding modes supported by numpy.pad):

  1. constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0, empty string, or False)

  2. reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

  3. edge - pads with the edge values of array

  4. wrap - wrap-around padding as if the data tensor forms a torus

Example 1 (constant mode):

Insert 0 pads to the beginning of the second dimension.

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'constant'

constant_value = 0.0

output = [
    [0.0, 0.0, 1.0, 1.2],
    [0.0, 0.0, 2.3, 3.4],
    [0.0, 0.0, 4.5, 5.7],
]

Example 2 (reflect mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'reflect'

output = [
    [1.0, 1.2, 1.0, 1.2],
    [2.3, 3.4, 2.3, 3.4],
    [4.5, 5.7, 4.5, 5.7],
]

Example 3 (edge mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'edge'

output = [
    [1.0, 1.0, 1.0, 1.2],
    [2.3, 2.3, 2.3, 3.4],
    [4.5, 4.5, 4.5, 5.7],
]

Example 4 (wrap mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [2, 1, 1, 1]

mode = 'wrap'

output = [
    [3.4, 2.3, 3.4, 2.3],
    [5.7, 4.5, 5.7, 4.5],
    [1.2, 1.0, 1.2, 1.0],
    [3.4, 2.3, 3.4, 2.3],
    [5.7, 4.5, 5.7, 4.5],
    [1.2, 1.0, 1.2, 1.0],
]

Attributes

  • mode: Supported modes: constant`(default), `reflect, edge, wrap Default value is name: "mode" type: STRING s: "constant"

Inputs

Between 2 and 4 inputs.

  • data (heterogeneous)T: Input tensor.

  • pads (heterogeneous)tensor(int64): Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * num_axes] where num_axes refers to the number of elements in the axes input or the input rank if axes are not provided explicitly. pads format should be: [x1_begin, x2_begin, …, x1_end, x2_end,…], where xi_begin is the number of pad values added at the beginning of axis axes[i] and xi_end, the number of pad values added at the end of axis axes[i].

  • constant_value (optional, heterogeneous)T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that pads apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated. If not provided, all axes are assumed ([0, 1, …, input_rank-1]).

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types up to IRv10.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxPad_1#

class skl2onnx.algebra.onnx_ops.OnnxPad_1(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 1.

Summary

Given data tensor, paddings, mode, and value. Example:

Insert 0 paddings to the beginning of the second dimension. data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

] paddings = [0, 0, 2, 0] output = [

[

[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],

],

]

Attributes

  • mode: Three modes: constant(default), reflect, edge Default value is name: "mode" type: STRING s: "constant"

  • value: One float, indicates the value to be filled, default is 0 Default value is name: "value" type: FLOAT f: 0

Inputs

  • data (heterogeneous)T: Input tensor.

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxPad_11#

class skl2onnx.algebra.onnx_ops.OnnxPad_11(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 11.

Summary

Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value, a padded tensor (output) is generated.

The three supported modes are (similar to corresponding modes supported by numpy.pad):

  1. constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0)

  2. reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

  3. edge - pads with the edge values of array

Example 1 (constant mode):

Insert 0 pads to the beginning of the second dimension.

data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

]

pads = [0, 2, 0, 0]

mode = ‘constant’

constant_value = 0.0

output = [

[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],

]

Example 2 (reflect mode):

data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

]

pads = [0, 2, 0, 0]

mode = ‘reflect’

output = [

[1.0, 1.2, 1.0, 1.2], [2.3, 3.4, 2.3, 3.4], [4.5, 5.7, 4.5, 5.7],

]

Example 3 (edge mode):

data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

]

pads = [0, 2, 0, 0]

mode = ‘edge’

output = [

[1.0, 1.0, 1.0, 1.2], [2.3, 2.3, 2.3, 3.4], [4.5, 4.5, 4.5, 5.7],

]

Attributes

  • mode: Supported modes: constant`(default), `reflect, edge Default value is name: "mode" type: STRING s: "constant"

Inputs

Between 2 and 3 inputs.

  • data (heterogeneous)T: Input tensor.

  • pads (heterogeneous)tensor(int64): Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * input_rank]. pads format should be: [x1_begin, x2_begin,…,x1_end, x2_end,…], where xi_begin is the number of pad values added at the beginning of axis i and xi_end, the number of pad values added at the end of axis i.

  • constant_value (optional, heterogeneous)T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0).

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output to only numeric types.

OnnxPad_13#

class skl2onnx.algebra.onnx_ops.OnnxPad_13(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 13.

Summary

Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value, a padded tensor (output) is generated.

The three supported modes are (similar to corresponding modes supported by numpy.pad):

  1. constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0, empty string, or False)

  2. reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

  3. edge - pads with the edge values of array

Example 1 (constant mode):

Insert 0 pads to the beginning of the second dimension.

data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

]

pads = [0, 2, 0, 0]

mode = ‘constant’

constant_value = 0.0

output = [

[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],

]

Example 2 (reflect mode):

data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

]

pads = [0, 2, 0, 0]

mode = ‘reflect’

output = [

[1.0, 1.2, 1.0, 1.2], [2.3, 3.4, 2.3, 3.4], [4.5, 5.7, 4.5, 5.7],

]

Example 3 (edge mode):

data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

]

pads = [0, 2, 0, 0]

mode = ‘edge’

output = [

[1.0, 1.0, 1.0, 1.2], [2.3, 2.3, 2.3, 3.4], [4.5, 4.5, 4.5, 5.7],

]

Attributes

  • mode: Supported modes: constant`(default), `reflect, edge Default value is name: "mode" type: STRING s: "constant"

Inputs

Between 2 and 3 inputs.

  • data (heterogeneous)T: Input tensor.

  • pads (heterogeneous)tensor(int64): Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * input_rank]. pads format should be: [x1_begin, x2_begin,…,x1_end, x2_end,…], where xi_begin is the number of pad values added at the beginning of axis i and xi_end, the number of pad values added at the end of axis i.

  • constant_value (optional, heterogeneous)T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxPad_18#

class skl2onnx.algebra.onnx_ops.OnnxPad_18(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 18.

Summary

Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value, a padded tensor (output) is generated.

The three supported modes are (similar to corresponding modes supported by numpy.pad):

  1. constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0, empty string, or False)

  2. reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

  3. edge - pads with the edge values of array

Example 1 (constant mode):

Insert 0 pads to the beginning of the second dimension.

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'constant'

constant_value = 0.0

output = [
    [0.0, 0.0, 1.0, 1.2],
    [0.0, 0.0, 2.3, 3.4],
    [0.0, 0.0, 4.5, 5.7],
]

Example 2 (reflect mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'reflect'

output = [
    [1.0, 1.2, 1.0, 1.2],
    [2.3, 3.4, 2.3, 3.4],
    [4.5, 5.7, 4.5, 5.7],
]

Example 3 (edge mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'edge'

output = [
    [1.0, 1.0, 1.0, 1.2],
    [2.3, 2.3, 2.3, 3.4],
    [4.5, 4.5, 4.5, 5.7],
]

Attributes

  • mode: Supported modes: constant`(default), `reflect, edge Default value is name: "mode" type: STRING s: "constant"

Inputs

Between 2 and 4 inputs.

  • data (heterogeneous)T: Input tensor.

  • pads (heterogeneous)tensor(int64): Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * num_axes] where num_axes refers to the number of elements in the axes input or the input rank if axes are not provided explicitly. pads format should be: [x1_begin, x2_begin, …, x1_end, x2_end,…], where xi_begin is the number of pad values added at the beginning of axis axes[i] and xi_end, the number of pad values added at the end of axis axes[i].

  • constant_value (optional, heterogeneous)T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that pads apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated. If not provided, all axes are assumed ([0, 1, …, input_rank-1]).

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxPad_19#

class skl2onnx.algebra.onnx_ops.OnnxPad_19(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 19.

Summary

Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value, a padded tensor (output) is generated.

The three supported modes are (similar to corresponding modes supported by numpy.pad):

  1. constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0, empty string, or False)

  2. reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

  3. edge - pads with the edge values of array

  4. wrap - wrap-around padding as if the data tensor forms a torus

Example 1 (constant mode):

Insert 0 pads to the beginning of the second dimension.

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'constant'

constant_value = 0.0

output = [
    [0.0, 0.0, 1.0, 1.2],
    [0.0, 0.0, 2.3, 3.4],
    [0.0, 0.0, 4.5, 5.7],
]

Example 2 (reflect mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'reflect'

output = [
    [1.0, 1.2, 1.0, 1.2],
    [2.3, 3.4, 2.3, 3.4],
    [4.5, 5.7, 4.5, 5.7],
]

Example 3 (edge mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'edge'

output = [
    [1.0, 1.0, 1.0, 1.2],
    [2.3, 2.3, 2.3, 3.4],
    [4.5, 4.5, 4.5, 5.7],
]

Example 4 (wrap mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [2, 1, 1, 1]

mode = 'wrap'

output = [
    [3.4, 2.3, 3.4, 2.3],
    [5.7, 4.5, 5.7, 4.5],
    [1.2, 1.0, 1.2, 1.0],
    [3.4, 2.3, 3.4, 2.3],
    [5.7, 4.5, 5.7, 4.5],
    [1.2, 1.0, 1.2, 1.0],
]

Attributes

  • mode: Supported modes: constant`(default), `reflect, edge, wrap Default value is name: "mode" type: STRING s: "constant"

Inputs

Between 2 and 4 inputs.

  • data (heterogeneous)T: Input tensor.

  • pads (heterogeneous)tensor(int64): Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * num_axes] where num_axes refers to the number of elements in the axes input or the input rank if axes are not provided explicitly. pads format should be: [x1_begin, x2_begin, …, x1_end, x2_end,…], where xi_begin is the number of pad values added at the beginning of axis axes[i] and xi_end, the number of pad values added at the end of axis axes[i].

  • constant_value (optional, heterogeneous)T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that pads apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated. If not provided, all axes are assumed ([0, 1, …, input_rank-1]).

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxPad_2#

class skl2onnx.algebra.onnx_ops.OnnxPad_2(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 2.

Summary

Given data tensor, pads, mode, and value. Example:

Insert 0 pads to the beginning of the second dimension. data = [

[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],

] pads = [0, 2, 0, 0] output = [

[

[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],

],

]

Attributes

  • mode: Three modes: constant(default), reflect, edge Default value is name: "mode" type: STRING s: "constant"

  • value: One float, indicates the value to be filled. Default value is name: "value" type: FLOAT f: 0

Inputs

  • data (heterogeneous)T: Input tensor.

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxPad_21#

class skl2onnx.algebra.onnx_ops.OnnxPad_21(*args, **kwargs)#

Version

Onnx name: Pad

This version of the operator has been available since version 21.

Summary

Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value, a padded tensor (output) is generated.

The three supported modes are (similar to corresponding modes supported by numpy.pad):

  1. constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0, empty string, or False)

  2. reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

  3. edge - pads with the edge values of array

  4. wrap - wrap-around padding as if the data tensor forms a torus

Example 1 (constant mode):

Insert 0 pads to the beginning of the second dimension.

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'constant'

constant_value = 0.0

output = [
    [0.0, 0.0, 1.0, 1.2],
    [0.0, 0.0, 2.3, 3.4],
    [0.0, 0.0, 4.5, 5.7],
]

Example 2 (reflect mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'reflect'

output = [
    [1.0, 1.2, 1.0, 1.2],
    [2.3, 3.4, 2.3, 3.4],
    [4.5, 5.7, 4.5, 5.7],
]

Example 3 (edge mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [0, 2, 0, 0]

mode = 'edge'

output = [
    [1.0, 1.0, 1.0, 1.2],
    [2.3, 2.3, 2.3, 3.4],
    [4.5, 4.5, 4.5, 5.7],
]

Example 4 (wrap mode):

data = [
    [1.0, 1.2],
    [2.3, 3.4],
    [4.5, 5.7],
]

pads = [2, 1, 1, 1]

mode = 'wrap'

output = [
    [3.4, 2.3, 3.4, 2.3],
    [5.7, 4.5, 5.7, 4.5],
    [1.2, 1.0, 1.2, 1.0],
    [3.4, 2.3, 3.4, 2.3],
    [5.7, 4.5, 5.7, 4.5],
    [1.2, 1.0, 1.2, 1.0],
]

Attributes

  • mode: Supported modes: constant`(default), `reflect, edge, wrap Default value is name: "mode" type: STRING s: "constant"

Inputs

Between 2 and 4 inputs.

  • data (heterogeneous)T: Input tensor.

  • pads (heterogeneous)tensor(int64): Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * num_axes] where num_axes refers to the number of elements in the axes input or the input rank if axes are not provided explicitly. pads format should be: [x1_begin, x2_begin, …, x1_end, x2_end,…], where xi_begin is the number of pad values added at the beginning of axis axes[i] and xi_end, the number of pad values added at the end of axis axes[i].

  • constant_value (optional, heterogeneous)T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that pads apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated. If not provided, all axes are assumed ([0, 1, …, input_rank-1]).

Outputs

  • output (heterogeneous)T: Tensor after padding.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types up to IRv10.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxPow#

class skl2onnx.algebra.onnx_ops.OnnxPow(*args, **kwargs)#

Version

Onnx name: Pow

This version of the operator has been available since version 15.

Summary

Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: First operand, base of the exponent.

  • Y (heterogeneous)T1: Second operand, power of the exponent.

Outputs

  • Z (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input X and output types to float/int tensors.

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input Y types to float/int tensors.

OnnxPow_1#

class skl2onnx.algebra.onnx_ops.OnnxPow_1(*args, **kwargs)#

Version

Onnx name: Pow

This version of the operator has been available since version 1.

Summary

Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise.

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • X (heterogeneous)T: Input tensor of any shape, base of the exponent.

  • Y (heterogeneous)T: Input tensor of any shape broadcastable to X shape, the exponent component.

Outputs

  • Z (heterogeneous)T: Output tensor (same size as X)

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxPow_12#

class skl2onnx.algebra.onnx_ops.OnnxPow_12(*args, **kwargs)#

Version

Onnx name: Pow

This version of the operator has been available since version 12.

Summary

Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: First operand, base of the exponent.

  • Y (heterogeneous)T1: Second operand, power of the exponent.

Outputs

  • Z (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input X and output types to float/int tensors.

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input Y types to float/int tensors.

OnnxPow_13#

class skl2onnx.algebra.onnx_ops.OnnxPow_13(*args, **kwargs)#

Version

Onnx name: Pow

This version of the operator has been available since version 13.

Summary

Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: First operand, base of the exponent.

  • Y (heterogeneous)T1: Second operand, power of the exponent.

Outputs

  • Z (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input X and output types to float/int tensors.

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input Y types to float/int tensors.

OnnxPow_15#

class skl2onnx.algebra.onnx_ops.OnnxPow_15(*args, **kwargs)#

Version

Onnx name: Pow

This version of the operator has been available since version 15.

Summary

Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: First operand, base of the exponent.

  • Y (heterogeneous)T1: Second operand, power of the exponent.

Outputs

  • Z (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input X and output types to float/int tensors.

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input Y types to float/int tensors.

OnnxPow_7#

class skl2onnx.algebra.onnx_ops.OnnxPow_7(*args, **kwargs)#

Version

Onnx name: Pow

This version of the operator has been available since version 7.

Summary

Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • X (heterogeneous)T: First operand, base of the exponent.

  • Y (heterogeneous)T: Second operand, power of the exponent.

Outputs

  • Z (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxQLinearConv#

class skl2onnx.algebra.onnx_ops.OnnxQLinearConv(*args, **kwargs)#

Version

Onnx name: QLinearConv

This version of the operator has been available since version 10.

Summary

The convolution operator consumes a quantized input tensor, its scale and zero point, a quantized filter, its scale and zero point, and output’s scale and zero point, and computes the quantized output. Each scale and zero-point pair must have same shape. It means they must be either scalars (per tensor) or 1-D tensors (per output channel). Each input or output and its related zero point must have same type. When bias is present it must be quantized using scale = input scale * weight scale and zero point as 0.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. default is 1. Default value is name: "group" type: INT i: 1

Inputs

Between 8 and 9 inputs.

  • x (heterogeneous)T1: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • x_scale (heterogeneous)tensor(float): Scale tensor for input ‘x’. It’s a scalar, which means a per-tensor/layer quantization.

  • x_zero_point (heterogeneous)T1: Zero point tensor for input ‘x’. It’s a scalar, which means a per-tensor/layer quantization.

  • w (heterogeneous)T2: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. X.shape[1] == (W.shape[1] * group) == C (assuming zero based indices for the shape array). Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL.

  • w_scale (heterogeneous)tensor(float): Scale tensor for input ‘w’. It could be a scalar or a 1-D tensor, which means a per-tensor/layer or per output channel quantization. If it’s a 1-D tensor, its number of elements should be equal to the number of output channels (M).

  • w_zero_point (heterogeneous)T2: Zero point tensor for input ‘w’. It could be a scalar or a 1-D tensor, which means a per-tensor/layer or per output channel quantization. If it’s a 1-D tensor, its number of elements should be equal to the number of output channels (M).

  • y_scale (heterogeneous)tensor(float): Scale tensor for output ‘y’. It’s a scalar, which means a per-tensor/layer quantization.

  • y_zero_point (heterogeneous)T3: Zero point tensor for output ‘y’. It’s a scalar, which means a per-tensor/layer quantization.

  • B (optional, heterogeneous)T4: Optional 1D bias to be added to the convolution, has size of M. Bias must be quantized using scale = x_scale * w_scale and zero_point = 0

Outputs

  • y (heterogeneous)T3: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain filter type to 8-bit integer tensor.

  • T3 tensor(int8), tensor(uint8): Constrain output type to 8-bit integer tensor.

  • T4 tensor(int32): Constrain bias type to 32-bit integer tensor.

OnnxQLinearConv_10#

class skl2onnx.algebra.onnx_ops.OnnxQLinearConv_10(*args, **kwargs)#

Version

Onnx name: QLinearConv

This version of the operator has been available since version 10.

Summary

The convolution operator consumes a quantized input tensor, its scale and zero point, a quantized filter, its scale and zero point, and output’s scale and zero point, and computes the quantized output. Each scale and zero-point pair must have same shape. It means they must be either scalars (per tensor) or 1-D tensors (per output channel). Each input or output and its related zero point must have same type. When bias is present it must be quantized using scale = input scale * weight scale and zero point as 0.

Attributes

  • auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is name: "auto_pad" type: STRING s: "NOTSET"

  • group: number of groups input channels and output channels are divided into. default is 1. Default value is name: "group" type: INT i: 1

Inputs

Between 8 and 9 inputs.

  • x (heterogeneous)T1: Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 … x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].

  • x_scale (heterogeneous)tensor(float): Scale tensor for input ‘x’. It’s a scalar, which means a per-tensor/layer quantization.

  • x_zero_point (heterogeneous)T1: Zero point tensor for input ‘x’. It’s a scalar, which means a per-tensor/layer quantization.

  • w (heterogeneous)T2: The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x … x kn), where (k1 x k2 x … kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL …]. X.shape[1] == (W.shape[1] * group) == C (assuming zero based indices for the shape array). Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL.

  • w_scale (heterogeneous)tensor(float): Scale tensor for input ‘w’. It could be a scalar or a 1-D tensor, which means a per-tensor/layer or per output channel quantization. If it’s a 1-D tensor, its number of elements should be equal to the number of output channels (M).

  • w_zero_point (heterogeneous)T2: Zero point tensor for input ‘w’. It could be a scalar or a 1-D tensor, which means a per-tensor/layer or per output channel quantization. If it’s a 1-D tensor, its number of elements should be equal to the number of output channels (M).

  • y_scale (heterogeneous)tensor(float): Scale tensor for output ‘y’. It’s a scalar, which means a per-tensor/layer quantization.

  • y_zero_point (heterogeneous)T3: Zero point tensor for output ‘y’. It’s a scalar, which means a per-tensor/layer quantization.

  • B (optional, heterogeneous)T4: Optional 1D bias to be added to the convolution, has size of M. Bias must be quantized using scale = x_scale * w_scale and zero_point = 0

Outputs

  • y (heterogeneous)T3: Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain filter type to 8-bit integer tensor.

  • T3 tensor(int8), tensor(uint8): Constrain output type to 8-bit integer tensor.

  • T4 tensor(int32): Constrain bias type to 32-bit integer tensor.

OnnxQLinearMatMul#

class skl2onnx.algebra.onnx_ops.OnnxQLinearMatMul(*args, **kwargs)#

Version

Onnx name: QLinearMatMul

This version of the operator has been available since version 21.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html. It consumes two quantized input tensors, their scales and zero points, scale and zero point of output, and computes the quantized output. The quantization formula is y = saturate((x / y_scale) + y_zero_point). For (x / y_scale), it is rounding to nearest ties to even. Refer to https://en.wikipedia.org/wiki/Rounding for details. Scale and zero point must have same shape. They must be either scalar (per tensor) or N-D tensor (per row for ‘a’ and per column for ‘b’). Scalar refers to per tensor quantization whereas N-D refers to per row or per column quantization. If the input is 2D of shape [M, K] then zero point and scale tensor may be an M element vector [v_1, v_2, …, v_M] for per row quantization and K element vector of shape [v_1, v_2, …, v_K] for per column quantization. If the input is N-D tensor with shape [D1, D2, M, K] then zero point and scale tensor may have shape [D1, D2, M, 1] for per row quantization and shape [D1, D2, 1, K] for per column quantization. Production must never overflow, and accumulation may overflow if and only if in 32 bits.

Inputs

  • a (heterogeneous)T1: N-dimensional quantized matrix a

  • a_scale (heterogeneous)TS: scale of quantized input a

  • a_zero_point (heterogeneous)T1: zero point of quantized input a

  • b (heterogeneous)T2: N-dimensional quantized matrix b

  • b_scale (heterogeneous)TS: scale of quantized input b

  • b_zero_point (heterogeneous)T2: zero point of quantized input b

  • y_scale (heterogeneous)TS: scale of quantized output y

  • y_zero_point (heterogeneous)T3: zero point of quantized output y

Outputs

  • y (heterogeneous)T3: Quantized matrix multiply results from a * b

Type Constraints

  • TS tensor(float), tensor(float16), tensor(bfloat16): Constrain scales.

  • T1 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): The type of input a and its zeropoint.

  • T2 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): The type of input b and its zeropoint.

  • T3 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): The type of the output and its zeropoint.

OnnxQLinearMatMul_10#

class skl2onnx.algebra.onnx_ops.OnnxQLinearMatMul_10(*args, **kwargs)#

Version

Onnx name: QLinearMatMul

This version of the operator has been available since version 10.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html. It consumes two quantized input tensors, their scales and zero points, scale and zero point of output, and computes the quantized output. The quantization formula is y = saturate((x / y_scale) + y_zero_point). For (x / y_scale), it is rounding to nearest ties to even. Refer to https://en.wikipedia.org/wiki/Rounding for details. Scale and zero point must have same shape. They must be either scalar (per tensor) or N-D tensor (per row for ‘a’ and per column for ‘b’). Scalar refers to per tensor quantization whereas N-D refers to per row or per column quantization. If the input is 2D of shape [M, K] then zero point and scale tensor may be an M element vector [v_1, v_2, …, v_M] for per row quantization and K element vector of shape [v_1, v_2, …, v_K] for per column quantization. If the input is N-D tensor with shape [D1, D2, M, K] then zero point and scale tensor may have shape [D1, D2, M, 1] for per row quantization and shape [D1, D2, 1, K] for per column quantization. Production must never overflow, and accumulation may overflow if and only if in 32 bits.

Inputs

  • a (heterogeneous)T1: N-dimensional quantized matrix a

  • a_scale (heterogeneous)tensor(float): scale of quantized input a

  • a_zero_point (heterogeneous)T1: zero point of quantized input a

  • b (heterogeneous)T2: N-dimensional quantized matrix b

  • b_scale (heterogeneous)tensor(float): scale of quantized input b

  • b_zero_point (heterogeneous)T2: zero point of quantized input b

  • y_scale (heterogeneous)tensor(float): scale of quantized output y

  • y_zero_point (heterogeneous)T3: zero point of quantized output y

Outputs

  • y (heterogeneous)T3: Quantized matrix multiply results from a * b

Type Constraints

  • T1 tensor(int8), tensor(uint8): Constrain input a and its zero point data type to 8-bit integer tensor.

  • T2 tensor(int8), tensor(uint8): Constrain input b and its zero point data type to 8-bit integer tensor.

  • T3 tensor(int8), tensor(uint8): Constrain output y and its zero point data type to 8-bit integer tensor.

OnnxQLinearMatMul_21#

class skl2onnx.algebra.onnx_ops.OnnxQLinearMatMul_21(*args, **kwargs)#

Version

Onnx name: QLinearMatMul

This version of the operator has been available since version 21.

Summary

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html. It consumes two quantized input tensors, their scales and zero points, scale and zero point of output, and computes the quantized output. The quantization formula is y = saturate((x / y_scale) + y_zero_point). For (x / y_scale), it is rounding to nearest ties to even. Refer to https://en.wikipedia.org/wiki/Rounding for details. Scale and zero point must have same shape. They must be either scalar (per tensor) or N-D tensor (per row for ‘a’ and per column for ‘b’). Scalar refers to per tensor quantization whereas N-D refers to per row or per column quantization. If the input is 2D of shape [M, K] then zero point and scale tensor may be an M element vector [v_1, v_2, …, v_M] for per row quantization and K element vector of shape [v_1, v_2, …, v_K] for per column quantization. If the input is N-D tensor with shape [D1, D2, M, K] then zero point and scale tensor may have shape [D1, D2, M, 1] for per row quantization and shape [D1, D2, 1, K] for per column quantization. Production must never overflow, and accumulation may overflow if and only if in 32 bits.

Inputs

  • a (heterogeneous)T1: N-dimensional quantized matrix a

  • a_scale (heterogeneous)TS: scale of quantized input a

  • a_zero_point (heterogeneous)T1: zero point of quantized input a

  • b (heterogeneous)T2: N-dimensional quantized matrix b

  • b_scale (heterogeneous)TS: scale of quantized input b

  • b_zero_point (heterogeneous)T2: zero point of quantized input b

  • y_scale (heterogeneous)TS: scale of quantized output y

  • y_zero_point (heterogeneous)T3: zero point of quantized output y

Outputs

  • y (heterogeneous)T3: Quantized matrix multiply results from a * b

Type Constraints

  • TS tensor(float), tensor(float16), tensor(bfloat16): Constrain scales.

  • T1 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): The type of input a and its zeropoint.

  • T2 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): The type of input b and its zeropoint.

  • T3 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): The type of the output and its zeropoint.

OnnxQuantizeLinear#

class skl2onnx.algebra.onnx_ops.OnnxQuantizeLinear(*args, **kwargs)#

Version

Onnx name: QuantizeLinear

This version of the operator has been available since version 21.

Summary

The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. The quantization formula is y = saturate ((x / y_scale) + y_zero_point). For saturation, it saturates according to: uint8: [0, 255], int8: [-128, 127], uint16: [0, 65535], int16: [-32768, 32767], uint4: [0, 15], int4: [-8, 7] For (x / y_scale), it’s rounding to the nearest even. Refer to https://en.wikipedia.org/wiki/Rounding for details. ‘y_zero_point’ and ‘y’ must have same type. ‘y_zero_point’ is usually not used for quantization to float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz, but the quantization formula remains the same for consistency and the type of the attribute ‘y_zero_point’ still determines the quantization type.

Attributes

  • axis: (Optional) The axis of the quantization dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 quantization (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. All cases are fully described in two tables inserted in the operator description. Default value is name: "saturate" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D full precision Input tensor to be quantized.

  • y_scale (heterogeneous)T1: Scale for doing quantization to get ‘y’. It can be a scalar, which means per-tensor/layer quantization, or a 1-D Tensor for per-axis quantization.

  • y_zero_point (optional, heterogeneous)T2: Zero point for doing quantization to get ‘y’. Shape must match y_scale. Default is uint8 with zero point of 0 if it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D quantized output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(float), tensor(float16), tensor(bfloat16), tensor(int32): The type of the input ‘x’.

  • T2 tensor(int8), tensor(uint8), tensor(int16), tensor(uint16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): The type of the input ‘y_zero_point’ and the output ‘y’.

OnnxQuantizeLinear_10#

class skl2onnx.algebra.onnx_ops.OnnxQuantizeLinear_10(*args, **kwargs)#

Version

Onnx name: QuantizeLinear

This version of the operator has been available since version 10.

Summary

The linear per-tensor/layer quantization operator. It consumes a high precision tensor, a scale, a zero point to compute the low precision / quantized tensor. The quantization formula is y = saturate ((x / y_scale) + y_zero_point). For saturation, it saturates to [0, 255] if it’s uint8, or [-128, 127] if it’s int8. For (x / y_scale), it’s rounding to the nearest even. Refer to https://en.wikipedia.org/wiki/Rounding for details. ‘y_zero_point’ and ‘y’ must have same type.

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D full precision Input tensor to be quantized.

  • y_scale (heterogeneous)tensor(float): Scale for doing quantization to get ‘y’. It’s a scalar, which means a per-tensor/layer quantization.

  • y_zero_point (optional, heterogeneous)T2: Zero point for doing quantization to get ‘y’. It’s a scalar, which means a per-tensor/layer quantization. Default value is uint8 typed 0 if it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D quantized output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(float), tensor(int32): Constrain ‘x’ to float or int32 tensor.

  • T2 tensor(int8), tensor(uint8): Constrain ‘y_zero_point’ and ‘y’ to 8-bit integer tensor.

OnnxQuantizeLinear_13#

class skl2onnx.algebra.onnx_ops.OnnxQuantizeLinear_13(*args, **kwargs)#

Version

Onnx name: QuantizeLinear

This version of the operator has been available since version 13.

Summary

The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. The quantization formula is y = saturate ((x / y_scale) + y_zero_point). For saturation, it saturates to [0, 255] if it’s uint8, or [-128, 127] if it’s int8. For (x / y_scale), it’s rounding to the nearest even. Refer to https://en.wikipedia.org/wiki/Rounding for details. ‘y_zero_point’ and ‘y’ must have same type.

Attributes

  • axis: (Optional) The axis of the quantization dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D full precision Input tensor to be quantized.

  • y_scale (heterogeneous)tensor(float): Scale for doing quantization to get ‘y’. It can be a scalar, which means per-tensor/layer quantization, or a 1-D Tensor for per-axis quantization.

  • y_zero_point (optional, heterogeneous)T2: Zero point for doing quantization to get ‘y’. Shape must match y_scale. Default is uint8 with zero point of 0 if it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D quantized output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(float), tensor(int32): Constrain ‘x’ to float or int32 tensor.

  • T2 tensor(int8), tensor(uint8): Constrain ‘y_zero_point’ and ‘y’ to 8-bit integer tensor.

OnnxQuantizeLinear_19#

class skl2onnx.algebra.onnx_ops.OnnxQuantizeLinear_19(*args, **kwargs)#

Version

Onnx name: QuantizeLinear

This version of the operator has been available since version 19.

Summary

The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. The quantization formula is y = saturate ((x / y_scale) + y_zero_point). For saturation, it saturates to [0, 255] if it’s uint8, or [-128, 127] if it’s int8. For (x / y_scale), it’s rounding to the nearest even. Refer to https://en.wikipedia.org/wiki/Rounding for details. ‘y_zero_point’ and ‘y’ must have same type. ‘y_zero_point’ is usually not used for quantization to float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz, but the quantization formula remains the same for consistency and the type of the attribute ‘y_zero_point’ still determines the quantization type.

Attributes

  • axis: (Optional) The axis of the quantization dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 quantization (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. All cases are fully described in two tables inserted in the operator description. Default value is name: "saturate" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D full precision Input tensor to be quantized.

  • y_scale (heterogeneous)T1: Scale for doing quantization to get ‘y’. It can be a scalar, which means per-tensor/layer quantization, or a 1-D Tensor for per-axis quantization.

  • y_zero_point (optional, heterogeneous)T2: Zero point for doing quantization to get ‘y’. Shape must match y_scale. Default is uint8 with zero point of 0 if it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D quantized output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(float), tensor(float16), tensor(bfloat16), tensor(int32): Constrain ‘x’ to float, float16, bfloat16 or int32 tensor.

  • T2 tensor(int8), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain ‘y_zero_point’ and ‘y’ to 8-bit integer/float tensor.

OnnxQuantizeLinear_21#

class skl2onnx.algebra.onnx_ops.OnnxQuantizeLinear_21(*args, **kwargs)#

Version

Onnx name: QuantizeLinear

This version of the operator has been available since version 21.

Summary

The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. The quantization formula is y = saturate ((x / y_scale) + y_zero_point). For saturation, it saturates according to: uint8: [0, 255], int8: [-128, 127], uint16: [0, 65535], int16: [-32768, 32767], uint4: [0, 15], int4: [-8, 7] For (x / y_scale), it’s rounding to the nearest even. Refer to https://en.wikipedia.org/wiki/Rounding for details. ‘y_zero_point’ and ‘y’ must have same type. ‘y_zero_point’ is usually not used for quantization to float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz, but the quantization formula remains the same for consistency and the type of the attribute ‘y_zero_point’ still determines the quantization type.

Attributes

  • axis: (Optional) The axis of the quantization dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

  • saturate: The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 quantization (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. All cases are fully described in two tables inserted in the operator description. Default value is name: "saturate" type: INT i: 1

Inputs

Between 2 and 3 inputs.

  • x (heterogeneous)T1: N-D full precision Input tensor to be quantized.

  • y_scale (heterogeneous)T1: Scale for doing quantization to get ‘y’. It can be a scalar, which means per-tensor/layer quantization, or a 1-D Tensor for per-axis quantization.

  • y_zero_point (optional, heterogeneous)T2: Zero point for doing quantization to get ‘y’. Shape must match y_scale. Default is uint8 with zero point of 0 if it’s not specified.

Outputs

  • y (heterogeneous)T2: N-D quantized output tensor. It has same shape as input ‘x’.

Type Constraints

  • T1 tensor(float), tensor(float16), tensor(bfloat16), tensor(int32): The type of the input ‘x’.

  • T2 tensor(int8), tensor(uint8), tensor(int16), tensor(uint16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): The type of the input ‘y_zero_point’ and the output ‘y’.

OnnxRNN#

class skl2onnx.algebra.onnx_ops.OnnxRNN(*args, **kwargs)#

Version

Onnx name: RNN

This version of the operator has been available since version 14.

Summary

Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

  • X - input tensor

  • i - input gate

  • t - time step (t-1 means previous time step)

  • Wi - W parameter weight matrix for input gate

  • Ri - R recurrence weight matrix for input gate

  • Wbi - W parameter bias vector for input gate

  • Rbi - R parameter bias vector for input gate

  • WBi - W parameter weight matrix for backward input gate

  • RBi - R recurrence weight matrix for backward input gate

  • WBbi - WR bias vectors for backward input gate

  • RBbi - RR bias vectors for backward input gate

  • H - Hidden state

  • num_directions - 2 if direction == bidirectional else 1

Activation functions:

  • Relu(x) - max(0, x)

  • Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

  • Sigmoid(x) - 1/(1 + e^{-x})

NOTE: Below are optional

  • Affine(x) - alpha*x + beta

  • LeakyRelu(x) - x if x >= 0 else alpha * x

  • ThresholdedRelu(x) - x if x >= alpha else 0

  • ScaledTanh(x) - alpha*Tanh(beta*x)

  • HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

  • Elu(x) - x if x >= 0 else alpha*(e^x - 1)

  • Softsign(x) - x/(1 + |x|)

  • Softplus(x) - log(1 + e^x)

Equations (Default: f=Tanh):

  • Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • activations: One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default Tanh if not specified. Default value is name: "activations" type: STRINGS strings: "Tanh" strings: "Tanh"

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • layout: The shape format of inputs X, initial_h and outputs Y, Y_h. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size]. Default value is name: "layout" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for input gate. Concatenation of Wi and WBi (if bidirectional). The tensor has shape [num_directions, hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of Ri and RBi (if bidirectional). The tensor has shape [num_directions, hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wbi, Rbi] and [WBbi, RBbi] (if bidirectional). The tensor has shape [num_directions, 2*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxRNN_1#

class skl2onnx.algebra.onnx_ops.OnnxRNN_1(*args, **kwargs)#

Version

Onnx name: RNN

This version of the operator has been available since version 1.

Summary

Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

t - time step (t-1 means previous time step)

Wi - W parameter weight matrix for input gate

Ri - R recurrence weight matrix for input gate

Wbi - W parameter bias vector for input gate

Rbi - R parameter bias vector for input gate

WBi - W parameter weight matrix for backward input gate

RBi - R recurrence weight matrix for backward input gate

WBbi - WR bias vectors for backward input gate

RBbi - RR bias vectors for backward input gate

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Tanh):

  • Ht = f(Xt*(Wi^T) + Ht-1*Ri + Wbi + Rbi)

Attributes

  • activations: One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default Tanh if not specified. Default value is name: "activations" type: STRINGS strings: "Tanh" strings: "Tanh"

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • output_sequence: The sequence output for the hidden is optional if 0. Default 0. Default value is name: "output_sequence" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for input gate. Concatenation of Wi and WBi (if bidirectional). The tensor has shape [num_directions, hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of Ri and RBi (if bidirectional). The tensor has shape [num_directions, hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wbi, Rbi] and [WBbi, RBbi] (if bidirectional). The tensor has shape [num_directions, 2*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size]. It is optional if output_sequence is 0.

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxRNN_14#

class skl2onnx.algebra.onnx_ops.OnnxRNN_14(*args, **kwargs)#

Version

Onnx name: RNN

This version of the operator has been available since version 14.

Summary

Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

  • X - input tensor

  • i - input gate

  • t - time step (t-1 means previous time step)

  • Wi - W parameter weight matrix for input gate

  • Ri - R recurrence weight matrix for input gate

  • Wbi - W parameter bias vector for input gate

  • Rbi - R parameter bias vector for input gate

  • WBi - W parameter weight matrix for backward input gate

  • RBi - R recurrence weight matrix for backward input gate

  • WBbi - WR bias vectors for backward input gate

  • RBbi - RR bias vectors for backward input gate

  • H - Hidden state

  • num_directions - 2 if direction == bidirectional else 1

Activation functions:

  • Relu(x) - max(0, x)

  • Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

  • Sigmoid(x) - 1/(1 + e^{-x})

NOTE: Below are optional

  • Affine(x) - alpha*x + beta

  • LeakyRelu(x) - x if x >= 0 else alpha * x

  • ThresholdedRelu(x) - x if x >= alpha else 0

  • ScaledTanh(x) - alpha*Tanh(beta*x)

  • HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

  • Elu(x) - x if x >= 0 else alpha*(e^x - 1)

  • Softsign(x) - x/(1 + |x|)

  • Softplus(x) - log(1 + e^x)

Equations (Default: f=Tanh):

  • Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • activations: One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default Tanh if not specified. Default value is name: "activations" type: STRINGS strings: "Tanh" strings: "Tanh"

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

  • layout: The shape format of inputs X, initial_h and outputs Y, Y_h. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size]. Default value is name: "layout" type: INT i: 0

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for input gate. Concatenation of Wi and WBi (if bidirectional). The tensor has shape [num_directions, hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of Ri and RBi (if bidirectional). The tensor has shape [num_directions, hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wbi, Rbi] and [WBbi, RBbi] (if bidirectional). The tensor has shape [num_directions, 2*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxRNN_7#

class skl2onnx.algebra.onnx_ops.OnnxRNN_7(*args, **kwargs)#

Version

Onnx name: RNN

This version of the operator has been available since version 7.

Summary

Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

t - time step (t-1 means previous time step)

Wi - W parameter weight matrix for input gate

Ri - R recurrence weight matrix for input gate

Wbi - W parameter bias vector for input gate

Rbi - R parameter bias vector for input gate

WBi - W parameter weight matrix for backward input gate

RBi - R recurrence weight matrix for backward input gate

WBbi - WR bias vectors for backward input gate

RBbi - RR bias vectors for backward input gate

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x) - max(0, x)

Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x) - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x) - alpha*x + beta

LeakyRelu(x) - x if x >= 0 else alpha * x

ThresholdedRelu(x) - x if x >= alpha else 0

ScaledTanh(x) - alpha*Tanh(beta*x)

HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)

Elu(x) - x if x >= 0 else alpha*(e^x - 1)

Softsign(x) - x/(1 + |x|)

Softplus(x) - log(1 + e^x)

Equations (Default: f=Tanh):

  • Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)

This operator has optional inputs/outputs. See ONNX for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument’s name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Attributes

  • activations: One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default Tanh if not specified. Default value is name: "activations" type: STRINGS strings: "Tanh" strings: "Tanh"

  • direction: Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional. Default value is name: "direction" type: STRING s: "forward"

Inputs

Between 3 and 6 inputs.

  • X (heterogeneous)T: The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W (heterogeneous)T: The weight tensor for input gate. Concatenation of Wi and WBi (if bidirectional). The tensor has shape [num_directions, hidden_size, input_size].

  • R (heterogeneous)T: The recurrence weight tensor. Concatenation of Ri and RBi (if bidirectional). The tensor has shape [num_directions, hidden_size, hidden_size].

  • B (optional, heterogeneous)T: The bias tensor for input gate. Concatenation of [Wbi, Rbi] and [WBbi, RBbi] (if bidirectional). The tensor has shape [num_directions, 2*hidden_size]. Optional: If not specified - assumed to be 0.

  • sequence_lens (optional, heterogeneous)T1: Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].

  • initial_h (optional, heterogeneous)T: Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].

Outputs

Between 0 and 2 outputs.

  • Y (optional, heterogeneous)T: A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].

  • Y_h (optional, heterogeneous)T: The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • T1 tensor(int32): Constrain seq_lens to integer tensor.

OnnxRandomNormal#

class skl2onnx.algebra.onnx_ops.OnnxRandomNormal(*args, **kwargs)#

Version

Onnx name: RandomNormal

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a normal distribution. The shape of the tensor is specified by the shape argument and the parameter of the normal distribution specified by mean and scale.

The data type is specified by the ‘dtype’ argument. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Attributes

  • dtype: The data type for the elements of the output tensor. Default is TensorProto::FLOAT. Default value is name: "dtype" type: INT i: 1

  • mean: The mean of the normal distribution. Default value is name: "mean" type: FLOAT f: 0

  • scale: The standard deviation of the normal distribution. Default value is name: "scale" type: FLOAT f: 1

Outputs

  • output (heterogeneous)T: Output tensor of random values drawn from normal distribution

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomNormalLike#

class skl2onnx.algebra.onnx_ops.OnnxRandomNormalLike(*args, **kwargs)#

Version

Onnx name: RandomNormalLike

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a normal distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the normal distribution are specified by mean and scale.

The data type is specified by the ‘dtype’ argument, or copied from the input tensor if not provided. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message, and be valid as an output type.

Attributes

  • mean: The mean of the normal distribution. Default value is name: "mean" type: FLOAT f: 0

  • scale: The standard deviation of the normal distribution. Default value is name: "scale" type: FLOAT f: 1

Inputs

  • input (heterogeneous)T1: Input tensor to copy shape and optionally type information from.

Outputs

  • output (heterogeneous)T2: Output tensor of random values drawn from normal distribution

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomNormalLike_1#

class skl2onnx.algebra.onnx_ops.OnnxRandomNormalLike_1(*args, **kwargs)#

Version

Onnx name: RandomNormalLike

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a normal distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the normal distribution are specified by mean and scale.

The data type is specified by the ‘dtype’ argument, or copied from the input tensor if not provided. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message, and be valid as an output type.

Attributes

  • mean: The mean of the normal distribution. Default value is name: "mean" type: FLOAT f: 0

  • scale: The standard deviation of the normal distribution. Default value is name: "scale" type: FLOAT f: 1

Inputs

  • input (heterogeneous)T1: Input tensor to copy shape and optionally type information from.

Outputs

  • output (heterogeneous)T2: Output tensor of random values drawn from normal distribution

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomNormal_1#

class skl2onnx.algebra.onnx_ops.OnnxRandomNormal_1(*args, **kwargs)#

Version

Onnx name: RandomNormal

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a normal distribution. The shape of the tensor is specified by the shape argument and the parameter of the normal distribution specified by mean and scale.

The data type is specified by the ‘dtype’ argument. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Attributes

  • dtype: The data type for the elements of the output tensor. Default is TensorProto::FLOAT. Default value is name: "dtype" type: INT i: 1

  • mean: The mean of the normal distribution. Default value is name: "mean" type: FLOAT f: 0

  • scale: The standard deviation of the normal distribution. Default value is name: "scale" type: FLOAT f: 1

Outputs

  • output (heterogeneous)T: Output tensor of random values drawn from normal distribution

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomUniform#

class skl2onnx.algebra.onnx_ops.OnnxRandomUniform(*args, **kwargs)#

Version

Onnx name: RandomUniform

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a uniform distribution. The shape of the tensor is specified by the shape argument and the range by low and high.

The data type is specified by the ‘dtype’ argument. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Attributes

  • dtype: The data type for the elements of the output tensor. If not specified, default is TensorProto::FLOAT. Default value is name: "dtype" type: INT i: 1

  • high: Upper boundary of the output values. Default value is name: "high" type: FLOAT f: 1

  • low: Lower boundary of the output values. Default value is name: "low" type: FLOAT f: 0

Outputs

  • output (heterogeneous)T: Output tensor of random values drawn from uniform distribution

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomUniformLike#

class skl2onnx.algebra.onnx_ops.OnnxRandomUniformLike(*args, **kwargs)#

Version

Onnx name: RandomUniformLike

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a uniform distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the uniform distribution are specified by low and high.

The data type is specified by the ‘dtype’ argument, or copied from the input tensor if not provided. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message and be valid as an output type.

Attributes

  • high: Upper boundary of the output values. Default value is name: "high" type: FLOAT f: 1

  • low: Lower boundary of the output values. Default value is name: "low" type: FLOAT f: 0

Inputs

  • input (heterogeneous)T1: Input tensor to copy shape and optionally type information from.

Outputs

  • output (heterogeneous)T2: Output tensor of random values drawn from uniform distribution

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomUniformLike_1#

class skl2onnx.algebra.onnx_ops.OnnxRandomUniformLike_1(*args, **kwargs)#

Version

Onnx name: RandomUniformLike

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a uniform distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the uniform distribution are specified by low and high.

The data type is specified by the ‘dtype’ argument, or copied from the input tensor if not provided. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message and be valid as an output type.

Attributes

  • high: Upper boundary of the output values. Default value is name: "high" type: FLOAT f: 1

  • low: Lower boundary of the output values. Default value is name: "low" type: FLOAT f: 0

Inputs

  • input (heterogeneous)T1: Input tensor to copy shape and optionally type information from.

Outputs

  • output (heterogeneous)T2: Output tensor of random values drawn from uniform distribution

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRandomUniform_1#

class skl2onnx.algebra.onnx_ops.OnnxRandomUniform_1(*args, **kwargs)#

Version

Onnx name: RandomUniform

This version of the operator has been available since version 1.

Summary

Generate a tensor with random values drawn from a uniform distribution. The shape of the tensor is specified by the shape argument and the range by low and high.

The data type is specified by the ‘dtype’ argument. The ‘dtype’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.

Attributes

  • dtype: The data type for the elements of the output tensor. If not specified, default is TensorProto::FLOAT. Default value is name: "dtype" type: INT i: 1

  • high: Upper boundary of the output values. Default value is name: "high" type: FLOAT f: 1

  • low: Lower boundary of the output values. Default value is name: "low" type: FLOAT f: 0

Outputs

  • output (heterogeneous)T: Output tensor of random values drawn from uniform distribution

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain output types to float tensors.

OnnxRange#

class skl2onnx.algebra.onnx_ops.OnnxRange(*args, **kwargs)#

Version

Onnx name: Range

This version of the operator has been available since version 11.

Summary

Generate a tensor containing a sequence of numbers that begin at start and extends by increments of delta up to limit (exclusive).

The number of elements in the output of range is computed as below:

number_of_elements = max( ceil( (limit - start) / delta ) , 0 )

The pseudocode determining the contents of the output is shown below:

for(int i=0; i<number_of_elements; ++i) {
  output[i] =  start + (i * delta);
}

Example 1

Inputs: start = 3, limit = 9, delta = 3
Output: [3, 6]

Example 2

Inputs: start = 10, limit = 4, delta = -2
Output: [10, 8, 6]

Inputs

  • start (heterogeneous)T: Scalar. First entry for the range of output values.

  • limit (heterogeneous)T: Scalar. Exclusive upper limit for the range of output values.

  • delta (heterogeneous)T: Scalar. Value to step by.

Outputs

  • output (heterogeneous)T: A 1-D tensor with same type as the inputs containing generated range of values.

Type Constraints

  • T tensor(float), tensor(double), tensor(int16), tensor(int32), tensor(int64): Constrain input types to common numeric type tensors.

OnnxRange_11#

class skl2onnx.algebra.onnx_ops.OnnxRange_11(*args, **kwargs)#

Version

Onnx name: Range

This version of the operator has been available since version 11.

Summary

Generate a tensor containing a sequence of numbers that begin at start and extends by increments of delta up to limit (exclusive).

The number of elements in the output of range is computed as below:

number_of_elements = max( ceil( (limit - start) / delta ) , 0 )

The pseudocode determining the contents of the output is shown below:

for(int i=0; i<number_of_elements; ++i) {
  output[i] =  start + (i * delta);
}

Example 1

Inputs: start = 3, limit = 9, delta = 3
Output: [3, 6]

Example 2

Inputs: start = 10, limit = 4, delta = -2
Output: [10, 8, 6]

Inputs

  • start (heterogeneous)T: Scalar. First entry for the range of output values.

  • limit (heterogeneous)T: Scalar. Exclusive upper limit for the range of output values.

  • delta (heterogeneous)T: Scalar. Value to step by.

Outputs

  • output (heterogeneous)T: A 1-D tensor with same type as the inputs containing generated range of values.

Type Constraints

  • T tensor(float), tensor(double), tensor(int16), tensor(int32), tensor(int64): Constrain input types to common numeric type tensors.

OnnxReciprocal#

class skl2onnx.algebra.onnx_ops.OnnxReciprocal(*args, **kwargs)#

Version

Onnx name: Reciprocal

This version of the operator has been available since version 13.

Summary

Reciprocal takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the reciprocal is, y = 1/x, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxReciprocal_1#

class skl2onnx.algebra.onnx_ops.OnnxReciprocal_1(*args, **kwargs)#

Version

Onnx name: Reciprocal

This version of the operator has been available since version 1.

Summary

Reciprocal takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the reciprocal is, y = 1/x, is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxReciprocal_13#

class skl2onnx.algebra.onnx_ops.OnnxReciprocal_13(*args, **kwargs)#

Version

Onnx name: Reciprocal

This version of the operator has been available since version 13.

Summary

Reciprocal takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the reciprocal is, y = 1/x, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxReciprocal_6#

class skl2onnx.algebra.onnx_ops.OnnxReciprocal_6(*args, **kwargs)#

Version

Onnx name: Reciprocal

This version of the operator has been available since version 6.

Summary

Reciprocal takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the reciprocal is, y = 1/x, is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxReduceL1#

class skl2onnx.algebra.onnx_ops.OnnxReduceL1(*args, **kwargs)#

Version

Onnx name: ReduceL1

This version of the operator has been available since version 18.

Summary

Computes the L1 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceL1_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceL1_1(*args, **kwargs)#

Version

Onnx name: ReduceL1

This version of the operator has been available since version 1.

Summary

Computes the L1 norm of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceL1_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceL1_11(*args, **kwargs)#

Version

Onnx name: ReduceL1

This version of the operator has been available since version 11.

Summary

Computes the L1 norm of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceL1_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceL1_13(*args, **kwargs)#

Version

Onnx name: ReduceL1

This version of the operator has been available since version 13.

Summary

Computes the L1 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceL1_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceL1_18(*args, **kwargs)#

Version

Onnx name: ReduceL1

This version of the operator has been available since version 18.

Summary

Computes the L1 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceL2#

class skl2onnx.algebra.onnx_ops.OnnxReduceL2(*args, **kwargs)#

Version

Onnx name: ReduceL2

This version of the operator has been available since version 18.

Summary

Computes the L2 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceL2_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceL2_1(*args, **kwargs)#

Version

Onnx name: ReduceL2

This version of the operator has been available since version 1.

Summary

Computes the L2 norm of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceL2_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceL2_11(*args, **kwargs)#

Version

Onnx name: ReduceL2

This version of the operator has been available since version 11.

Summary

Computes the L2 norm of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceL2_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceL2_13(*args, **kwargs)#

Version

Onnx name: ReduceL2

This version of the operator has been available since version 13.

Summary

Computes the L2 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceL2_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceL2_18(*args, **kwargs)#

Version

Onnx name: ReduceL2

This version of the operator has been available since version 18.

Summary

Computes the L2 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceLogSum#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSum(*args, **kwargs)#

Version

Onnx name: ReduceLogSum

This version of the operator has been available since version 18.

Summary

Computes the log sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceLogSumExp#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSumExp(*args, **kwargs)#

Version

Onnx name: ReduceLogSumExp

This version of the operator has been available since version 18.

Summary

Computes the log sum exponent of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceLogSumExp_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSumExp_1(*args, **kwargs)#

Version

Onnx name: ReduceLogSumExp

This version of the operator has been available since version 1.

Summary

Computes the log sum exponent of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceLogSumExp_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSumExp_11(*args, **kwargs)#

Version

Onnx name: ReduceLogSumExp

This version of the operator has been available since version 11.

Summary

Computes the log sum exponent of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceLogSumExp_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSumExp_13(*args, **kwargs)#

Version

Onnx name: ReduceLogSumExp

This version of the operator has been available since version 13.

Summary

Computes the log sum exponent of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceLogSumExp_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSumExp_18(*args, **kwargs)#

Version

Onnx name: ReduceLogSumExp

This version of the operator has been available since version 18.

Summary

Computes the log sum exponent of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceLogSum_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSum_1(*args, **kwargs)#

Version

Onnx name: ReduceLogSum

This version of the operator has been available since version 1.

Summary

Computes the log sum of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceLogSum_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSum_11(*args, **kwargs)#

Version

Onnx name: ReduceLogSum

This version of the operator has been available since version 11.

Summary

Computes the log sum of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceLogSum_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSum_13(*args, **kwargs)#

Version

Onnx name: ReduceLogSum

This version of the operator has been available since version 13.

Summary

Computes the log sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceLogSum_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceLogSum_18(*args, **kwargs)#

Version

Onnx name: ReduceLogSum

This version of the operator has been available since version 18.

Summary

Computes the log sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceMax#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 20.

Summary

Computes the max of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise.

If the input data type is Boolean, the comparison should consider False < True.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8), tensor(bool): Constrain input and output types to numeric and Boolean tensors.

OnnxReduceMax_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax_1(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 1.

Summary

Computes the max of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceMax_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax_11(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 11.

Summary

Computes the max of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceMax_12#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax_12(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 12.

Summary

Computes the max of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(uint8), tensor(int8): Constrain input and output types to high-precision and 8 bit numeric tensors.

OnnxReduceMax_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax_13(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 13.

Summary

Computes the max of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8): Constrain input and output types to numeric tensors.

OnnxReduceMax_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax_18(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 18.

Summary

Computes the max of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8): Constrain input and output types to numeric tensors.

OnnxReduceMax_20#

class skl2onnx.algebra.onnx_ops.OnnxReduceMax_20(*args, **kwargs)#

Version

Onnx name: ReduceMax

This version of the operator has been available since version 20.

Summary

Computes the max of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise.

If the input data type is Boolean, the comparison should consider False < True.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8), tensor(bool): Constrain input and output types to numeric and Boolean tensors.

OnnxReduceMean#

class skl2onnx.algebra.onnx_ops.OnnxReduceMean(*args, **kwargs)#

Version

Onnx name: ReduceMean

This version of the operator has been available since version 18.

Summary

Computes the mean of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields undefined.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceMean_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceMean_1(*args, **kwargs)#

Version

Onnx name: ReduceMean

This version of the operator has been available since version 1.

Summary

Computes the mean of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields undefined.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceMean_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceMean_11(*args, **kwargs)#

Version

Onnx name: ReduceMean

This version of the operator has been available since version 11.

Summary

Computes the mean of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceMean_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceMean_13(*args, **kwargs)#

Version

Onnx name: ReduceMean

This version of the operator has been available since version 13.

Summary

Computes the mean of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields undefined.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceMean_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceMean_18(*args, **kwargs)#

Version

Onnx name: ReduceMean

This version of the operator has been available since version 18.

Summary

Computes the mean of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields undefined.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceMin#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 20.

Summary

Computes the min of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise.

If the input data type is Boolean, the comparison should consider False < True.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8), tensor(bool): Constrain input and output types to numeric and Boolean tensors.

OnnxReduceMin_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin_1(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 1.

Summary

Computes the min of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceMin_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin_11(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 11.

Summary

Computes the min of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceMin_12#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin_12(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 12.

Summary

Computes the min of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(uint8), tensor(int8): Constrain input and output types to high-precision and 8 bit numeric tensors.

OnnxReduceMin_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin_13(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 13.

Summary

Computes the min of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8): Constrain input and output types to numeric tensors.

OnnxReduceMin_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin_18(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 18.

Summary

Computes the min of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8): Constrain input and output types to numeric tensors.

OnnxReduceMin_20#

class skl2onnx.algebra.onnx_ops.OnnxReduceMin_20(*args, **kwargs)#

Version

Onnx name: ReduceMin

This version of the operator has been available since version 20.

Summary

Computes the min of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise.

If the input data type is Boolean, the comparison should consider False < True.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(int8), tensor(bool): Constrain input and output types to numeric and Boolean tensors.

OnnxReduceProd#

class skl2onnx.algebra.onnx_ops.OnnxReduceProd(*args, **kwargs)#

Version

Onnx name: ReduceProd

This version of the operator has been available since version 18.

Summary

Computes the product of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 1.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceProd_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceProd_1(*args, **kwargs)#

Version

Onnx name: ReduceProd

This version of the operator has been available since version 1.

Summary

Computes the product of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 1.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceProd_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceProd_11(*args, **kwargs)#

Version

Onnx name: ReduceProd

This version of the operator has been available since version 11.

Summary

Computes the product of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceProd_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceProd_13(*args, **kwargs)#

Version

Onnx name: ReduceProd

This version of the operator has been available since version 13.

Summary

Computes the product of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 1.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceProd_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceProd_18(*args, **kwargs)#

Version

Onnx name: ReduceProd

This version of the operator has been available since version 18.

Summary

Computes the product of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 1.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceSum#

class skl2onnx.algebra.onnx_ops.OnnxReduceSum(*args, **kwargs)#

Version

Onnx name: ReduceSum

This version of the operator has been available since version 13.

Summary

Computes the sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceSumSquare#

class skl2onnx.algebra.onnx_ops.OnnxReduceSumSquare(*args, **kwargs)#

Version

Onnx name: ReduceSumSquare

This version of the operator has been available since version 18.

Summary

Computes the sum square of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceSumSquare_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceSumSquare_1(*args, **kwargs)#

Version

Onnx name: ReduceSumSquare

This version of the operator has been available since version 1.

Summary

Computes the sum square of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceSumSquare_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceSumSquare_11(*args, **kwargs)#

Version

Onnx name: ReduceSumSquare

This version of the operator has been available since version 11.

Summary

Computes the sum square of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceSumSquare_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceSumSquare_13(*args, **kwargs)#

Version

Onnx name: ReduceSumSquare

This version of the operator has been available since version 13.

Summary

Computes the sum square of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceSumSquare_18#

class skl2onnx.algebra.onnx_ops.OnnxReduceSumSquare_18(*args, **kwargs)#

Version

Onnx name: ReduceSumSquare

This version of the operator has been available since version 18.

Summary

Computes the sum square of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxReduceSum_1#

class skl2onnx.algebra.onnx_ops.OnnxReduceSum_1(*args, **kwargs)#

Version

Onnx name: ReduceSum

This version of the operator has been available since version 1.

Summary

Computes the sum of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceSum_11#

class skl2onnx.algebra.onnx_ops.OnnxReduceSum_11(*args, **kwargs)#

Version

Onnx name: ReduceSum

This version of the operator has been available since version 11.

Summary

Computes the sum of the input tensor’s element along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxReduceSum_13#

class skl2onnx.algebra.onnx_ops.OnnxReduceSum_13(*args, **kwargs)#

Version

Onnx name: ReduceSum

This version of the operator has been available since version 13.

Summary

Computes the sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

The above behavior is similar to numpy, with the exception that numpy defaults keepdims to False instead of True.

Attributes

  • keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. Default value is name: "keepdims" type: INT i: 1

  • noop_with_empty_axes: Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced,and the output tensor would be equivalent to input tensor. Default value is name: "noop_with_empty_axes" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: An input tensor.

  • axes (optional, heterogeneous)tensor(int64): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if ‘noop_with_empty_axes’ is false, else act as an Identity op when ‘noop_with_empty_axes’ is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (heterogeneous)T: Reduced output tensor.

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to numeric tensors.

OnnxRegexFullMatch#

class skl2onnx.algebra.onnx_ops.OnnxRegexFullMatch(*args, **kwargs)#

Version

Onnx name: RegexFullMatch

This version of the operator has been available since version 20.

Summary

RegexFullMatch performs a full regex match on each element of the input tensor. If an element fully matches the regex pattern specified as an attribute, the corresponding element in the output is True and it is False otherwise. [RE2](https://github.com/google/re2/wiki/Syntax) regex syntax is used.

Attributes

Inputs

  • X (heterogeneous)T1: Tensor with strings to match on.

Outputs

  • Y (heterogeneous)T2: Tensor of bools indicating if each input string fully matches the regex pattern specified.

Type Constraints

  • T1 tensor(string): Inputs must be UTF-8 strings

  • T2 tensor(bool): Outputs are bools and are True where there is a full regex match and False otherwise.

OnnxRegexFullMatch_20#

class skl2onnx.algebra.onnx_ops.OnnxRegexFullMatch_20(*args, **kwargs)#

Version

Onnx name: RegexFullMatch

This version of the operator has been available since version 20.

Summary

RegexFullMatch performs a full regex match on each element of the input tensor. If an element fully matches the regex pattern specified as an attribute, the corresponding element in the output is True and it is False otherwise. [RE2](https://github.com/google/re2/wiki/Syntax) regex syntax is used.

Attributes

Inputs

  • X (heterogeneous)T1: Tensor with strings to match on.

Outputs

  • Y (heterogeneous)T2: Tensor of bools indicating if each input string fully matches the regex pattern specified.

Type Constraints

  • T1 tensor(string): Inputs must be UTF-8 strings

  • T2 tensor(bool): Outputs are bools and are True where there is a full regex match and False otherwise.

OnnxRelu#

class skl2onnx.algebra.onnx_ops.OnnxRelu(*args, **kwargs)#

Version

Onnx name: Relu

This version of the operator has been available since version 14.

Summary

Relu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float), tensor(int32), tensor(int8), tensor(int16), tensor(int64), tensor(float16), tensor(double), tensor(bfloat16): Constrain input and output types to signed numeric tensors.

OnnxRelu_1#

class skl2onnx.algebra.onnx_ops.OnnxRelu_1(*args, **kwargs)#

Version

Onnx name: Relu

This version of the operator has been available since version 1.

Summary

Relu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxRelu_13#

class skl2onnx.algebra.onnx_ops.OnnxRelu_13(*args, **kwargs)#

Version

Onnx name: Relu

This version of the operator has been available since version 13.

Summary

Relu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxRelu_14#

class skl2onnx.algebra.onnx_ops.OnnxRelu_14(*args, **kwargs)#

Version

Onnx name: Relu

This version of the operator has been available since version 14.

Summary

Relu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float), tensor(int32), tensor(int8), tensor(int16), tensor(int64), tensor(float16), tensor(double), tensor(bfloat16): Constrain input and output types to signed numeric tensors.

OnnxRelu_6#

class skl2onnx.algebra.onnx_ops.OnnxRelu_6(*args, **kwargs)#

Version

Onnx name: Relu

This version of the operator has been available since version 6.

Summary

Relu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxReshape#

class skl2onnx.algebra.onnx_ops.OnnxReshape(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 21.

Summary

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). If ‘allowzero’ is set, and the new shape includes 0, the dimension will be set explicitly to zero (i.e. not taken from input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

If the attribute ‘allowzero’ is set, it is invalid for the specified shape to contain both a zero value and -1, as the value of the dimension corresponding to -1 cannot be determined uniquely.

Attributes

  • allowzero: (Optional) By default, when any value in the ‘shape’ input is equal to zero the corresponding dimension value is copied from the input tensor dynamically. allowzero=1 indicates that if any value in the ‘shape’ input is set to zero, the zero value is honored, similar to NumPy. Default value is name: "allowzero" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

  • shape (heterogeneous)tensor(int64): Specified shape for output.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types.

OnnxReshape_1#

class skl2onnx.algebra.onnx_ops.OnnxReshape_1(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 1.

Summary

Reshape the input tensor similar to numpy.reshape. It takes a tensor as input and an argument shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

Attributes

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxReshape_13#

class skl2onnx.algebra.onnx_ops.OnnxReshape_13(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 13.

Summary

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

Inputs

  • data (heterogeneous)T: An input tensor.

  • shape (heterogeneous)tensor(int64): Specified shape for output.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxReshape_14#

class skl2onnx.algebra.onnx_ops.OnnxReshape_14(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 14.

Summary

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). If ‘allowzero’ is set, and the new shape includes 0, the dimension will be set explicitly to zero (i.e. not taken from input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

If the attribute ‘allowzero’ is set, it is invalid for the specified shape to contain both a zero value and -1, as the value of the dimension corresponding to -1 cannot be determined uniquely.

Attributes

  • allowzero: (Optional) By default, when any value in the ‘shape’ input is equal to zero the corresponding dimension value is copied from the input tensor dynamically. allowzero=1 indicates that if any value in the ‘shape’ input is set to zero, the zero value is honored, similar to NumPy. Default value is name: "allowzero" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

  • shape (heterogeneous)tensor(int64): Specified shape for output.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxReshape_19#

class skl2onnx.algebra.onnx_ops.OnnxReshape_19(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 19.

Summary

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). If ‘allowzero’ is set, and the new shape includes 0, the dimension will be set explicitly to zero (i.e. not taken from input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

If the attribute ‘allowzero’ is set, it is invalid for the specified shape to contain both a zero value and -1, as the value of the dimension corresponding to -1 cannot be determined uniquely.

Attributes

  • allowzero: (Optional) By default, when any value in the ‘shape’ input is equal to zero the corresponding dimension value is copied from the input tensor dynamically. allowzero=1 indicates that if any value in the ‘shape’ input is set to zero, the zero value is honored, similar to NumPy. Default value is name: "allowzero" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

  • shape (heterogeneous)tensor(int64): Specified shape for output.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Constrain input and output types to all tensor types.

OnnxReshape_21#

class skl2onnx.algebra.onnx_ops.OnnxReshape_21(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 21.

Summary

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). If ‘allowzero’ is set, and the new shape includes 0, the dimension will be set explicitly to zero (i.e. not taken from input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

If the attribute ‘allowzero’ is set, it is invalid for the specified shape to contain both a zero value and -1, as the value of the dimension corresponding to -1 cannot be determined uniquely.

Attributes

  • allowzero: (Optional) By default, when any value in the ‘shape’ input is equal to zero the corresponding dimension value is copied from the input tensor dynamically. allowzero=1 indicates that if any value in the ‘shape’ input is set to zero, the zero value is honored, similar to NumPy. Default value is name: "allowzero" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

  • shape (heterogeneous)tensor(int64): Specified shape for output.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types.

OnnxReshape_5#

class skl2onnx.algebra.onnx_ops.OnnxReshape_5(*args, **kwargs)#

Version

Onnx name: Reshape

This version of the operator has been available since version 5.

Summary

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor). Shape (second input) could be an empty shape, which means converting to a scalar. The input tensor’s shape and the output tensor’s shape are required to have the same number of elements.

Inputs

  • data (heterogeneous)T: An input tensor.

  • shape (heterogeneous)tensor(int64): Specified shape for output.

Outputs

  • reshaped (heterogeneous)T: Reshaped data.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxResize#

class skl2onnx.algebra.onnx_ops.OnnxResize(*args, **kwargs)#

Version

Onnx name: Resize

This version of the operator has been available since version 19.

Summary

Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)

if input "sizes" is not specified.

Attributes

  • antialias: If set to 1, “linear” and “cubic” interpolation modes will use an antialiasing filter when downscaling. Antialiasing is achieved by stretching the resampling filter by a factor max(1, 1 / scale), which means that when downsampling, more input pixels contribute to an output pixel. Default value is name: "antialias" type: INT i: 0

  • coordinate_transformation_mode:

This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor.

The coordinate of each dimension is transformed individually. Let’s describe a case using axis x as an example. Denote x_resized as the coordinate of axis x in the resized tensor,

x_original as the coordinate of axis x in the original tensor, length_original as the length of the original tensor in axis x, length_resized as the length of the resized tensor in axis x, scale = length_resized / length_original, output_width the target length on the axis x which can be a fractional number when it is calculated out of a scale factor, and output_width_int the effective output width as an integer.

if coordinate_transformation_mode is “half_pixel”, ` x_original = (x_resized + 0.5) / scale - 0.5 `

if coordinate_transformation_mode is “half_pixel_symmetric”, ` adjustment = output_width_int / output_width center = input_width / 2 offset = center * (1 - adjustment) x_ori = offset + (x + 0.5) / scale - 0.5 `

if coordinate_transformation_mode is “pytorch_half_pixel”, ` x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 : 0 `

if coordinate_transformation_mode is “align_corners”, ` x_original = x_resized * (length_original - 1) / (length_resized - 1) `

if coordinate_transformation_mode is “asymmetric”, ` x_original = x_resized / scale `

if coordinate_transformation_mode is “tf_crop_and_resize”, ` x_original = length_resized > 1 ? start_x * (length_original - 1) + x_resized * (end_x - start_x) * (length_original - 1) / (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original - 1) ` . Default value is

name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • cubic_coeff_a: The coefficient ‘a’ used in cubic interpolation. Two common choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for the details. This attribute is valid only if mode is “cubic”. Default value is name: "cubic_coeff_a" type: FLOAT f: -0.75

  • exclude_outside: If set to 1, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0. The default value is 0. Default value is name: "exclude_outside" type: INT i: 0

  • extrapolation_value: When coordinate_transformation_mode is “tf_crop_and_resize” and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value. Default is 0.0f. Default value is name: "extrapolation_value" type: FLOAT f: 0

  • keep_aspect_ratio_policy:

This attribute describes how to interpret the sizes input with regard to keeping the original aspect ratio of the input, and it is not applicable when the scales input is used.

Given a set of sizes, associated with a subset of axes (explicitly provided or default), and assuming d = axes[i], with i being the index of the provided sizes.

If keep_aspect_ratio_policy is “stretch”, the original aspect ratio is disregarded, and the input is resized to the specified size: out_size[d] = sizes[i]

If keep_aspect_ratio_policy is “not_larger”, the sizes are adjusted so that no extent of the output is larger than the specified size, while keeping the original aspect ratio: ` scale = Min(sizes[i] / in_size[d]) out_size[d] = round_int(scale * in_size[i]) `

If keep_aspect_ratio_policy is “not_smaller”, the sizes are adjusted so that no extent of the output is smaller than the specified size, while keeping the original aspect ratio: ` scale = Max(sizes[i] / in_size[d]) out_size[d] = round_int(scale * in_size[i]) `

For non-resizable axes (those not specified in axes), the output size will be equal to the input size.

Note: round_int stands for computing the nearest integer value, rounding halfway cases up. Default value is

name: "keep_aspect_ratio_policy" type: STRING s: "stretch"

  • mode: Three interpolation modes: “nearest” (default), “linear” and “cubic”. The “linear” mode includes linear interpolation for 1D tensor and N-linear interpolation for N-D tensor (for example, bilinear interpolation for 2D tensor). The “cubic” mode includes cubic interpolation for 1D tensor and N-cubic interpolation for N-D tensor (for example, bicubic interpolation for 2D tensor). Default value is name: "mode" type: STRING s: "nearest"

  • nearest_mode: Four modes: “round_prefer_floor” (default, as known as round half down), “round_prefer_ceil” (as known as round half up), “floor”, “ceil”. Only used by nearest interpolation. It indicates how to get “nearest” pixel in input tensor from x_original, so this attribute is valid only if “mode” is “nearest”. Default value is name: "nearest_mode" type: STRING s: "round_prefer_floor"

Inputs

Between 1 and 4 inputs.

  • X (heterogeneous)T1: N-D tensor

  • roi (optional, heterogeneous)T2: 1-D tensor given as [start1, …, startN, end1, …, endN], where N is the rank of X or the length of axes, if provided. The RoIs’ coordinates are normalized in the coordinate system of the input image. It only takes effect when coordinate_transformation_mode is “tf_crop_and_resize”

  • scales (optional, heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’ or the length of ‘axes’, if provided. One of ‘scales’ and ‘sizes’ MUST be specified and it is an error if both are specified. If ‘sizes’ is needed, the user can use an empty string as the name of ‘scales’ in this operator’s input list.

  • sizes (optional, heterogeneous)tensor(int64): Target size of the output tensor. Its interpretation depends on the ‘keep_aspect_ratio_policy’ value.The number of elements of ‘sizes’ should be the same as the rank of input ‘X’, or the length of ‘axes’, if provided. Only one of ‘scales’ and ‘sizes’ can be specified.

Outputs

  • Y (heterogeneous)T1: N-D tensor after resizing

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain roi type to float or double.

OnnxResize_10#

class skl2onnx.algebra.onnx_ops.OnnxResize_10(*args, **kwargs)#

Version

Onnx name: Resize

This version of the operator has been available since version 10.

Summary

Resize the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * scale).

Attributes

  • mode: Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc) Default value is name: "mode" type: STRING s: "nearest"

Inputs

  • X (heterogeneous)T: N-D tensor

  • scales (heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’.

Outputs

  • Y (heterogeneous)T: N-D tensor after resizing

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

OnnxResize_11#

class skl2onnx.algebra.onnx_ops.OnnxResize_11(*args, **kwargs)#

Version

Onnx name: Resize

This version of the operator has been available since version 11.

Summary

Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) if input "sizes" is not specified.

Attributes

  • coordinate_transformation_mode:

This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor. <br/>

The coordinate of each dimension is transformed individually. Let’s describe a case using axis x as an example. Denote x_resized as the coordinate of axis x in the resized tensor, x_original as the coordinate of axis x in the original tensor, length_original as the length of the original tensor in axis x, length_resized as the length of the resized tensor in axis x, roi_x = (start_x, end_x) of the axis x in input “roi”, scale = length_resized / length_original, <br/>

if coordinate_transformation_mode is “half_pixel”, <br/> x_original = (x_resized + 0.5) / scale - 0.5, <br/>

if coordinate_transformation_mode is “pytorch_half_pixel”, <br/> x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 : 0, <br/>

if coordinate_transformation_mode is “align_corners”, <br/> x_original = x_resized * (length_original - 1) / (length_resized - 1), <br/>

if coordinate_transformation_mode is “asymmetric”, <br/> x_original = x_resized / scale, <br/>

if coordinate_transformation_mode is “tf_half_pixel_for_nn”, <br/> x_original = (x_resized + 0.5) / scale, <br/>

if coordinate_transformation_mode is “tf_crop_and_resize”, <br/> x_original = length_resized > 1 ? start_x * (length_original - 1) + x_resized * (end_x - start_x) * (length_original - 1) / (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original - 1). Default value is

name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • cubic_coeff_a: The coefficient ‘a’ used in cubic interpolation. Two common choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for the details. This attribute is valid only if “mode” is “cubic”. Default value is name: "cubic_coeff_a" type: FLOAT f: -0.75

  • exclude_outside: If set to 1, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0. The default value is 0. Default value is name: "exclude_outside" type: INT i: 0

  • extrapolation_value: When coordinate_transformation_mode is “tf_crop_and_resize” and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value. Default is 0.0f. Default value is name: "extrapolation_value" type: FLOAT f: 0

  • mode: Three interpolation modes: nearest (default), linear and cubic. The “linear” mode includes linear interpolation for 1D tensor and N-linear interpolation for N-D tensor (for example, bilinear interpolation for 2D tensor). The “cubic” mode includes cubic interpolation for 1D tensor and N-cubic interpolation for N-D tensor (for example, bicubic interpolation for 2D tensor). Default value is name: "mode" type: STRING s: "nearest"

  • nearest_mode: Four modes: round_prefer_floor (default, as known as round half down), round_prefer_ceil (as known as round half up), floor, ceil. Only used by nearest interpolation. It indicates how to get “nearest” pixel in input tensor from x_original, so this attribute is valid only if “mode” is “nearest”. Default value is name: "nearest_mode" type: STRING s: "round_prefer_floor"

Inputs

Between 3 and 4 inputs.

  • X (heterogeneous)T1: N-D tensor

  • roi (heterogeneous)T2: 1-D tensor given as [start1, …, startN, end1, …, endN], where N is the rank of X. The RoIs’ coordinates are normalized in the coordinate system of the input image. It only takes effect when coordinate_transformation_mode is “tf_crop_and_resize”

  • scales (heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’. If ‘size’ is needed, the user must set ‘scales’ to an empty tensor.

  • sizes (optional, heterogeneous)tensor(int64): The size of the output tensor. The number of elements of ‘sizes’ should be the same as the rank of input ‘X’. May only be set if ‘scales’ is set to an empty tensor.

Outputs

  • Y (heterogeneous)T1: N-D tensor after resizing

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain roi type to float or double.

OnnxResize_13#

class skl2onnx.algebra.onnx_ops.OnnxResize_13(*args, **kwargs)#

Version

Onnx name: Resize

This version of the operator has been available since version 13.

Summary

Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) if input "sizes" is not specified.

Attributes

  • coordinate_transformation_mode:

This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor. <br/>

The coordinate of each dimension is transformed individually. Let’s describe a case using axis x as an example. Denote x_resized as the coordinate of axis x in the resized tensor, x_original as the coordinate of axis x in the original tensor, length_original as the length of the original tensor in axis x, length_resized as the length of the resized tensor in axis x, roi_x = (start_x, end_x) of the axis x in input “roi”, scale = length_resized / length_original, <br/>

if coordinate_transformation_mode is “half_pixel”, <br/> x_original = (x_resized + 0.5) / scale - 0.5, <br/>

if coordinate_transformation_mode is “pytorch_half_pixel”, <br/> x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 : 0, <br/>

if coordinate_transformation_mode is “align_corners”, <br/> x_original = x_resized * (length_original - 1) / (length_resized - 1), <br/>

if coordinate_transformation_mode is “asymmetric”, <br/> x_original = x_resized / scale, <br/>

if coordinate_transformation_mode is “tf_crop_and_resize”, <br/> x_original = length_resized > 1 ? start_x * (length_original - 1) + x_resized * (end_x - start_x) * (length_original - 1) / (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original - 1). Default value is

name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • cubic_coeff_a: The coefficient ‘a’ used in cubic interpolation. Two common choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for the details. This attribute is valid only if “mode” is “cubic”. Default value is name: "cubic_coeff_a" type: FLOAT f: -0.75

  • exclude_outside: If set to 1, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0. The default value is 0. Default value is name: "exclude_outside" type: INT i: 0

  • extrapolation_value: When coordinate_transformation_mode is “tf_crop_and_resize” and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value. Default is 0.0f. Default value is name: "extrapolation_value" type: FLOAT f: 0

  • mode: Three interpolation modes: nearest (default), linear and cubic. The “linear” mode includes linear interpolation for 1D tensor and N-linear interpolation for N-D tensor (for example, bilinear interpolation for 2D tensor). The “cubic” mode includes cubic interpolation for 1D tensor and N-cubic interpolation for N-D tensor (for example, bicubic interpolation for 2D tensor). Default value is name: "mode" type: STRING s: "nearest"

  • nearest_mode: Four modes: round_prefer_floor (default, as known as round half down), round_prefer_ceil (as known as round half up), floor, ceil. Only used by nearest interpolation. It indicates how to get “nearest” pixel in input tensor from x_original, so this attribute is valid only if “mode” is “nearest”. Default value is name: "nearest_mode" type: STRING s: "round_prefer_floor"

Inputs

Between 1 and 4 inputs.

  • X (heterogeneous)T1: N-D tensor

  • roi (optional, heterogeneous)T2: 1-D tensor given as [start1, …, startN, end1, …, endN], where N is the rank of X. The RoIs’ coordinates are normalized in the coordinate system of the input image. It only takes effect when coordinate_transformation_mode is “tf_crop_and_resize”

  • scales (optional, heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’. One of ‘scales’ and ‘sizes’ MUST be specified and it is an error if both are specified. If ‘sizes’ is needed, the user can use an empty string as the name of ‘scales’ in this operator’s input list.

  • sizes (optional, heterogeneous)tensor(int64): The size of the output tensor. The number of elements of ‘sizes’ should be the same as the rank of input ‘X’. Only one of ‘scales’ and ‘sizes’ can be specified.

Outputs

  • Y (heterogeneous)T1: N-D tensor after resizing

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain roi type to float or double.

OnnxResize_18#

class skl2onnx.algebra.onnx_ops.OnnxResize_18(*args, **kwargs)#

Version

Onnx name: Resize

This version of the operator has been available since version 18.

Summary

Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor. Each dimension value of the output tensor is: <br/>

output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) <br/>

if input "sizes" is not specified.

Attributes

  • antialias: If set to 1, “linear” and “cubic” interpolation modes will use an antialiasing filter when downscaling. Antialiasing is achieved by stretching the resampling filter by a factor max(1, 1 / scale), which means that when downsampling, more input pixels contribute to an output pixel. Default value is name: "antialias" type: INT i: 0

  • coordinate_transformation_mode:

This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor. <br/>

The coordinate of each dimension is transformed individually. Let’s describe a case using axis x as an example. Denote x_resized as the coordinate of axis x in the resized tensor, x_original as the coordinate of axis x in the original tensor, length_original as the length of the original tensor in axis x, length_resized as the length of the resized tensor in axis x, roi_x = (start_x, end_x) of the axis x in input “roi”, scale = length_resized / length_original, <br/>

if coordinate_transformation_mode is “half_pixel”, <br/> x_original = (x_resized + 0.5) / scale - 0.5 <br/>

if coordinate_transformation_mode is “pytorch_half_pixel”, <br/> x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 : 0 <br/>

if coordinate_transformation_mode is “align_corners”, <br/> x_original = x_resized * (length_original - 1) / (length_resized - 1) <br/>

if coordinate_transformation_mode is “asymmetric”, <br/> x_original = x_resized / scale <br/>

if coordinate_transformation_mode is “tf_crop_and_resize”, <br/> x_original = length_resized > 1 ? start_x * (length_original - 1) + x_resized * (end_x - start_x) * (length_original - 1) / (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original - 1) . Default value is

name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • cubic_coeff_a: The coefficient ‘a’ used in cubic interpolation. Two common choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for the details. This attribute is valid only if mode is “cubic”. Default value is name: "cubic_coeff_a" type: FLOAT f: -0.75

  • exclude_outside: If set to 1, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0. The default value is 0. Default value is name: "exclude_outside" type: INT i: 0

  • extrapolation_value: When coordinate_transformation_mode is “tf_crop_and_resize” and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value. Default is 0.0f. Default value is name: "extrapolation_value" type: FLOAT f: 0

  • keep_aspect_ratio_policy:

This attribute describes how to interpret the sizes input with regard to keeping the original aspect ratio of the input, and it is not applicable when the scales input is used. <br/>

Given a set of sizes, associated with a subset of axes (explicitly provided or default), and assuming d = axes[i], with i being the index of the provided sizes. <br/>

If keep_aspect_ratio_policy is “stretch”, the original aspect ratio is disregarded, and the input is resized to the specified size: <br/> out_size[d] = sizes[i] <br/>

If keep_aspect_ratio_policy is “not_larger”, the sizes are adjusted so that no extent of the output is larger than the specified size, while keeping the original aspect ratio: <br/> scale = Min(sizes[i] / in_size[d]) <br/> out_size[d] = round_int(scale * in_size[i]) <br/>

If keep_aspect_ratio_policy is “not_smaller”, the sizes are adjusted so that no extent of the output is smaller than the specified size, while keeping the original aspect ratio: <br/> scale = Max(sizes[i] / in_size[d]) <br/> out_size[d] = round_int(scale * in_size[i]) <br/>

For non-resizable axes (those not specified in axes), the output size will be equal to the input size.

Note: round_int stands for computing the nearest integer value, rounding halfway cases up. Default value is

name: "keep_aspect_ratio_policy" type: STRING s: "stretch"

  • mode: Three interpolation modes: “nearest” (default), “linear” and “cubic”. The “linear” mode includes linear interpolation for 1D tensor and N-linear interpolation for N-D tensor (for example, bilinear interpolation for 2D tensor). The “cubic” mode includes cubic interpolation for 1D tensor and N-cubic interpolation for N-D tensor (for example, bicubic interpolation for 2D tensor). Default value is name: "mode" type: STRING s: "nearest"

  • nearest_mode: Four modes: “round_prefer_floor” (default, as known as round half down), “round_prefer_ceil” (as known as round half up), “floor”, “ceil”. Only used by nearest interpolation. It indicates how to get “nearest” pixel in input tensor from x_original, so this attribute is valid only if “mode” is “nearest”. Default value is name: "nearest_mode" type: STRING s: "round_prefer_floor"

Inputs

Between 1 and 4 inputs.

  • X (heterogeneous)T1: N-D tensor

  • roi (optional, heterogeneous)T2: 1-D tensor given as [start1, …, startN, end1, …, endN], where N is the rank of X or the length of axes, if provided. The RoIs’ coordinates are normalized in the coordinate system of the input image. It only takes effect when coordinate_transformation_mode is “tf_crop_and_resize”

  • scales (optional, heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’ or the length of ‘axes’, if provided. One of ‘scales’ and ‘sizes’ MUST be specified and it is an error if both are specified. If ‘sizes’ is needed, the user can use an empty string as the name of ‘scales’ in this operator’s input list.

  • sizes (optional, heterogeneous)tensor(int64): Target size of the output tensor. Its interpretation depends on the ‘keep_aspect_ratio_policy’ value.The number of elements of ‘sizes’ should be the same as the rank of input ‘X’, or the length of ‘axes’, if provided. Only one of ‘scales’ and ‘sizes’ can be specified.

Outputs

  • Y (heterogeneous)T1: N-D tensor after resizing

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain roi type to float or double.

OnnxResize_19#

class skl2onnx.algebra.onnx_ops.OnnxResize_19(*args, **kwargs)#

Version

Onnx name: Resize

This version of the operator has been available since version 19.

Summary

Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)

if input "sizes" is not specified.

Attributes

  • antialias: If set to 1, “linear” and “cubic” interpolation modes will use an antialiasing filter when downscaling. Antialiasing is achieved by stretching the resampling filter by a factor max(1, 1 / scale), which means that when downsampling, more input pixels contribute to an output pixel. Default value is name: "antialias" type: INT i: 0

  • coordinate_transformation_mode:

This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor.

The coordinate of each dimension is transformed individually. Let’s describe a case using axis x as an example. Denote x_resized as the coordinate of axis x in the resized tensor,

x_original as the coordinate of axis x in the original tensor, length_original as the length of the original tensor in axis x, length_resized as the length of the resized tensor in axis x, scale = length_resized / length_original, output_width the target length on the axis x which can be a fractional number when it is calculated out of a scale factor, and output_width_int the effective output width as an integer.

if coordinate_transformation_mode is “half_pixel”, ` x_original = (x_resized + 0.5) / scale - 0.5 `

if coordinate_transformation_mode is “half_pixel_symmetric”, ` adjustment = output_width_int / output_width center = input_width / 2 offset = center * (1 - adjustment) x_ori = offset + (x + 0.5) / scale - 0.5 `

if coordinate_transformation_mode is “pytorch_half_pixel”, ` x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 : 0 `

if coordinate_transformation_mode is “align_corners”, ` x_original = x_resized * (length_original - 1) / (length_resized - 1) `

if coordinate_transformation_mode is “asymmetric”, ` x_original = x_resized / scale `

if coordinate_transformation_mode is “tf_crop_and_resize”, ` x_original = length_resized > 1 ? start_x * (length_original - 1) + x_resized * (end_x - start_x) * (length_original - 1) / (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original - 1) ` . Default value is

name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • cubic_coeff_a: The coefficient ‘a’ used in cubic interpolation. Two common choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for the details. This attribute is valid only if mode is “cubic”. Default value is name: "cubic_coeff_a" type: FLOAT f: -0.75

  • exclude_outside: If set to 1, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0. The default value is 0. Default value is name: "exclude_outside" type: INT i: 0

  • extrapolation_value: When coordinate_transformation_mode is “tf_crop_and_resize” and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value. Default is 0.0f. Default value is name: "extrapolation_value" type: FLOAT f: 0

  • keep_aspect_ratio_policy:

This attribute describes how to interpret the sizes input with regard to keeping the original aspect ratio of the input, and it is not applicable when the scales input is used.

Given a set of sizes, associated with a subset of axes (explicitly provided or default), and assuming d = axes[i], with i being the index of the provided sizes.

If keep_aspect_ratio_policy is “stretch”, the original aspect ratio is disregarded, and the input is resized to the specified size: out_size[d] = sizes[i]

If keep_aspect_ratio_policy is “not_larger”, the sizes are adjusted so that no extent of the output is larger than the specified size, while keeping the original aspect ratio: ` scale = Min(sizes[i] / in_size[d]) out_size[d] = round_int(scale * in_size[i]) `

If keep_aspect_ratio_policy is “not_smaller”, the sizes are adjusted so that no extent of the output is smaller than the specified size, while keeping the original aspect ratio: ` scale = Max(sizes[i] / in_size[d]) out_size[d] = round_int(scale * in_size[i]) `

For non-resizable axes (those not specified in axes), the output size will be equal to the input size.

Note: round_int stands for computing the nearest integer value, rounding halfway cases up. Default value is

name: "keep_aspect_ratio_policy" type: STRING s: "stretch"

  • mode: Three interpolation modes: “nearest” (default), “linear” and “cubic”. The “linear” mode includes linear interpolation for 1D tensor and N-linear interpolation for N-D tensor (for example, bilinear interpolation for 2D tensor). The “cubic” mode includes cubic interpolation for 1D tensor and N-cubic interpolation for N-D tensor (for example, bicubic interpolation for 2D tensor). Default value is name: "mode" type: STRING s: "nearest"

  • nearest_mode: Four modes: “round_prefer_floor” (default, as known as round half down), “round_prefer_ceil” (as known as round half up), “floor”, “ceil”. Only used by nearest interpolation. It indicates how to get “nearest” pixel in input tensor from x_original, so this attribute is valid only if “mode” is “nearest”. Default value is name: "nearest_mode" type: STRING s: "round_prefer_floor"

Inputs

Between 1 and 4 inputs.

  • X (heterogeneous)T1: N-D tensor

  • roi (optional, heterogeneous)T2: 1-D tensor given as [start1, …, startN, end1, …, endN], where N is the rank of X or the length of axes, if provided. The RoIs’ coordinates are normalized in the coordinate system of the input image. It only takes effect when coordinate_transformation_mode is “tf_crop_and_resize”

  • scales (optional, heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’ or the length of ‘axes’, if provided. One of ‘scales’ and ‘sizes’ MUST be specified and it is an error if both are specified. If ‘sizes’ is needed, the user can use an empty string as the name of ‘scales’ in this operator’s input list.

  • sizes (optional, heterogeneous)tensor(int64): Target size of the output tensor. Its interpretation depends on the ‘keep_aspect_ratio_policy’ value.The number of elements of ‘sizes’ should be the same as the rank of input ‘X’, or the length of ‘axes’, if provided. Only one of ‘scales’ and ‘sizes’ can be specified.

Outputs

  • Y (heterogeneous)T1: N-D tensor after resizing

Type Constraints

  • T1 tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

  • T2 tensor(float16), tensor(float), tensor(double): Constrain roi type to float or double.

OnnxReverseSequence#

class skl2onnx.algebra.onnx_ops.OnnxReverseSequence(*args, **kwargs)#

Version

Onnx name: ReverseSequence

This version of the operator has been available since version 10.

Summary

Reverse batch of sequences having different lengths specified by sequence_lens.

For each slice i iterating on batch axis, the operator reverses the first sequence_lens[i] elements on time axis, and copies elements whose index’s beyond sequence_lens[i] to the output. So the output slice i contains reversed sequences on the first sequence_lens[i] elements, then have original values copied for the other elements.

Example 1:
input = [[0.0, 4.0, 8.0, 12.0],

[1.0, 5.0, 9.0, 13.0], [2.0, 6.0, 10.0, 14.0], [3.0, 7.0, 11.0, 15.0]]

sequence_lens = [4, 3, 2, 1] time_axis = 0 batch_axis = 1

output = [[3.0, 6.0, 9.0, 12.0],

[2.0, 5.0, 8.0, 13.0], [1.0, 4.0, 10.0, 14.0], [0.0, 7.0, 11.0, 15.0]]

Example 2:
input = [[0.0, 1.0, 2.0, 3.0 ],

[4.0, 5.0, 6.0, 7.0 ], [8.0, 9.0, 10.0, 11.0], [12.0, 13.0, 14.0, 15.0]]

sequence_lens = [1, 2, 3, 4] time_axis = 1 batch_axis = 0

output = [[0.0, 1.0, 2.0, 3.0 ],

[5.0, 4.0, 6.0, 7.0 ], [10.0, 9.0, 8.0, 11.0], [15.0, 14.0, 13.0, 12.0]]

Attributes

  • batch_axis: (Optional) Specify which axis is batch axis. Must be one of 1 (default), or 0. Default value is name: "batch_axis" type: INT i: 1

  • time_axis: (Optional) Specify which axis is time axis. Must be one of 0 (default), or 1. Default value is name: "time_axis" type: INT i: 0

Inputs

  • input (heterogeneous)T: Tensor of rank r >= 2.

  • sequence_lens (heterogeneous)tensor(int64): Tensor specifying lengths of the sequences in a batch. It has shape [batch_size].

Outputs

  • Y (heterogeneous)T: Tensor with same shape of input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

OnnxReverseSequence_10#

class skl2onnx.algebra.onnx_ops.OnnxReverseSequence_10(*args, **kwargs)#

Version

Onnx name: ReverseSequence

This version of the operator has been available since version 10.

Summary

Reverse batch of sequences having different lengths specified by sequence_lens.

For each slice i iterating on batch axis, the operator reverses the first sequence_lens[i] elements on time axis, and copies elements whose index’s beyond sequence_lens[i] to the output. So the output slice i contains reversed sequences on the first sequence_lens[i] elements, then have original values copied for the other elements.

Example 1:
input = [[0.0, 4.0, 8.0, 12.0],

[1.0, 5.0, 9.0, 13.0], [2.0, 6.0, 10.0, 14.0], [3.0, 7.0, 11.0, 15.0]]

sequence_lens = [4, 3, 2, 1] time_axis = 0 batch_axis = 1

output = [[3.0, 6.0, 9.0, 12.0],

[2.0, 5.0, 8.0, 13.0], [1.0, 4.0, 10.0, 14.0], [0.0, 7.0, 11.0, 15.0]]

Example 2:
input = [[0.0, 1.0, 2.0, 3.0 ],

[4.0, 5.0, 6.0, 7.0 ], [8.0, 9.0, 10.0, 11.0], [12.0, 13.0, 14.0, 15.0]]

sequence_lens = [1, 2, 3, 4] time_axis = 1 batch_axis = 0

output = [[0.0, 1.0, 2.0, 3.0 ],

[5.0, 4.0, 6.0, 7.0 ], [10.0, 9.0, 8.0, 11.0], [15.0, 14.0, 13.0, 12.0]]

Attributes

  • batch_axis: (Optional) Specify which axis is batch axis. Must be one of 1 (default), or 0. Default value is name: "batch_axis" type: INT i: 1

  • time_axis: (Optional) Specify which axis is time axis. Must be one of 0 (default), or 1. Default value is name: "time_axis" type: INT i: 0

Inputs

  • input (heterogeneous)T: Tensor of rank r >= 2.

  • sequence_lens (heterogeneous)tensor(int64): Tensor specifying lengths of the sequences in a batch. It has shape [batch_size].

Outputs

  • Y (heterogeneous)T: Tensor with same shape of input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

OnnxRoiAlign#

class skl2onnx.algebra.onnx_ops.OnnxRoiAlign(*args, **kwargs)#

Version

Onnx name: RoiAlign

This version of the operator has been available since version 16.

Summary

Region of Interest (RoI) align operation described in the [Mask R-CNN paper](https://arxiv.org/abs/1703.06870). RoiAlign consumes an input tensor X and region of interests (rois) to apply pooling across each RoI; it produces a 4-D tensor of shape (num_rois, C, output_height, output_width).

RoiAlign is proposed to avoid the misalignment by removing quantizations while converting from original image into feature map and from feature map into RoI feature; in each ROI bin, the value of the sampled locations are computed directly through bilinear interpolation.

Attributes

  • coordinate_transformation_mode: Allowed values are ‘half_pixel’ and ‘output_half_pixel’. Use the value ‘half_pixel’ to pixel shift the input coordinates by -0.5 (the recommended behavior). Use the value ‘output_half_pixel’ to omit the pixel shift for the input (use this for a backward-compatible behavior). Default value is name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • mode: The pooling method. Two modes are supported: ‘avg’ and ‘max’. Default is ‘avg’. Default value is name: "mode" type: STRING s: "avg"

  • output_height: default 1; Pooled output Y’s height. Default value is name: "output_height" type: INT i: 1

  • output_width: default 1; Pooled output Y’s width. Default value is name: "output_width" type: INT i: 1

  • sampling_ratio: Number of sampling points in the interpolation grid used to compute the output value of each pooled output bin. If > 0, then exactly sampling_ratio x sampling_ratio grid points are used. If == 0, then an adaptive number of grid points are used (computed as ceil(roi_width / output_width), and likewise for height). Default is 0. Default value is name: "sampling_ratio" type: INT i: 0

  • spatial_scale: Multiplicative spatial scale factor to translate ROI coordinates from their input spatial scale to the scale used when pooling, i.e., spatial scale of the input feature map X relative to the input image. E.g.; default is 1.0f. Default value is name: "spatial_scale" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T1: Input data tensor from the previous operator; 4-D feature map of shape (N, C, H, W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.

  • rois (heterogeneous)T1: RoIs (Regions of Interest) to pool over; rois is 2-D input of shape (num_rois, 4) given as [[x1, y1, x2, y2], …]. The RoIs’ coordinates are in the coordinate system of the input image. Each coordinate set has a 1:1 correspondence with the ‘batch_indices’ input.

  • batch_indices (heterogeneous)T2: 1-D tensor of shape (num_rois,) with each element denoting the index of the corresponding image in the batch.

Outputs

  • Y (heterogeneous)T1: RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element Y[r-1] is a pooled feature map corresponding to the r-th RoI X[r-1].

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain types to float tensors.

  • T2 tensor(int64): Constrain types to int tensors.

OnnxRoiAlign_10#

class skl2onnx.algebra.onnx_ops.OnnxRoiAlign_10(*args, **kwargs)#

Version

Onnx name: RoiAlign

This version of the operator has been available since version 10.

Summary

Region of Interest (RoI) align operation described in the [Mask R-CNN paper](https://arxiv.org/abs/1703.06870). RoiAlign consumes an input tensor X and region of interests (rois) to apply pooling across each RoI; it produces a 4-D tensor of shape (num_rois, C, output_height, output_width).

RoiAlign is proposed to avoid the misalignment by removing quantizations while converting from original image into feature map and from feature map into RoI feature; in each ROI bin, the value of the sampled locations are computed directly through bilinear interpolation.

Attributes

  • mode: The pooling method. Two modes are supported: ‘avg’ and ‘max’. Default is ‘avg’. Default value is name: "mode" type: STRING s: "avg"

  • output_height: default 1; Pooled output Y’s height. Default value is name: "output_height" type: INT i: 1

  • output_width: default 1; Pooled output Y’s width. Default value is name: "output_width" type: INT i: 1

  • sampling_ratio: Number of sampling points in the interpolation grid used to compute the output value of each pooled output bin. If > 0, then exactly sampling_ratio x sampling_ratio grid points are used. If == 0, then an adaptive number of grid points are used (computed as ceil(roi_width / output_width), and likewise for height). Default is 0. Default value is name: "sampling_ratio" type: INT i: 0

  • spatial_scale: Multiplicative spatial scale factor to translate ROI coordinates from their input spatial scale to the scale used when pooling, i.e., spatial scale of the input feature map X relative to the input image. E.g.; default is 1.0f. Default value is name: "spatial_scale" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T1: Input data tensor from the previous operator; 4-D feature map of shape (N, C, H, W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.

  • rois (heterogeneous)T1: RoIs (Regions of Interest) to pool over; rois is 2-D input of shape (num_rois, 4) given as [[x1, y1, x2, y2], …]. The RoIs’ coordinates are in the coordinate system of the input image. Each coordinate set has a 1:1 correspondence with the ‘batch_indices’ input.

  • batch_indices (heterogeneous)T2: 1-D tensor of shape (num_rois,) with each element denoting the index of the corresponding image in the batch.

Outputs

  • Y (heterogeneous)T1: RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element Y[r-1] is a pooled feature map corresponding to the r-th RoI X[r-1].

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain types to float tensors.

  • T2 tensor(int64): Constrain types to int tensors.

OnnxRoiAlign_16#

class skl2onnx.algebra.onnx_ops.OnnxRoiAlign_16(*args, **kwargs)#

Version

Onnx name: RoiAlign

This version of the operator has been available since version 16.

Summary

Region of Interest (RoI) align operation described in the [Mask R-CNN paper](https://arxiv.org/abs/1703.06870). RoiAlign consumes an input tensor X and region of interests (rois) to apply pooling across each RoI; it produces a 4-D tensor of shape (num_rois, C, output_height, output_width).

RoiAlign is proposed to avoid the misalignment by removing quantizations while converting from original image into feature map and from feature map into RoI feature; in each ROI bin, the value of the sampled locations are computed directly through bilinear interpolation.

Attributes

  • coordinate_transformation_mode: Allowed values are ‘half_pixel’ and ‘output_half_pixel’. Use the value ‘half_pixel’ to pixel shift the input coordinates by -0.5 (the recommended behavior). Use the value ‘output_half_pixel’ to omit the pixel shift for the input (use this for a backward-compatible behavior). Default value is name: "coordinate_transformation_mode" type: STRING s: "half_pixel"

  • mode: The pooling method. Two modes are supported: ‘avg’ and ‘max’. Default is ‘avg’. Default value is name: "mode" type: STRING s: "avg"

  • output_height: default 1; Pooled output Y’s height. Default value is name: "output_height" type: INT i: 1

  • output_width: default 1; Pooled output Y’s width. Default value is name: "output_width" type: INT i: 1

  • sampling_ratio: Number of sampling points in the interpolation grid used to compute the output value of each pooled output bin. If > 0, then exactly sampling_ratio x sampling_ratio grid points are used. If == 0, then an adaptive number of grid points are used (computed as ceil(roi_width / output_width), and likewise for height). Default is 0. Default value is name: "sampling_ratio" type: INT i: 0

  • spatial_scale: Multiplicative spatial scale factor to translate ROI coordinates from their input spatial scale to the scale used when pooling, i.e., spatial scale of the input feature map X relative to the input image. E.g.; default is 1.0f. Default value is name: "spatial_scale" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T1: Input data tensor from the previous operator; 4-D feature map of shape (N, C, H, W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.

  • rois (heterogeneous)T1: RoIs (Regions of Interest) to pool over; rois is 2-D input of shape (num_rois, 4) given as [[x1, y1, x2, y2], …]. The RoIs’ coordinates are in the coordinate system of the input image. Each coordinate set has a 1:1 correspondence with the ‘batch_indices’ input.

  • batch_indices (heterogeneous)T2: 1-D tensor of shape (num_rois,) with each element denoting the index of the corresponding image in the batch.

Outputs

  • Y (heterogeneous)T1: RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element Y[r-1] is a pooled feature map corresponding to the r-th RoI X[r-1].

Type Constraints

  • T1 tensor(float16), tensor(float), tensor(double): Constrain types to float tensors.

  • T2 tensor(int64): Constrain types to int tensors.

OnnxRound#

class skl2onnx.algebra.onnx_ops.OnnxRound(*args, **kwargs)#

Version

Onnx name: Round

This version of the operator has been available since version 11.

Summary

Round takes one input Tensor and rounds the values, element-wise, meaning it finds the nearest integer for each value. In case of halves, the rule is to round them to the nearest even integer. If input x is integral, +0, -0, NaN, or infinite, x itself is returned. The output tensor has the same shape and type as the input.

Examples:

round([0.9]) = [1.0]
round([2.5]) = [2.0]
round([2.3]) = [2.0]
round([1.5]) = [2.0]
round([-4.5]) = [-4.0]

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxRound_11#

class skl2onnx.algebra.onnx_ops.OnnxRound_11(*args, **kwargs)#

Version

Onnx name: Round

This version of the operator has been available since version 11.

Summary

Round takes one input Tensor and rounds the values, element-wise, meaning it finds the nearest integer for each value. In case of halves, the rule is to round them to the nearest even integer. If input x is integral, +0, -0, NaN, or infinite, x itself is returned. The output tensor has the same shape and type as the input.

Examples:

round([0.9]) = [1.0]
round([2.5]) = [2.0]
round([2.3]) = [2.0]
round([1.5]) = [2.0]
round([-4.5]) = [-4.0]

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSTFT#

class skl2onnx.algebra.onnx_ops.OnnxSTFT(*args, **kwargs)#

Version

Onnx name: STFT

This version of the operator has been available since version 17.

Summary

Computes the Short-time Fourier Transform of the signal.

Attributes

  • onesided: If onesided is 1, only values for w in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, w] = X[m,w]=X[m,n_fft-w]*. Note if the input or window tensors are complex, then onesided output is not possible. Enabling onesided with real inputs performs a Real-valued fast Fourier transform (RFFT).When invoked with real or complex valued input, the default value is 1. Values can be 0 or 1. Default value is name: "onesided" type: INT i: 1

Inputs

Between 2 and 4 inputs.

  • signal (heterogeneous)T1: Input tensor representing a real or complex valued signal. For real input, the following shape is expected: [batch_size][signal_length][1]. For complex input, the following shape is expected: [batch_size][signal_length][2], where [batch_size][signal_length][0] represents the real component and [batch_size][signal_length][1] represents the imaginary component of the signal.

  • frame_step (heterogeneous)T2: The number of samples to step between successive DFTs.

  • window (optional, heterogeneous)T1: A tensor representing the window that will be slid over the signal.The window must have rank 1 with shape: [window_shape]. It’s an optional value.

  • frame_length (optional, heterogeneous)T2: A scalar representing the size of the DFT. It’s an optional value.

Outputs

  • output (heterogeneous)T1: The Short-time Fourier Transform of the signals.If onesided is 1, the output has the shape: [batch_size][frames][dft_unique_bins][2], where dft_unique_bins is frame_length // 2 + 1 (the unique components of the DFT) If onesided is 0, the output has the shape: [batch_size][frames][frame_length][2], where frame_length is the length of the DFT.

Type Constraints

  • T1 tensor(float), tensor(float16), tensor(double), tensor(bfloat16): Constrain signal and output to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain scalar length types to int64_t.

OnnxSTFT_17#

class skl2onnx.algebra.onnx_ops.OnnxSTFT_17(*args, **kwargs)#

Version

Onnx name: STFT

This version of the operator has been available since version 17.

Summary

Computes the Short-time Fourier Transform of the signal.

Attributes

  • onesided: If onesided is 1, only values for w in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, w] = X[m,w]=X[m,n_fft-w]*. Note if the input or window tensors are complex, then onesided output is not possible. Enabling onesided with real inputs performs a Real-valued fast Fourier transform (RFFT).When invoked with real or complex valued input, the default value is 1. Values can be 0 or 1. Default value is name: "onesided" type: INT i: 1

Inputs

Between 2 and 4 inputs.

  • signal (heterogeneous)T1: Input tensor representing a real or complex valued signal. For real input, the following shape is expected: [batch_size][signal_length][1]. For complex input, the following shape is expected: [batch_size][signal_length][2], where [batch_size][signal_length][0] represents the real component and [batch_size][signal_length][1] represents the imaginary component of the signal.

  • frame_step (heterogeneous)T2: The number of samples to step between successive DFTs.

  • window (optional, heterogeneous)T1: A tensor representing the window that will be slid over the signal.The window must have rank 1 with shape: [window_shape]. It’s an optional value.

  • frame_length (optional, heterogeneous)T2: A scalar representing the size of the DFT. It’s an optional value.

Outputs

  • output (heterogeneous)T1: The Short-time Fourier Transform of the signals.If onesided is 1, the output has the shape: [batch_size][frames][dft_unique_bins][2], where dft_unique_bins is frame_length // 2 + 1 (the unique components of the DFT) If onesided is 0, the output has the shape: [batch_size][frames][frame_length][2], where frame_length is the length of the DFT.

Type Constraints

  • T1 tensor(float), tensor(float16), tensor(double), tensor(bfloat16): Constrain signal and output to float tensors.

  • T2 tensor(int32), tensor(int64): Constrain scalar length types to int64_t.

OnnxSVMClassifier#

class skl2onnx.algebra.onnx_ops.OnnxSVMClassifier(*args, **kwargs)#

Version

Onnx name: SVMClassifier

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Support Vector Machine classifier

Attributes

  • kernel_type: The kernel type, one of ‘LINEAR,’ ‘POLY,’ ‘RBF,’ ‘SIGMOID’. Default value is name: "kernel_type" type: STRING s: "LINEAR"

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Data to be classified.

Outputs

  • Y (heterogeneous)T2: Classification outputs (one class per example).

  • Z (heterogeneous)tensor(float): Class scores (one per class per example), if prob_a and prob_b are provided they are probabilities for each class, otherwise they are raw scores.

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type, either [C] or [N,C].

  • T2 tensor(string), tensor(int64): The output type will be a tensor of strings or integers, depending on which of the classlabels_* attributes is used. Its size will match the bactch size of the input.

OnnxSVMClassifier_1#

class skl2onnx.algebra.onnx_ops.OnnxSVMClassifier_1(*args, **kwargs)#

Version

Onnx name: SVMClassifier

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Support Vector Machine classifier

Attributes

  • kernel_type: The kernel type, one of ‘LINEAR,’ ‘POLY,’ ‘RBF,’ ‘SIGMOID’. Default value is name: "kernel_type" type: STRING s: "LINEAR"

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Data to be classified.

Outputs

  • Y (heterogeneous)T2: Classification outputs (one class per example).

  • Z (heterogeneous)tensor(float): Class scores (one per class per example), if prob_a and prob_b are provided they are probabilities for each class, otherwise they are raw scores.

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type, either [C] or [N,C].

  • T2 tensor(string), tensor(int64): The output type will be a tensor of strings or integers, depending on which of the classlabels_* attributes is used. Its size will match the bactch size of the input.

OnnxSVMRegressor#

class skl2onnx.algebra.onnx_ops.OnnxSVMRegressor(*args, **kwargs)#

Version

Onnx name: SVMRegressor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Support Vector Machine regression prediction and one-class SVM anomaly detection.

Attributes

  • kernel_type: The kernel type, one of ‘LINEAR,’ ‘POLY,’ ‘RBF,’ ‘SIGMOID’. Default value is name: "kernel_type" type: STRING s: "LINEAR"

  • n_supports: The number of support vectors. Default value is name: "n_supports" type: INT i: 0

  • one_class: Flag indicating whether the regression is a one-class SVM or not. Default value is name: "one_class" type: INT i: 0

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT.’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T: Data to be regressed.

Outputs

  • Y (heterogeneous)tensor(float): Regression outputs (one score per target per example).

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type, either [C] or [N,C].

OnnxSVMRegressor_1#

class skl2onnx.algebra.onnx_ops.OnnxSVMRegressor_1(*args, **kwargs)#

Version

Onnx name: SVMRegressor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Support Vector Machine regression prediction and one-class SVM anomaly detection.

Attributes

  • kernel_type: The kernel type, one of ‘LINEAR,’ ‘POLY,’ ‘RBF,’ ‘SIGMOID’. Default value is name: "kernel_type" type: STRING s: "LINEAR"

  • n_supports: The number of support vectors. Default value is name: "n_supports" type: INT i: 0

  • one_class: Flag indicating whether the regression is a one-class SVM or not. Default value is name: "one_class" type: INT i: 0

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT.’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T: Data to be regressed.

Outputs

  • Y (heterogeneous)tensor(float): Regression outputs (one score per target per example).

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type, either [C] or [N,C].

OnnxScaler#

class skl2onnx.algebra.onnx_ops.OnnxScaler(*args, **kwargs)#

Version

Onnx name: Scaler

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Rescale input data, for example to standardize features by removing the mean and scaling to unit variance.

Attributes

Inputs

  • X (heterogeneous)T: Data to be scaled.

Outputs

  • Y (heterogeneous)tensor(float): Scaled output data.

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type.

OnnxScaler_1#

class skl2onnx.algebra.onnx_ops.OnnxScaler_1(*args, **kwargs)#

Version

Onnx name: Scaler

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Rescale input data, for example to standardize features by removing the mean and scaling to unit variance.

Attributes

Inputs

  • X (heterogeneous)T: Data to be scaled.

Outputs

  • Y (heterogeneous)tensor(float): Scaled output data.

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input must be a tensor of a numeric type.

OnnxScan#

class skl2onnx.algebra.onnx_ops.OnnxScan(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 21.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body, scan_input_axes = [axis_1, …, axis_m]

> (init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j. sequence_length = scan_1.shape[axis_1];

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations:

// execute loop for (int t = 0; t < sequence_length; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = scan_1<axis=axis_1>[t]; … ; si_m = scan_m<axis=axis_m>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

}

return st_1, …, st_n, scan_out_1, …, scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): All Tensor types up to IRv10.

OnnxScan_11#

class skl2onnx.algebra.onnx_ops.OnnxScan_11(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 11.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body, scan_input_axes = [axis_1, …, axis_m]

> (init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j. sequence_length = scan_1.shape[axis_1];

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations:

// execute loop for (int t = 0; t < sequence_length; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = scan_1<axis=axis_1>[t]; … ; si_m = scan_m<axis=axis_m>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

}

return st_1, …, st_n, scan_out_1, …, scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

OnnxScan_16#

class skl2onnx.algebra.onnx_ops.OnnxScan_16(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 16.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body, scan_input_axes = [axis_1, …, axis_m]

> (init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j. sequence_length = scan_1.shape[axis_1];

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations:

// execute loop for (int t = 0; t < sequence_length; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = scan_1<axis=axis_1>[t]; … ; si_m = scan_m<axis=axis_m>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

}

return st_1, …, st_n, scan_out_1, …, scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types up to IRv4.

OnnxScan_19#

class skl2onnx.algebra.onnx_ops.OnnxScan_19(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 19.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body, scan_input_axes = [axis_1, …, axis_m]

> (init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j. sequence_length = scan_1.shape[axis_1];

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations:

// execute loop for (int t = 0; t < sequence_length; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = scan_1<axis=axis_1>[t]; … ; si_m = scan_m<axis=axis_m>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

}

return st_1, …, st_n, scan_out_1, …, scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): All Tensor types up to IRv9.

OnnxScan_21#

class skl2onnx.algebra.onnx_ops.OnnxScan_21(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 21.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body, scan_input_axes = [axis_1, …, axis_m]

> (init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j. sequence_length = scan_1.shape[axis_1];

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations:

// execute loop for (int t = 0; t < sequence_length; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = scan_1<axis=axis_1>[t]; … ; si_m = scan_m<axis=axis_m>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

}

return st_1, …, st_n, scan_out_1, …, scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): All Tensor types up to IRv10.

OnnxScan_8#

class skl2onnx.algebra.onnx_ops.OnnxScan_8(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 8.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). All these tensors are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs).

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The operation supports batching, and the batch-axis is required to be 0. When multiple scan_input tensors are used, they must all have the same batch-size, and they must all have the same maximum-sequence-length (the dimensionality of the sequence axis or scan axis). The sequence axis or scan axis is required to be 1.

The operation has an optional sequence_lens input (of shape [BATCH_SIZE]) to allow variable length sequences of length <= the maximum-sequence-length. If this input is not specified, all sequences are assumed to be of length equal to maximum-sequence-length. For variable length input sequences, the scan_outputs will consist of a sequence of same length as the input, padded to the maximum-sequence-length.

The optional attribute directions can be used to scan a sequence in the reverse direction. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body

> (sequence_lengths, init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// T.shape[0] denotes the batch-size of T // The batch-size of scan_1, …, scan_m are all required to be equal batch_size = scan_1.shape[0];

// scan_i.shape[1] denotes the (max) sequence-length of scan_i // scan_i.shape[1] is required to be equal to scan_j.shape[1] for all i,j. max_sequence_length = scan_1.shape[1];

for (int batch = 0; batch < batch_size; ++batch) {

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations: N = (sequence_lengths specified) ? sequence_lengths[batch] : max_sequence_length;

// execute loop for (int t = 0; t < N; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = (scan_1<axis=0>[batch])<axis=1>[t]; … ; si_m = (scan_m<axis=0>[batch])<axis=1>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

} // accumulate the outputs for this batch: bst_1[batch] = st_1; …, bst_n[batch] = st_n; // Note scan-outputs will have size max_sequence_length, but only first N values will be meaningful. // The remaining values have an undefined value. b_scan_out_1[batch] = scan_out_1; …; b_scan_out_k[batch] = scan_out_k;

} return bst_1, …, bst_n, b_scan_out_1, …, b_scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](“”, %H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 2 and 2147483647 inputs.

  • sequence_lens (optional, heterogeneous)I: Optional tensor specifying lengths of the sequences in a batch. If this input is not specified, all sequences are assumed to be of the maximum sequence length (the dimension of the sequence axis of the scan_input tensors).

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • I tensor(int64): Int64 tensor

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

OnnxScan_9#

class skl2onnx.algebra.onnx_ops.OnnxScan_9(*args, **kwargs)#

Version

Onnx name: Scan

This version of the operator has been available since version 9.

Summary

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip, and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

Scan <

num_scan_inputs = m, body = loop-body, scan_input_axes = [axis_1, …, axis_m]

> (init_1, …, init_n, scan_1, …, scan_m)

is equivalent to the following pseudo-code:

// scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j. sequence_length = scan_1.shape[axis_1];

// initialize state-variables st_1 = init_1; … st_n = init_n; // initialize scan-output variables: [] denotes an empty tensor scan_out_1 = []; …; scan_out_k = []; // identify number of iterations:

// execute loop for (int t = 0; t < sequence_length; ++t) {

// generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor // of rank one less than T obtained by indexing T at position t along axis k. si_1 = scan_1<axis=axis_1>[t]; … ; si_m = scan_m<axis=axis_m>[t]; // execute loop-body st_1, …, st_n, so_1, …, so_k = loop-body(st_1, …, st_n, si_1, …, si_m) // accumulate the scan-output elements scan_out_1 = Concat<axis=0>(scan_out_1, so_1); … ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);

}

return st_1, …, st_n, scan_out_1, …, scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

graph rnn-encoding {

%H_0 = … %X = … %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X) return %Y, %Y_h

}

graph rnn-cell-1 (

%H_tminus1[FLOAT, tensor] %X_t[FLOAT, tensor]

) {

%Wi = … %Ri = … %Wbi = … %Rbi = … %t1 = X_t * (Wi^T) %t2 = H_tminus1*(Ri^T) %t3 = Add(%t1, %t2) %t4 = Add(%t3, %Wbi) %t5 = Add(%t4, %Rbi) %Ht = Tanh(%t5) %Accumulate = Identity(%Ht) return %Ht, %Accumulate

}

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • initial_state_and_scan_inputs (variadic)V: Initial values of the loop’s N state variables followed by M scan_inputs

Outputs

Between 1 and 2147483647 outputs.

  • final_state_and_scan_outputs (variadic)V: Final values of the loop’s N state variables followed by K scan_outputs

Type Constraints

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): All Tensor types

OnnxScatter#

class skl2onnx.algebra.onnx_ops.OnnxScatter(*args, **kwargs)#

Version

Onnx name: Scatter

This version of the operator has been deprecated since version 11.

Summary

This operator is deprecated. Please use ScatterElements, which provides the same functionality.

Scatter takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself.

For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation.

Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatterElements#

class skl2onnx.algebra.onnx_ops.OnnxScatterElements(*args, **kwargs)#

Version

Onnx name: ScatterElements

This version of the operator has been available since version 18.

Summary

ScatterElements takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself.

reduction allows specification of an optional reduction operation, which is applied to all values in updates tensor into output at the specified indices. In cases where reduction is set to “none”, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

When reduction is set to some reduction function f, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = f(output[indices[i][j]][j], updates[i][j]) if axis = 0,
output[i][indices[i][j]] = f(output[i][indices[i][j]], updates[i][j]) if axis = 1,

where the f is +, *, max or min as specified.

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation.

(Opset 18 change): Adds max/min to the set of allowed reduction ops.

Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • reduction: Type of reduction to apply: none (default), add, mul, max, min. ‘none’: no reduction applied. ‘add’: reduction using the addition operation. ‘mul’: reduction using the multiplication operation.’max’: reduction using the maximum operation.’min’: reduction using the minimum operation. Default value is name: "reduction" type: STRING s: "none"

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatterElements_11#

class skl2onnx.algebra.onnx_ops.OnnxScatterElements_11(*args, **kwargs)#

Version

Onnx name: ScatterElements

This version of the operator has been available since version 11.

Summary

ScatterElements takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself.

For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation.

Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatterElements_13#

class skl2onnx.algebra.onnx_ops.OnnxScatterElements_13(*args, **kwargs)#

Version

Onnx name: ScatterElements

This version of the operator has been available since version 13.

Summary

ScatterElements takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself.

For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation.

Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatterElements_16#

class skl2onnx.algebra.onnx_ops.OnnxScatterElements_16(*args, **kwargs)#

Version

Onnx name: ScatterElements

This version of the operator has been available since version 16.

Summary

ScatterElements takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data. For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself. reduction allows specification of an optional reduction operation, which is applied to all values in updates tensor into output at the specified indices. In cases where reduction is set to “none”, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

When reduction is set to “add”, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] += updates[i][j] if axis = 0,
output[i][indices[i][j]] += updates[i][j] if axis = 1,

When reduction is set to “mul”, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] *= updates[i][j] if axis = 0,
output[i][indices[i][j]] *= updates[i][j] if axis = 1,

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation. Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • reduction: Type of reduction to apply: none (default), add, mul. ‘none’: no reduction applied. ‘add’: reduction using the addition operation. ‘mul’: reduction using the multiplication operation. Default value is name: "reduction" type: STRING s: "none"

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatterElements_18#

class skl2onnx.algebra.onnx_ops.OnnxScatterElements_18(*args, **kwargs)#

Version

Onnx name: ScatterElements

This version of the operator has been available since version 18.

Summary

ScatterElements takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself.

reduction allows specification of an optional reduction operation, which is applied to all values in updates tensor into output at the specified indices. In cases where reduction is set to “none”, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

When reduction is set to some reduction function f, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = f(output[indices[i][j]][j], updates[i][j]) if axis = 0,
output[i][indices[i][j]] = f(output[i][indices[i][j]], updates[i][j]) if axis = 1,

where the f is +, *, max or min as specified.

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation.

(Opset 18 change): Adds max/min to the set of allowed reduction ops.

Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

  • reduction: Type of reduction to apply: none (default), add, mul, max, min. ‘none’: no reduction applied. ‘add’: reduction using the addition operation. ‘mul’: reduction using the multiplication operation.’max’: reduction using the maximum operation.’min’: reduction using the minimum operation. Default value is name: "reduction" type: STRING s: "none"

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatterND#

class skl2onnx.algebra.onnx_ops.OnnxScatterND(*args, **kwargs)#

Version

Onnx name: ScatterND

This version of the operator has been available since version 18.

Summary

ScatterND takes three inputs data tensor of rank r >= 1, indices tensor of rank q >= 1, and updates tensor of rank q + r - indices.shape[-1] - 1. The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

indices is an integer tensor. Let k denote indices.shape[-1], the last dimension in the shape of indices. indices is treated as a (q-1)-dimensional tensor of k-tuples, where each k-tuple is a partial-index into data. Hence, k can be a value at most the rank of data. When k equals rank(data), each update entry specifies an update to a single element of the tensor. When k is less than rank(data) each update entry specifies an update to a slice of the tensor. Index values are allowed to be negative, as per the usual convention for counting backwards from the end, but are expected in the valid range.

updates is treated as a (q-1)-dimensional tensor of replacement-slice-values. Thus, the first (q-1) dimensions of updates.shape must match the first (q-1) dimensions of indices.shape. The remaining dimensions of updates correspond to the dimensions of the replacement-slice-values. Each replacement-slice-value is a (r-k) dimensional tensor, corresponding to the trailing (r-k) dimensions of data. Thus, the shape of updates must equal indices.shape[0:q-1] ++ data.shape[k:r-1], where ++ denotes the concatenation of shapes.

The output is calculated via the following equation:

output = np.copy(data)
update_indices = indices.shape[:-1]
for idx in np.ndindex(update_indices):
    output[indices[idx]] = updates[idx]

The order of iteration in the above loop is not specified. In particular, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order.

reduction allows specification of an optional reduction operation, which is applied to all values in updates tensor into output at the specified indices. In cases where reduction is set to “none”, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order. When reduction is set to some reduction function f, output is calculated as follows:

output = np.copy(data)
update_indices = indices.shape[:-1]
for idx in np.ndindex(update_indices):
    output[indices[idx]] = f(output[indices[idx]], updates[idx])

where the f is +, *, max or min as specified.

This operator is the inverse of GatherND.

(Opset 18 change): Adds max/min to the set of allowed reduction ops.

Example 1:

data    = [1, 2, 3, 4, 5, 6, 7, 8]
indices = [[4], [3], [1], [7]]
updates = [9, 10, 11, 12]
output  = [1, 11, 3, 10, 9, 6, 7, 12]

Example 2:

data    = [[[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
            [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
            [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]],
            [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]
indices = [[0], [2]]
updates = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
            [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]]
output  = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
            [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
            [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],
            [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]

Attributes

  • reduction: Type of reduction to apply: none (default), add, mul, max, min. ‘none’: no reduction applied. ‘add’: reduction using the addition operation. ‘mul’: reduction using the addition operation. ‘max’: reduction using the maximum operation.’min’: reduction using the minimum operation. Default value is name: "reduction" type: STRING s: "none"

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1.

  • updates (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxScatterND_11#

class skl2onnx.algebra.onnx_ops.OnnxScatterND_11(*args, **kwargs)#

Version

Onnx name: ScatterND

This version of the operator has been available since version 11.

Summary

ScatterND takes three inputs data tensor of rank r >= 1, indices tensor of rank q >= 1, and updates tensor of rank q + r - indices.shape[-1] - 1. The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data. Note that indices should not have duplicate entries. That is, two or more updates for the same index-location is not supported.

indices is an integer tensor. Let k denote indices.shape[-1], the last dimension in the shape of indices.

indices is treated as a (q-1)-dimensional tensor of k-tuples, where each k-tuple is a partial-index into data.

Hence, k can be a value at most the rank of data. When k equals rank(data), each update entry specifies an update to a single element of the tensor. When k is less than rank(data) each update entry specifies an update to a slice of the tensor. Index values are allowed to be negative, as per the usual convention for counting backwards from the end, but are expected in the valid range.

updates is treated as a (q-1)-dimensional tensor of replacement-slice-values. Thus, the first (q-1) dimensions of updates.shape must match the first (q-1) dimensions of indices.shape. The remaining dimensions of updates correspond to the dimensions of the replacement-slice-values. Each replacement-slice-value is a (r-k) dimensional tensor, corresponding to the trailing (r-k) dimensions of data. Thus, the shape of updates must equal indices.shape[0:q-1] ++ data.shape[k:r-1], where ++ denotes the concatenation of shapes.

The output is calculated via the following equation:

output = np.copy(data) update_indices = indices.shape[:-1] for idx in np.ndindex(update_indices):

output[indices[idx]] = updates[idx]

The order of iteration in the above loop is not specified. In particular, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order.

This operator is the inverse of GatherND.

Example 1:

data    = [1, 2, 3, 4, 5, 6, 7, 8]
indices = [[4], [3], [1], [7]]
updates = [9, 10, 11, 12]
output  = [1, 11, 3, 10, 9, 6, 7, 12]

Example 2:

data    = [[[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]
indices = [[0], [2]]
updates = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
           [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]]
output  = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
           [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1.

  • updates (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxScatterND_13#

class skl2onnx.algebra.onnx_ops.OnnxScatterND_13(*args, **kwargs)#

Version

Onnx name: ScatterND

This version of the operator has been available since version 13.

Summary

ScatterND takes three inputs data tensor of rank r >= 1, indices tensor of rank q >= 1, and updates tensor of rank q + r - indices.shape[-1] - 1. The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data. Note that indices should not have duplicate entries. That is, two or more updates for the same index-location is not supported.

indices is an integer tensor. Let k denote indices.shape[-1], the last dimension in the shape of indices.

indices is treated as a (q-1)-dimensional tensor of k-tuples, where each k-tuple is a partial-index into data.

Hence, k can be a value at most the rank of data. When k equals rank(data), each update entry specifies an update to a single element of the tensor. When k is less than rank(data) each update entry specifies an update to a slice of the tensor. Index values are allowed to be negative, as per the usual convention for counting backwards from the end, but are expected in the valid range.

updates is treated as a (q-1)-dimensional tensor of replacement-slice-values. Thus, the first (q-1) dimensions of updates.shape must match the first (q-1) dimensions of indices.shape. The remaining dimensions of updates correspond to the dimensions of the replacement-slice-values. Each replacement-slice-value is a (r-k) dimensional tensor, corresponding to the trailing (r-k) dimensions of data. Thus, the shape of updates must equal indices.shape[0:q-1] ++ data.shape[k:r-1], where ++ denotes the concatenation of shapes.

The output is calculated via the following equation:

output = np.copy(data) update_indices = indices.shape[:-1] for idx in np.ndindex(update_indices):

output[indices[idx]] = updates[idx]

The order of iteration in the above loop is not specified. In particular, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order.

This operator is the inverse of GatherND.

Example 1:

data    = [1, 2, 3, 4, 5, 6, 7, 8]
indices = [[4], [3], [1], [7]]
updates = [9, 10, 11, 12]
output  = [1, 11, 3, 10, 9, 6, 7, 12]

Example 2:

data    = [[[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]
indices = [[0], [2]]
updates = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
           [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]]
output  = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
           [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1.

  • updates (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxScatterND_16#

class skl2onnx.algebra.onnx_ops.OnnxScatterND_16(*args, **kwargs)#

Version

Onnx name: ScatterND

This version of the operator has been available since version 16.

Summary

ScatterND takes three inputs data tensor of rank r >= 1, indices tensor of rank q >= 1, and updates tensor of rank q + r - indices.shape[-1] - 1. The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

indices is an integer tensor. Let k denote indices.shape[-1], the last dimension in the shape of indices.

indices is treated as a (q-1)-dimensional tensor of k-tuples, where each k-tuple is a partial-index into data.

Hence, k can be a value at most the rank of data. When k equals rank(data), each update entry specifies an update to a single element of the tensor. When k is less than rank(data) each update entry specifies an update to a slice of the tensor. Index values are allowed to be negative, as per the usual convention for counting backwards from the end, but are expected in the valid range.

updates is treated as a (q-1)-dimensional tensor of replacement-slice-values. Thus, the first (q-1) dimensions of updates.shape must match the first (q-1) dimensions of indices.shape. The remaining dimensions of updates correspond to the dimensions of the replacement-slice-values. Each replacement-slice-value is a (r-k) dimensional tensor, corresponding to the trailing (r-k) dimensions of data. Thus, the shape of updates must equal indices.shape[0:q-1] ++ data.shape[k:r-1], where ++ denotes the concatenation of shapes.

The output is calculated via the following equation:

output = np.copy(data) update_indices = indices.shape[:-1] for idx in np.ndindex(update_indices):

output[indices[idx]] = updates[idx]

The order of iteration in the above loop is not specified. In particular, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order.

reduction allows specification of an optional reduction operation, which is applied to all values in updates tensor into output at the specified indices. In cases where reduction is set to “none”, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order. When reduction is set to “add”, output is calculated as follows:

output = np.copy(data) update_indices = indices.shape[:-1] for idx in np.ndindex(update_indices):

output[indices[idx]] += updates[idx]

When reduction is set to “mul”, output is calculated as follows:

output = np.copy(data) update_indices = indices.shape[:-1] for idx in np.ndindex(update_indices):

output[indices[idx]] *= updates[idx]

This operator is the inverse of GatherND. Example 1:

data    = [1, 2, 3, 4, 5, 6, 7, 8]
indices = [[4], [3], [1], [7]]
updates = [9, 10, 11, 12]
output  = [1, 11, 3, 10, 9, 6, 7, 12]

Example 2:

data    = [[[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]
indices = [[0], [2]]
updates = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
           [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]]
output  = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
           [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
           [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],
           [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]

Attributes

  • reduction: Type of reduction to apply: none (default), add, mul. ‘none’: no reduction applied. ‘add’: reduction using the addition operation. ‘mul’: reduction using the multiplication operation. Default value is name: "reduction" type: STRING s: "none"

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1.

  • updates (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxScatterND_18#

class skl2onnx.algebra.onnx_ops.OnnxScatterND_18(*args, **kwargs)#

Version

Onnx name: ScatterND

This version of the operator has been available since version 18.

Summary

ScatterND takes three inputs data tensor of rank r >= 1, indices tensor of rank q >= 1, and updates tensor of rank q + r - indices.shape[-1] - 1. The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

indices is an integer tensor. Let k denote indices.shape[-1], the last dimension in the shape of indices. indices is treated as a (q-1)-dimensional tensor of k-tuples, where each k-tuple is a partial-index into data. Hence, k can be a value at most the rank of data. When k equals rank(data), each update entry specifies an update to a single element of the tensor. When k is less than rank(data) each update entry specifies an update to a slice of the tensor. Index values are allowed to be negative, as per the usual convention for counting backwards from the end, but are expected in the valid range.

updates is treated as a (q-1)-dimensional tensor of replacement-slice-values. Thus, the first (q-1) dimensions of updates.shape must match the first (q-1) dimensions of indices.shape. The remaining dimensions of updates correspond to the dimensions of the replacement-slice-values. Each replacement-slice-value is a (r-k) dimensional tensor, corresponding to the trailing (r-k) dimensions of data. Thus, the shape of updates must equal indices.shape[0:q-1] ++ data.shape[k:r-1], where ++ denotes the concatenation of shapes.

The output is calculated via the following equation:

output = np.copy(data)
update_indices = indices.shape[:-1]
for idx in np.ndindex(update_indices):
    output[indices[idx]] = updates[idx]

The order of iteration in the above loop is not specified. In particular, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order.

reduction allows specification of an optional reduction operation, which is applied to all values in updates tensor into output at the specified indices. In cases where reduction is set to “none”, indices should not have duplicate entries: that is, if idx1 != idx2, then indices[idx1] != indices[idx2]. This ensures that the output value does not depend on the iteration order. When reduction is set to some reduction function f, output is calculated as follows:

output = np.copy(data)
update_indices = indices.shape[:-1]
for idx in np.ndindex(update_indices):
    output[indices[idx]] = f(output[indices[idx]], updates[idx])

where the f is +, *, max or min as specified.

This operator is the inverse of GatherND.

(Opset 18 change): Adds max/min to the set of allowed reduction ops.

Example 1:

data    = [1, 2, 3, 4, 5, 6, 7, 8]
indices = [[4], [3], [1], [7]]
updates = [9, 10, 11, 12]
output  = [1, 11, 3, 10, 9, 6, 7, 12]

Example 2:

data    = [[[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
            [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
            [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]],
            [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]
indices = [[0], [2]]
updates = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
            [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]]
output  = [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
            [[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]],
            [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],
            [[8, 7, 6, 5], [4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]]

Attributes

  • reduction: Type of reduction to apply: none (default), add, mul, max, min. ‘none’: no reduction applied. ‘add’: reduction using the addition operation. ‘mul’: reduction using the addition operation. ‘max’: reduction using the maximum operation.’min’: reduction using the minimum operation. Default value is name: "reduction" type: STRING s: "none"

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)tensor(int64): Tensor of rank q >= 1.

  • updates (heterogeneous)T: Tensor of rank q + r - indices_shape[-1] - 1.

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to any tensor type.

OnnxScatter_11#

class skl2onnx.algebra.onnx_ops.OnnxScatter_11(*args, **kwargs)#

Version

Onnx name: Scatter

This version of the operator has been deprecated since version 11.

Summary

This operator is deprecated. Please use ScatterElements, which provides the same functionality.

Scatter takes three inputs data, updates, and indices of the same rank r >= 1 and an optional attribute axis that identifies an axis of data (by default, the outer-most axis, that is axis 0). The output of the operation is produced by creating a copy of the input data, and then updating its value to values specified by updates at specific index positions specified by indices. Its output shape is the same as the shape of data.

For each entry in updates, the target index in data is obtained by combining the corresponding entry in indices with the index of the entry itself: the index-value for dimension = axis is obtained from the value of the corresponding entry in indices and the index-value for dimension != axis is obtained from the index of the entry itself.

For instance, in a 2-D tensor case, the update corresponding to the [i][j] entry is performed as below:

output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,

This operator is the inverse of GatherElements. It is similar to Torch’s Scatter operation.

Example 1:

data = [
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
    [0.0, 0.0, 0.0],
]
indices = [
    [1, 0, 2],
    [0, 2, 1],
]
updates = [
    [1.0, 1.1, 1.2],
    [2.0, 2.1, 2.2],
]
output = [
    [2.0, 1.1, 0.0]
    [1.0, 0.0, 2.2]
    [0.0, 2.1, 1.2]
]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input). All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxScatter_9#

class skl2onnx.algebra.onnx_ops.OnnxScatter_9(*args, **kwargs)#

Version

Onnx name: Scatter

This version of the operator has been available since version 9.

Summary

Given data, updates and indices input tensors of rank r >= 1, write the values provided by updates into the first input, data, along axis dimension of data (by default outer-most one as axis=0) at corresponding indices. For each entry in updates, the target index in data is specified by corresponding entry in indices for dimension = axis, and index in source for dimension != axis. For instance, in a 2-D tensor case, data[indices[i][j]][j] = updates[i][j] if axis = 0, or data[i][indices[i][j]] = updates[i][j] if axis = 1, where i and j are loop counters from 0 up to the respective size in updates - 1. Example 1:

data = [

[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0],

] indices = [

[1, 0, 2], [0, 2, 1],

] updates = [

[1.0, 1.1, 1.2], [2.0, 2.1, 2.2],

] output = [

[2.0, 1.1, 0.0] [1.0, 0.0, 2.2] [0.0, 2.1, 1.2]

]

Example 2:

data = [[1.0, 2.0, 3.0, 4.0, 5.0]] indices = [[1, 3]] updates = [[1.1, 2.1]] axis = 1 output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Attributes

  • axis: Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] Default value is name: "axis" type: INT i: 0

Inputs

  • data (heterogeneous)T: Tensor of rank r >= 1.

  • indices (heterogeneous)Tind: Tensor of int32/int64 indices, of r >= 1 (same rank as input).

  • updates (heterogeneous)T: Tensor of rank r >=1 (same rank and shape as indices)

Outputs

  • output (heterogeneous)T: Tensor of rank r >= 1 (same rank as input).

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input and output types can be of any tensor type.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxSelu#

class skl2onnx.algebra.onnx_ops.OnnxSelu(*args, **kwargs)#

Version

Onnx name: Selu

This version of the operator has been available since version 6.

Summary

Selu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the scaled exponential linear unit function, y = gamma * (alpha * e^x - alpha) for x <= 0, y = gamma * x for x > 0, is applied to the tensor elementwise.

Attributes

  • alpha: Coefficient of SELU default to 1.67326319217681884765625 (i.e., float32 approximation of 1.6732632423543772848170429916717). Default value is name: "alpha" type: FLOAT f: 1.67326319

  • gamma: Coefficient of SELU default to 1.05070102214813232421875 (i.e., float32 approximation of 1.0507009873554804934193349852946). Default value is name: "gamma" type: FLOAT f: 1.05070102

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSelu_1#

class skl2onnx.algebra.onnx_ops.OnnxSelu_1(*args, **kwargs)#

Version

Onnx name: Selu

This version of the operator has been available since version 1.

Summary

Selu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the scaled exponential linear unit function, y = gamma * (alpha * e^x - alpha) for x <= 0, y = gamma * x for x > 0, is applied to the tensor elementwise.

Attributes

  • alpha: Coefficient of SELU default to 1.6732. Default value is name: "alpha" type: FLOAT f: 1.6732

  • gamma: Coefficient of SELU default to 1.0507. Default value is name: "gamma" type: FLOAT f: 1.0507

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSelu_6#

class skl2onnx.algebra.onnx_ops.OnnxSelu_6(*args, **kwargs)#

Version

Onnx name: Selu

This version of the operator has been available since version 6.

Summary

Selu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the scaled exponential linear unit function, y = gamma * (alpha * e^x - alpha) for x <= 0, y = gamma * x for x > 0, is applied to the tensor elementwise.

Attributes

  • alpha: Coefficient of SELU default to 1.67326319217681884765625 (i.e., float32 approximation of 1.6732632423543772848170429916717). Default value is name: "alpha" type: FLOAT f: 1.67326319

  • gamma: Coefficient of SELU default to 1.05070102214813232421875 (i.e., float32 approximation of 1.0507009873554804934193349852946). Default value is name: "gamma" type: FLOAT f: 1.05070102

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSequenceAt#

class skl2onnx.algebra.onnx_ops.OnnxSequenceAt(*args, **kwargs)#

Version

Onnx name: SequenceAt

This version of the operator has been available since version 11.

Summary

Outputs a tensor copy from the tensor at ‘position’ in ‘input_sequence’. Accepted range for ‘position’ is in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. Negative value means counting positions from the back.

Inputs

  • input_sequence (heterogeneous)S: Input sequence.

  • position (heterogeneous)I: Position of the tensor in the sequence. Negative value means counting positions from the back. Accepted range in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).

Outputs

  • tensor (heterogeneous)T: Output tensor at the specified position in the input sequence.

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

  • I tensor(int32), tensor(int64): Constrain position to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceAt_11#

class skl2onnx.algebra.onnx_ops.OnnxSequenceAt_11(*args, **kwargs)#

Version

Onnx name: SequenceAt

This version of the operator has been available since version 11.

Summary

Outputs a tensor copy from the tensor at ‘position’ in ‘input_sequence’. Accepted range for ‘position’ is in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. Negative value means counting positions from the back.

Inputs

  • input_sequence (heterogeneous)S: Input sequence.

  • position (heterogeneous)I: Position of the tensor in the sequence. Negative value means counting positions from the back. Accepted range in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).

Outputs

  • tensor (heterogeneous)T: Output tensor at the specified position in the input sequence.

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

  • I tensor(int32), tensor(int64): Constrain position to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceConstruct#

class skl2onnx.algebra.onnx_ops.OnnxSequenceConstruct(*args, **kwargs)#

Version

Onnx name: SequenceConstruct

This version of the operator has been available since version 11.

Summary

Construct a tensor sequence containing ‘inputs’ tensors. All tensors in ‘inputs’ must have the same data type.

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: Tensors.

Outputs

  • output_sequence (heterogeneous)S: Sequence enclosing the input tensors.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input types to any tensor type.

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output types to any tensor type.

OnnxSequenceConstruct_11#

class skl2onnx.algebra.onnx_ops.OnnxSequenceConstruct_11(*args, **kwargs)#

Version

Onnx name: SequenceConstruct

This version of the operator has been available since version 11.

Summary

Construct a tensor sequence containing ‘inputs’ tensors. All tensors in ‘inputs’ must have the same data type.

Inputs

Between 1 and 2147483647 inputs.

  • inputs (variadic, heterogeneous)T: Tensors.

Outputs

  • output_sequence (heterogeneous)S: Sequence enclosing the input tensors.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input types to any tensor type.

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output types to any tensor type.

OnnxSequenceEmpty#

class skl2onnx.algebra.onnx_ops.OnnxSequenceEmpty(*args, **kwargs)#

Version

Onnx name: SequenceEmpty

This version of the operator has been available since version 11.

Summary

Construct an empty tensor sequence, with given data type.

Attributes

Outputs

  • output (heterogeneous)S: Empty sequence.

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output types to any tensor type.

OnnxSequenceEmpty_11#

class skl2onnx.algebra.onnx_ops.OnnxSequenceEmpty_11(*args, **kwargs)#

Version

Onnx name: SequenceEmpty

This version of the operator has been available since version 11.

Summary

Construct an empty tensor sequence, with given data type.

Attributes

Outputs

  • output (heterogeneous)S: Empty sequence.

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output types to any tensor type.

OnnxSequenceErase#

class skl2onnx.algebra.onnx_ops.OnnxSequenceErase(*args, **kwargs)#

Version

Onnx name: SequenceErase

This version of the operator has been available since version 11.

Summary

Outputs a tensor sequence that removes the tensor at ‘position’ from ‘input_sequence’. Accepted range for ‘position’ is in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. Negative value means counting positions from the back. ‘position’ is optional, by default it erases the last tensor from ‘input_sequence’.

Inputs

Between 1 and 2 inputs.

  • input_sequence (heterogeneous)S: Input sequence.

  • position (optional, heterogeneous)I: Position of the tensor in the sequence. Negative value means counting positions from the back. Accepted range in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).

Outputs

  • output_sequence (heterogeneous)S: Output sequence that has the tensor at the specified position removed.

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • I tensor(int32), tensor(int64): Constrain position to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceErase_11#

class skl2onnx.algebra.onnx_ops.OnnxSequenceErase_11(*args, **kwargs)#

Version

Onnx name: SequenceErase

This version of the operator has been available since version 11.

Summary

Outputs a tensor sequence that removes the tensor at ‘position’ from ‘input_sequence’. Accepted range for ‘position’ is in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. Negative value means counting positions from the back. ‘position’ is optional, by default it erases the last tensor from ‘input_sequence’.

Inputs

Between 1 and 2 inputs.

  • input_sequence (heterogeneous)S: Input sequence.

  • position (optional, heterogeneous)I: Position of the tensor in the sequence. Negative value means counting positions from the back. Accepted range in [-n, n - 1], where n is the number of tensors in ‘input_sequence’. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).

Outputs

  • output_sequence (heterogeneous)S: Output sequence that has the tensor at the specified position removed.

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • I tensor(int32), tensor(int64): Constrain position to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceInsert#

class skl2onnx.algebra.onnx_ops.OnnxSequenceInsert(*args, **kwargs)#

Version

Onnx name: SequenceInsert

This version of the operator has been available since version 11.

Summary

Outputs a tensor sequence that inserts ‘tensor’ into ‘input_sequence’ at ‘position’. ‘tensor’ must have the same data type as ‘input_sequence’. Accepted range for ‘position’ is in [-n, n], where n is the number of tensors in ‘input_sequence’. Negative value means counting positions from the back. ‘position’ is optional, by default it inserts ‘tensor’ to the back of ‘input_sequence’.

Inputs

Between 2 and 3 inputs.

  • input_sequence (heterogeneous)S: Input sequence.

  • tensor (heterogeneous)T: Input tensor to be inserted into the input sequence.

  • position (optional, heterogeneous)I: Position in the sequence where the new tensor is inserted. It is optional and default is to insert to the back of the sequence. Negative value means counting positions from the back. Accepted range in [-n, n], where n is the number of tensors in ‘input_sequence’. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).

Outputs

  • output_sequence (heterogeneous)S: Output sequence that contains the inserted tensor at given position.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • I tensor(int32), tensor(int64): Constrain position to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceInsert_11#

class skl2onnx.algebra.onnx_ops.OnnxSequenceInsert_11(*args, **kwargs)#

Version

Onnx name: SequenceInsert

This version of the operator has been available since version 11.

Summary

Outputs a tensor sequence that inserts ‘tensor’ into ‘input_sequence’ at ‘position’. ‘tensor’ must have the same data type as ‘input_sequence’. Accepted range for ‘position’ is in [-n, n], where n is the number of tensors in ‘input_sequence’. Negative value means counting positions from the back. ‘position’ is optional, by default it inserts ‘tensor’ to the back of ‘input_sequence’.

Inputs

Between 2 and 3 inputs.

  • input_sequence (heterogeneous)S: Input sequence.

  • tensor (heterogeneous)T: Input tensor to be inserted into the input sequence.

  • position (optional, heterogeneous)I: Position in the sequence where the new tensor is inserted. It is optional and default is to insert to the back of the sequence. Negative value means counting positions from the back. Accepted range in [-n, n], where n is the number of tensors in ‘input_sequence’. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).

Outputs

  • output_sequence (heterogeneous)S: Output sequence that contains the inserted tensor at given position.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain to any tensor type.

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • I tensor(int32), tensor(int64): Constrain position to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceLength#

class skl2onnx.algebra.onnx_ops.OnnxSequenceLength(*args, **kwargs)#

Version

Onnx name: SequenceLength

This version of the operator has been available since version 11.

Summary

Produces a scalar(tensor of empty shape) containing the number of tensors in ‘input_sequence’.

Inputs

  • input_sequence (heterogeneous)S: Input sequence.

Outputs

  • length (heterogeneous)I: Length of input sequence. It must be a scalar(tensor of empty shape).

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • I tensor(int64): Constrain output to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceLength_11#

class skl2onnx.algebra.onnx_ops.OnnxSequenceLength_11(*args, **kwargs)#

Version

Onnx name: SequenceLength

This version of the operator has been available since version 11.

Summary

Produces a scalar(tensor of empty shape) containing the number of tensors in ‘input_sequence’.

Inputs

  • input_sequence (heterogeneous)S: Input sequence.

Outputs

  • length (heterogeneous)I: Length of input sequence. It must be a scalar(tensor of empty shape).

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor type.

  • I tensor(int64): Constrain output to integral tensor. It must be a scalar(tensor of empty shape).

OnnxSequenceMap#

class skl2onnx.algebra.onnx_ops.OnnxSequenceMap(*args, **kwargs)#

Version

Onnx name: SequenceMap

This version of the operator has been available since version 17.

Summary

Applies a sub-graph to each sample in the input sequence(s).

Inputs can be either tensors or sequences, with the exception of the first input which must be a sequence. The length of the first input sequence will determine the number of samples in the outputs. Any other sequence inputs should have the same number of samples. The number of inputs and outputs, should match the one of the subgraph.

For each i-th element in the output, a sample will be extracted from the input sequence(s) at the i-th position and the sub-graph will be applied to it. The outputs will contain the outputs of the sub-graph for each sample, in the same order as in the input.

This operator assumes that processing each sample is independent and could executed in parallel or in any order. Users cannot expect any specific ordering in which each subgraph is computed.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • input_sequence (heterogeneous)S: Input sequence.

  • additional_inputs (variadic)V: Additional inputs to the graph

Outputs

Between 1 and 2147483647 outputs.

  • out_sequence (variadic)S: Output sequence(s)

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input types to any sequence type.

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor or sequence type.

OnnxSequenceMap_17#

class skl2onnx.algebra.onnx_ops.OnnxSequenceMap_17(*args, **kwargs)#

Version

Onnx name: SequenceMap

This version of the operator has been available since version 17.

Summary

Applies a sub-graph to each sample in the input sequence(s).

Inputs can be either tensors or sequences, with the exception of the first input which must be a sequence. The length of the first input sequence will determine the number of samples in the outputs. Any other sequence inputs should have the same number of samples. The number of inputs and outputs, should match the one of the subgraph.

For each i-th element in the output, a sample will be extracted from the input sequence(s) at the i-th position and the sub-graph will be applied to it. The outputs will contain the outputs of the sub-graph for each sample, in the same order as in the input.

This operator assumes that processing each sample is independent and could executed in parallel or in any order. Users cannot expect any specific ordering in which each subgraph is computed.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • input_sequence (heterogeneous)S: Input sequence.

  • additional_inputs (variadic)V: Additional inputs to the graph

Outputs

Between 1 and 2147483647 outputs.

  • out_sequence (variadic)S: Output sequence(s)

Type Constraints

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain input types to any sequence type.

  • V tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain to any tensor or sequence type.

OnnxShape#

class skl2onnx.algebra.onnx_ops.OnnxShape(*args, **kwargs)#

Version

Onnx name: Shape

This version of the operator has been available since version 21.

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor. Optional attributes start and end can be used to compute a slice of the input tensor’s shape. If start axis is omitted, the slice starts from axis 0. The end axis, if specified, is exclusive (and the returned value will not include the size of that axis). If the end axis is omitted, the axes upto the last one will be included. Negative axes indicate counting back from the last axis. Note that axes will be clamped to the range [0, r-1], where r is the rank of the input tensor if they are out-of-range (after adding r in the case of negative axis). Thus, specifying any end value > r is equivalent to specifying an end value of r, and specifying any start value < -r is equivalent to specifying a start value of 0.

Examples:

Input tensor with shape: [2, 3, 4]
No attributes specified.
Output: [2, 3, 4]
Input tensor with shape: [2, 3, 4]
start: -1
Output: [4]
Input tensor with shape: [2, 3, 4]
end: -1
Output: [2, 3]
Input tensor with shape: [2, 3, 4]
start: 1
end: 2
Output: [3]

Attributes

  • start: (Optional) Starting axis for slicing the shape. Default value is 0.Negative value means counting dimensions from the back. Default value is name: "start" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • shape (heterogeneous)T1: Shape of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor.

OnnxShape_1#

class skl2onnx.algebra.onnx_ops.OnnxShape_1(*args, **kwargs)#

Version

Onnx name: Shape

This version of the operator has been available since version 1.

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • shape (heterogeneous)T1: Shape of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor.

OnnxShape_13#

class skl2onnx.algebra.onnx_ops.OnnxShape_13(*args, **kwargs)#

Version

Onnx name: Shape

This version of the operator has been available since version 13.

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • shape (heterogeneous)T1: Shape of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor.

OnnxShape_15#

class skl2onnx.algebra.onnx_ops.OnnxShape_15(*args, **kwargs)#

Version

Onnx name: Shape

This version of the operator has been available since version 15.

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor. Optional attributes start and end can be used to compute a slice of the input tensor’s shape. If start axis is omitted, the slice starts from axis 0. The end axis, if specified, is exclusive (and the returned value will not include the size of that axis). If the end axis is omitted, the axes upto the last one will be included. Negative axes indicate counting back from the last axis. Note that axes will be clamped to the range [0, r-1], where r is the rank of the input tensor if they are out-of-range (after adding r in the case of negative axis). Thus, specifying any end value > r is equivalent to specifying an end value of r, and specifying any start value < -r is equivalent to specifying a start value of 0.

Examples:

Input tensor with shape: [2, 3, 4]
No attributes specified.
Output: [2, 3, 4]
Input tensor with shape: [2, 3, 4]
start: -1
Output: [4]
Input tensor with shape: [2, 3, 4]
end: -1
Output: [2, 3]
Input tensor with shape: [2, 3, 4]
start: 1
end: 2
Output: [3]

Attributes

  • start: (Optional) Starting axis for slicing the shape. Default value is 0.Negative value means counting dimensions from the back. Default value is name: "start" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • shape (heterogeneous)T1: Shape of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor.

OnnxShape_19#

class skl2onnx.algebra.onnx_ops.OnnxShape_19(*args, **kwargs)#

Version

Onnx name: Shape

This version of the operator has been available since version 19.

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor. Optional attributes start and end can be used to compute a slice of the input tensor’s shape. If start axis is omitted, the slice starts from axis 0. The end axis, if specified, is exclusive (and the returned value will not include the size of that axis). If the end axis is omitted, the axes upto the last one will be included. Negative axes indicate counting back from the last axis. Note that axes will be clamped to the range [0, r-1], where r is the rank of the input tensor if they are out-of-range (after adding r in the case of negative axis). Thus, specifying any end value > r is equivalent to specifying an end value of r, and specifying any start value < -r is equivalent to specifying a start value of 0.

Examples:

Input tensor with shape: [2, 3, 4]
No attributes specified.
Output: [2, 3, 4]
Input tensor with shape: [2, 3, 4]
start: -1
Output: [4]
Input tensor with shape: [2, 3, 4]
end: -1
Output: [2, 3]
Input tensor with shape: [2, 3, 4]
start: 1
end: 2
Output: [3]

Attributes

  • start: (Optional) Starting axis for slicing the shape. Default value is 0.Negative value means counting dimensions from the back. Default value is name: "start" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • shape (heterogeneous)T1: Shape of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor.

OnnxShape_21#

class skl2onnx.algebra.onnx_ops.OnnxShape_21(*args, **kwargs)#

Version

Onnx name: Shape

This version of the operator has been available since version 21.

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor. Optional attributes start and end can be used to compute a slice of the input tensor’s shape. If start axis is omitted, the slice starts from axis 0. The end axis, if specified, is exclusive (and the returned value will not include the size of that axis). If the end axis is omitted, the axes upto the last one will be included. Negative axes indicate counting back from the last axis. Note that axes will be clamped to the range [0, r-1], where r is the rank of the input tensor if they are out-of-range (after adding r in the case of negative axis). Thus, specifying any end value > r is equivalent to specifying an end value of r, and specifying any start value < -r is equivalent to specifying a start value of 0.

Examples:

Input tensor with shape: [2, 3, 4]
No attributes specified.
Output: [2, 3, 4]
Input tensor with shape: [2, 3, 4]
start: -1
Output: [4]
Input tensor with shape: [2, 3, 4]
end: -1
Output: [2, 3]
Input tensor with shape: [2, 3, 4]
start: 1
end: 2
Output: [3]

Attributes

  • start: (Optional) Starting axis for slicing the shape. Default value is 0.Negative value means counting dimensions from the back. Default value is name: "start" type: INT i: 0

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • shape (heterogeneous)T1: Shape of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor.

OnnxShrink#

class skl2onnx.algebra.onnx_ops.OnnxShrink(*args, **kwargs)#

Version

Onnx name: Shrink

This version of the operator has been available since version 9.

Summary

Shrink takes one input data (Tensor<numeric>) and produces one Tensor output, having same datatype and shape with input. It has two attributes, lambd and bias. The formula of this operator is: If x < -lambd, y = x + bias; If x > lambd, y = x - bias; Otherwise, y = 0.

Attributes

  • bias: The bias value added to output. Default is 0. Default value is name: "bias" type: FLOAT f: 0

  • lambd: The lambd value for the Shrink formulation. Default is 0.5. Default value is name: "lambd" type: FLOAT f: 0.5

Inputs

  • input (heterogeneous)T: The input data as Tensor.

Outputs

  • output (heterogeneous)T: The output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

OnnxShrink_9#

class skl2onnx.algebra.onnx_ops.OnnxShrink_9(*args, **kwargs)#

Version

Onnx name: Shrink

This version of the operator has been available since version 9.

Summary

Shrink takes one input data (Tensor<numeric>) and produces one Tensor output, having same datatype and shape with input. It has two attributes, lambd and bias. The formula of this operator is: If x < -lambd, y = x + bias; If x > lambd, y = x - bias; Otherwise, y = 0.

Attributes

  • bias: The bias value added to output. Default is 0. Default value is name: "bias" type: FLOAT f: 0

  • lambd: The lambd value for the Shrink formulation. Default is 0.5. Default value is name: "lambd" type: FLOAT f: 0.5

Inputs

  • input (heterogeneous)T: The input data as Tensor.

Outputs

  • output (heterogeneous)T: The output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input to only numeric types.

OnnxSigmoid#

class skl2onnx.algebra.onnx_ops.OnnxSigmoid(*args, **kwargs)#

Version

Onnx name: Sigmoid

This version of the operator has been available since version 13.

Summary

Sigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSigmoid_1#

class skl2onnx.algebra.onnx_ops.OnnxSigmoid_1(*args, **kwargs)#

Version

Onnx name: Sigmoid

This version of the operator has been available since version 1.

Summary

Sigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the tensor elementwise.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSigmoid_13#

class skl2onnx.algebra.onnx_ops.OnnxSigmoid_13(*args, **kwargs)#

Version

Onnx name: Sigmoid

This version of the operator has been available since version 13.

Summary

Sigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSigmoid_6#

class skl2onnx.algebra.onnx_ops.OnnxSigmoid_6(*args, **kwargs)#

Version

Onnx name: Sigmoid

This version of the operator has been available since version 6.

Summary

Sigmoid takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSign#

class skl2onnx.algebra.onnx_ops.OnnxSign(*args, **kwargs)#

Version

Onnx name: Sign

This version of the operator has been available since version 13.

Summary

Calculate the sign of the given input tensor element-wise. If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The sign of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxSign_13#

class skl2onnx.algebra.onnx_ops.OnnxSign_13(*args, **kwargs)#

Version

Onnx name: Sign

This version of the operator has been available since version 13.

Summary

Calculate the sign of the given input tensor element-wise. If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The sign of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxSign_9#

class skl2onnx.algebra.onnx_ops.OnnxSign_9(*args, **kwargs)#

Version

Onnx name: Sign

This version of the operator has been available since version 9.

Summary

Calculate the sign of the given input tensor element-wise. If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The sign of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to all numeric tensors.

OnnxSin#

class skl2onnx.algebra.onnx_ops.OnnxSin(*args, **kwargs)#

Version

Onnx name: Sin

This version of the operator has been available since version 7.

Summary

Calculates the sine of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The sine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSin_7#

class skl2onnx.algebra.onnx_ops.OnnxSin_7(*args, **kwargs)#

Version

Onnx name: Sin

This version of the operator has been available since version 7.

Summary

Calculates the sine of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The sine of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSinh#

class skl2onnx.algebra.onnx_ops.OnnxSinh(*args, **kwargs)#

Version

Onnx name: Sinh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic sine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic sine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSinh_9#

class skl2onnx.algebra.onnx_ops.OnnxSinh_9(*args, **kwargs)#

Version

Onnx name: Sinh

This version of the operator has been available since version 9.

Summary

Calculates the hyperbolic sine of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic sine values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSize#

class skl2onnx.algebra.onnx_ops.OnnxSize(*args, **kwargs)#

Version

Onnx name: Size

This version of the operator has been available since version 21.

Summary

Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • size (heterogeneous)T1: Total number of elements of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor, which should be a scalar though.

OnnxSize_1#

class skl2onnx.algebra.onnx_ops.OnnxSize_1(*args, **kwargs)#

Version

Onnx name: Size

This version of the operator has been available since version 1.

Summary

Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • size (heterogeneous)T1: Total number of elements of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor, which should be a scalar though.

OnnxSize_13#

class skl2onnx.algebra.onnx_ops.OnnxSize_13(*args, **kwargs)#

Version

Onnx name: Size

This version of the operator has been available since version 13.

Summary

Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • size (heterogeneous)T1: Total number of elements of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor, which should be a scalar though.

OnnxSize_19#

class skl2onnx.algebra.onnx_ops.OnnxSize_19(*args, **kwargs)#

Version

Onnx name: Size

This version of the operator has been available since version 19.

Summary

Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • size (heterogeneous)T1: Total number of elements of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor, which should be a scalar though.

OnnxSize_21#

class skl2onnx.algebra.onnx_ops.OnnxSize_21(*args, **kwargs)#

Version

Onnx name: Size

This version of the operator has been available since version 21.

Summary

Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • size (heterogeneous)T1: Total number of elements of the input tensor

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Input tensor can be of arbitrary type.

  • T1 tensor(int64): Constrain output to int64 tensor, which should be a scalar though.

OnnxSlice#

class skl2onnx.algebra.onnx_ops.OnnxSlice(*args, **kwargs)#

Version

Onnx name: Slice

This version of the operator has been available since version 13.

Summary

Produces a slice of the input tensor along multiple axes. Similar to numpy: https://numpy.org/doc/stable/user/basics.indexing.html?highlight=slice#slicing-and-striding

Slice uses the starts, ends, axes and steps inputs to select a sub-tensor of its input data tensor.

An effective starts[i], ends[i], and steps[i] must be computed for each i in [0, … r-1] where r = rank(input) as follows:

If axes are omitted, they are set to [0, …, r-1]. If steps are omitted, they are set to [1, …, 1] of length len(starts)

The effective values are initialized as start[i] = 0, ends[i] = dims[i] where dims are the dimensions of input and steps[i] = 1.

All negative elements of axes are made non-negative by adding r to them, where r =rank(input).

All negative values in starts[i] and ends[i] have dims[axes[i]] added to them, where dims are the dimensions of input. Then start[axes[i]] is the adjusted starts[i] is clamped into the range [0, dims[axes[i]]] for positive stepping and [0, dims[axes[i]]-1] for negative stepping.

The clamping for the adjusted ends[i] depends on the sign of steps[i] and must accommodate copying 0 through dims[axes[i]] elements, so for positive stepping ends[axes[i]] is clamped to [0, dims[axes[i]]], while for negative stepping it is clamped to [-1, dims[axes[i]]-1].

Finally, steps[axes[i]] = steps[i].

For slicing to the end of a dimension with unknown size, it is recommended to pass in INT_MAX when slicing forward and ‘INT_MIN’ when slicing backward.

Example 1:

data = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
]
axes = [0, 1]
starts = [1, 0]
ends = [2, 3]
steps = [1, 2]
result = [
    [5, 7],
]

Example 2:

data = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
]
starts = [0, 1]
ends = [-1, 1000]
result = [
    [2, 3, 4],
]

Inputs

Between 3 and 5 inputs.

  • data (heterogeneous)T: Tensor of data to extract slices from.

  • starts (heterogeneous)Tind: 1-D tensor of starting indices of corresponding axis in axes

  • ends (heterogeneous)Tind: 1-D tensor of ending indices (exclusive) of corresponding axis in axes

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that starts and ends apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated.

  • steps (optional, heterogeneous)Tind: 1-D tensor of slice step of corresponding axis in axes. Negative value means slicing backward. ‘steps’ cannot be 0. Defaults to 1s.

Outputs

  • output (heterogeneous)T: Sliced data tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxSlice_1#

class skl2onnx.algebra.onnx_ops.OnnxSlice_1(*args, **kwargs)#

Version

Onnx name: Slice

This version of the operator has been available since version 1.

Summary

Produces a slice of the input tensor along multiple axes. Similar to numpy: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html Slices uses axes, starts and ends attributes to specify the start and end dimension for each axis in the list of axes, it uses this information to slice the input data tensor. If a negative value is passed for any of the start or end indices, it represent number of elements before the end of that dimension. If the value passed to start or end is larger than the n (the number of elements in this dimension), it represents n. For slicing to the end of a dimension with unknown size, it is recommended to pass in INT_MAX. If axes are omitted, they are set to [0, …, ndim-1]. Example 1:

data = [

[1, 2, 3, 4], [5, 6, 7, 8],

] axes = [0, 1] starts = [1, 0] ends = [2, 3] result = [

[5, 6, 7],

]

Example 2:
data = [

[1, 2, 3, 4], [5, 6, 7, 8],

] starts = [0, 1] ends = [-1, 1000] result = [

[2, 3, 4],

]

Attributes

Inputs

  • data (heterogeneous)T: Tensor of data to extract slices from.

Outputs

  • output (heterogeneous)T: Sliced data tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSlice_10#

class skl2onnx.algebra.onnx_ops.OnnxSlice_10(*args, **kwargs)#

Version

Onnx name: Slice

This version of the operator has been available since version 10.

Summary

Produces a slice of the input tensor along multiple axes. Similar to numpy: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html Slices uses starts, ends, axes and steps inputs to specify the start and end dimension and step for each axis in the list of axes, it uses this information to slice the input data tensor. If a negative value is passed for any of the start or end indices, it represent number of elements before the end of that dimension. If the value passed to start or end is larger than the n (the number of elements in this dimension), it represents n. For slicing to the end of a dimension with unknown size, it is recommended to pass in INT_MAX. If a negative value is passed for step, it represents slicing backward. If axes are omitted, they are set to [0, …, ndim-1]. If steps are omitted, they are set to [1, …, 1] of length len(starts) Example 1:

data = [

[1, 2, 3, 4], [5, 6, 7, 8],

] axes = [0, 1] starts = [1, 0] ends = [2, 3] steps = [1, 2] result = [

[5, 7],

]

Example 2:
data = [

[1, 2, 3, 4], [5, 6, 7, 8],

] starts = [0, 1] ends = [-1, 1000] result = [

[2, 3, 4],

]

Inputs

Between 3 and 5 inputs.

  • data (heterogeneous)T: Tensor of data to extract slices from.

  • starts (heterogeneous)Tind: 1-D tensor of starting indices of corresponding axis in axes

  • ends (heterogeneous)Tind: 1-D tensor of ending indices (exclusive) of corresponding axis in axes

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that starts and ends apply to.

  • steps (optional, heterogeneous)Tind: 1-D tensor of slice step of corresponding axis in axes. Default to 1.

Outputs

  • output (heterogeneous)T: Sliced data tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxSlice_11#

class skl2onnx.algebra.onnx_ops.OnnxSlice_11(*args, **kwargs)#

Version

Onnx name: Slice

This version of the operator has been available since version 11.

Summary

Produces a slice of the input tensor along multiple axes. Similar to numpy: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html Slices uses starts, ends, axes and steps inputs to specify the start and end dimension and step for each axis in the list of axes, it uses this information to slice the input data tensor. If a negative value is passed for any of the start or end indices, it represents number of elements before the end of that dimension. If the value passed to start or end is larger than the n (the number of elements in this dimension), it represents n. For slicing to the end of a dimension with unknown size, it is recommended to pass in INT_MAX when slicing forward and ‘INT_MIN’ when slicing backward. If a negative value is passed for step, it represents slicing backward. However step value cannot be 0. If axes are omitted, they are set to [0, …, ndim-1]. If steps are omitted, they are set to [1, …, 1] of length len(starts) Example 1:

data = [

[1, 2, 3, 4], [5, 6, 7, 8],

] axes = [0, 1] starts = [1, 0] ends = [2, 3] steps = [1, 2] result = [

[5, 7],

]

Example 2:
data = [

[1, 2, 3, 4], [5, 6, 7, 8],

] starts = [0, 1] ends = [-1, 1000] result = [

[2, 3, 4],

]

Inputs

Between 3 and 5 inputs.

  • data (heterogeneous)T: Tensor of data to extract slices from.

  • starts (heterogeneous)Tind: 1-D tensor of starting indices of corresponding axis in axes

  • ends (heterogeneous)Tind: 1-D tensor of ending indices (exclusive) of corresponding axis in axes

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that starts and ends apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

  • steps (optional, heterogeneous)Tind: 1-D tensor of slice step of corresponding axis in axes. Negative value means slicing backward. ‘steps’ cannot be 0. Defaults to 1.

Outputs

  • output (heterogeneous)T: Sliced data tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxSlice_13#

class skl2onnx.algebra.onnx_ops.OnnxSlice_13(*args, **kwargs)#

Version

Onnx name: Slice

This version of the operator has been available since version 13.

Summary

Produces a slice of the input tensor along multiple axes. Similar to numpy: https://numpy.org/doc/stable/user/basics.indexing.html?highlight=slice#slicing-and-striding

Slice uses the starts, ends, axes and steps inputs to select a sub-tensor of its input data tensor.

An effective starts[i], ends[i], and steps[i] must be computed for each i in [0, … r-1] where r = rank(input) as follows:

If axes are omitted, they are set to [0, …, r-1]. If steps are omitted, they are set to [1, …, 1] of length len(starts)

The effective values are initialized as start[i] = 0, ends[i] = dims[i] where dims are the dimensions of input and steps[i] = 1.

All negative elements of axes are made non-negative by adding r to them, where r =rank(input).

All negative values in starts[i] and ends[i] have dims[axes[i]] added to them, where dims are the dimensions of input. Then start[axes[i]] is the adjusted starts[i] is clamped into the range [0, dims[axes[i]]] for positive stepping and [0, dims[axes[i]]-1] for negative stepping.

The clamping for the adjusted ends[i] depends on the sign of steps[i] and must accommodate copying 0 through dims[axes[i]] elements, so for positive stepping ends[axes[i]] is clamped to [0, dims[axes[i]]], while for negative stepping it is clamped to [-1, dims[axes[i]]-1].

Finally, steps[axes[i]] = steps[i].

For slicing to the end of a dimension with unknown size, it is recommended to pass in INT_MAX when slicing forward and ‘INT_MIN’ when slicing backward.

Example 1:

data = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
]
axes = [0, 1]
starts = [1, 0]
ends = [2, 3]
steps = [1, 2]
result = [
    [5, 7],
]

Example 2:

data = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
]
starts = [0, 1]
ends = [-1, 1000]
result = [
    [2, 3, 4],
]

Inputs

Between 3 and 5 inputs.

  • data (heterogeneous)T: Tensor of data to extract slices from.

  • starts (heterogeneous)Tind: 1-D tensor of starting indices of corresponding axis in axes

  • ends (heterogeneous)Tind: 1-D tensor of ending indices (exclusive) of corresponding axis in axes

  • axes (optional, heterogeneous)Tind: 1-D tensor of axes that starts and ends apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated.

  • steps (optional, heterogeneous)Tind: 1-D tensor of slice step of corresponding axis in axes. Negative value means slicing backward. ‘steps’ cannot be 0. Defaults to 1s.

Outputs

  • output (heterogeneous)T: Sliced data tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • Tind tensor(int32), tensor(int64): Constrain indices to integer types

OnnxSoftmax#

class skl2onnx.algebra.onnx_ops.OnnxSoftmax(*args, **kwargs)#

Version

Onnx name: Softmax

This version of the operator has been available since version 13.

Summary

The operator computes the normalized exponential values for the given input:

Softmax(input, axis) = Exp(input) / ReduceSum(Exp(input), axis=axis, keepdims=1)

The “axis” attribute indicates the dimension along which Softmax will be performed. The output tensor has the same shape and contains the Softmax values of the corresponding input.

Attributes

  • axis:

Describes the dimension Softmax will be performed on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).

Default value is

name: "axis" type: INT i: -1

Inputs

  • input (heterogeneous)T: The input tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: The output values with the same shape as the input tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSoftmaxCrossEntropyLoss#

class skl2onnx.algebra.onnx_ops.OnnxSoftmaxCrossEntropyLoss(*args, **kwargs)#

Version

Onnx name: SoftmaxCrossEntropyLoss

This version of the operator has been available since version 13.

Summary

Loss function that measures the softmax cross entropy between ‘scores’ and ‘labels’. This operator first computes a loss tensor whose shape is identical to the labels input. If the input is 2-D with shape (N, C), the loss tensor may be a N-element vector L = (l_1, l_2, …, l_N). If the input is N-D tensor with shape (N, C, D1, D2, …, Dk), the loss tensor L may have (N, D1, D2, …, Dk) as its shape and L[i,][j_1][j_2]…[j_k] denotes a scalar element in L. After L is available, this operator can optionally do a reduction operator.

  • shape(scores): (N, C) where C is the number of classes, or (N, C, D1, D2,…, Dk), with K >= 1 in case of K-dimensional loss.

  • shape(labels): (N) where each value is 0 <= labels[i] <= C-1, or (N, D1, D2,…, Dk), with K >= 1 in case of K-dimensional loss.

The loss for one sample, l_i, can calculated as follows:

l[i][d1][d2]...[dk] = -y[i][c][d1][d2]..[dk], where i is the index of classes.

or#

l[i][d1][d2]…[dk] = -y[i][c][d1][d2]..[dk] * weights[c], if ‘weights’ is provided.

loss is zero for the case when label-value equals ignore_index.

l[i][d1][d2]...[dk]  = 0, when labels[n][d1][d2]...[dk] = ignore_index

where:

p = Softmax(scores)
y = Log(p)
c = labels[i][d1][d2]...[dk]

Finally, L is optionally reduced:

  • If reduction = ‘none’, the output is L with shape (N, D1, D2, …, Dk).

  • If reduction = ‘sum’, the output is scalar: Sum(L).

  • If reduction = ‘mean’, the output is scalar: ReduceMean(L), or if weight is provided: ReduceSum(L) / ReduceSum(W), where tensor W is of shape (N, D1, D2, …, Dk) and W[n][d1][d2]…[dk] = weights[labels[i][d1][d2]…[dk]].

Attributes

  • reduction: Type of reduction to apply to loss: none, sum, mean(default). ‘none’: no reduction will be applied, ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the number of elements in the output. Default value is name: "reduction" type: STRING s: "mean"

Inputs

Between 2 and 3 inputs.

  • scores (heterogeneous)T: The predicted outputs with shape [batch_size, class_size], or [batch_size, class_size, D1, D2 , …, Dk], where K is the number of dimensions.

  • labels (heterogeneous)Tind: The ground truth output tensor, with shape [batch_size], or [batch_size, D1, D2, …, Dk], where K is the number of dimensions. Labels element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the label values should either be in the range [0, C) or have the value ignore_index.

  • weights (optional, heterogeneous)T: A manual rescaling weight given to each class. If given, it has to be a 1D Tensor assigning weight to each of the classes. Otherwise, it is treated as if having all ones.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: Weighted loss float Tensor. If reduction is ‘none’, this has the shape of [batch_size], or [batch_size, D1, D2, …, Dk] in case of K-dimensional loss. Otherwise, it is a scalar.

  • log_prob (optional, heterogeneous)T: Log probability tensor. If the output of softmax is prob, its value is log(prob).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • Tind tensor(int32), tensor(int64): Constrain target to integer types

OnnxSoftmaxCrossEntropyLoss_12#

class skl2onnx.algebra.onnx_ops.OnnxSoftmaxCrossEntropyLoss_12(*args, **kwargs)#

Version

Onnx name: SoftmaxCrossEntropyLoss

This version of the operator has been available since version 12.

Summary

Loss function that measures the softmax cross entropy between ‘scores’ and ‘labels’. This operator first computes a loss tensor whose shape is identical to the labels input. If the input is 2-D with shape (N, C), the loss tensor may be a N-element vector L = (l_1, l_2, …, l_N). If the input is N-D tensor with shape (N, C, D1, D2, …, Dk), the loss tensor L may have (N, D1, D2, …, Dk) as its shape and L[i,][j_1][j_2]…[j_k] denotes a scalar element in L. After L is available, this operator can optionally do a reduction operator.

shape(scores): (N, C) where C is the number of classes, or (N, C, D1, D2,…, Dk),

with K >= 1 in case of K-dimensional loss.

shape(labels): (N) where each value is 0 <= labels[i] <= C-1, or (N, D1, D2,…, Dk),

with K >= 1 in case of K-dimensional loss.

The loss for one sample, l_i, can calculated as follows:

l[i][d1][d2]…[dk] = -y[i][c][d1][d2]..[dk], where i is the index of classes.

or

l[i][d1][d2]…[dk] = -y[i][c][d1][d2]..[dk] * weights[c], if ‘weights’ is provided.

loss is zero for the case when label-value equals ignore_index.

l[i][d1][d2]…[dk] = 0, when labels[n][d1][d2]…[dk] = ignore_index

where:

p = Softmax(scores) y = Log(p) c = labels[i][d1][d2]…[dk]

Finally, L is optionally reduced: If reduction = ‘none’, the output is L with shape (N, D1, D2, …, Dk). If reduction = ‘sum’, the output is scalar: Sum(L). If reduction = ‘mean’, the output is scalar: ReduceMean(L), or if weight is provided: ReduceSum(L) / ReduceSum(W), where tensor W is of shape (N, D1, D2, …, Dk) and W[n][d1][d2]…[dk] = weights[labels[i][d1][d2]…[dk]].

Attributes

  • reduction: Type of reduction to apply to loss: none, sum, mean(default). ‘none’: no reduction will be applied, ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the number of elements in the output. Default value is name: "reduction" type: STRING s: "mean"

Inputs

Between 2 and 3 inputs.

  • scores (heterogeneous)T: The predicted outputs with shape [batch_size, class_size], or [batch_size, class_size, D1, D2 , …, Dk], where K is the number of dimensions.

  • labels (heterogeneous)Tind: The ground truth output tensor, with shape [batch_size], or [batch_size, D1, D2, …, Dk], where K is the number of dimensions. Labels element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the label values should either be in the range [0, C) or have the value ignore_index.

  • weights (optional, heterogeneous)T: A manual rescaling weight given to each class. If given, it has to be a 1D Tensor assigning weight to each of the classes. Otherwise, it is treated as if having all ones.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: Weighted loss float Tensor. If reduction is ‘none’, this has the shape of [batch_size], or [batch_size, D1, D2, …, Dk] in case of K-dimensional loss. Otherwise, it is a scalar.

  • log_prob (optional, heterogeneous)T: Log probability tensor. If the output of softmax is prob, its value is log(prob).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • Tind tensor(int32), tensor(int64): Constrain target to integer types

OnnxSoftmaxCrossEntropyLoss_13#

class skl2onnx.algebra.onnx_ops.OnnxSoftmaxCrossEntropyLoss_13(*args, **kwargs)#

Version

Onnx name: SoftmaxCrossEntropyLoss

This version of the operator has been available since version 13.

Summary

Loss function that measures the softmax cross entropy between ‘scores’ and ‘labels’. This operator first computes a loss tensor whose shape is identical to the labels input. If the input is 2-D with shape (N, C), the loss tensor may be a N-element vector L = (l_1, l_2, …, l_N). If the input is N-D tensor with shape (N, C, D1, D2, …, Dk), the loss tensor L may have (N, D1, D2, …, Dk) as its shape and L[i,][j_1][j_2]…[j_k] denotes a scalar element in L. After L is available, this operator can optionally do a reduction operator.

  • shape(scores): (N, C) where C is the number of classes, or (N, C, D1, D2,…, Dk), with K >= 1 in case of K-dimensional loss.

  • shape(labels): (N) where each value is 0 <= labels[i] <= C-1, or (N, D1, D2,…, Dk), with K >= 1 in case of K-dimensional loss.

The loss for one sample, l_i, can calculated as follows:

l[i][d1][d2]...[dk] = -y[i][c][d1][d2]..[dk], where i is the index of classes.

or#

l[i][d1][d2]…[dk] = -y[i][c][d1][d2]..[dk] * weights[c], if ‘weights’ is provided.

loss is zero for the case when label-value equals ignore_index.

l[i][d1][d2]...[dk]  = 0, when labels[n][d1][d2]...[dk] = ignore_index

where:

p = Softmax(scores)
y = Log(p)
c = labels[i][d1][d2]...[dk]

Finally, L is optionally reduced:

  • If reduction = ‘none’, the output is L with shape (N, D1, D2, …, Dk).

  • If reduction = ‘sum’, the output is scalar: Sum(L).

  • If reduction = ‘mean’, the output is scalar: ReduceMean(L), or if weight is provided: ReduceSum(L) / ReduceSum(W), where tensor W is of shape (N, D1, D2, …, Dk) and W[n][d1][d2]…[dk] = weights[labels[i][d1][d2]…[dk]].

Attributes

  • reduction: Type of reduction to apply to loss: none, sum, mean(default). ‘none’: no reduction will be applied, ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the number of elements in the output. Default value is name: "reduction" type: STRING s: "mean"

Inputs

Between 2 and 3 inputs.

  • scores (heterogeneous)T: The predicted outputs with shape [batch_size, class_size], or [batch_size, class_size, D1, D2 , …, Dk], where K is the number of dimensions.

  • labels (heterogeneous)Tind: The ground truth output tensor, with shape [batch_size], or [batch_size, D1, D2, …, Dk], where K is the number of dimensions. Labels element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the label values should either be in the range [0, C) or have the value ignore_index.

  • weights (optional, heterogeneous)T: A manual rescaling weight given to each class. If given, it has to be a 1D Tensor assigning weight to each of the classes. Otherwise, it is treated as if having all ones.

Outputs

Between 1 and 2 outputs.

  • output (heterogeneous)T: Weighted loss float Tensor. If reduction is ‘none’, this has the shape of [batch_size], or [batch_size, D1, D2, …, Dk] in case of K-dimensional loss. Otherwise, it is a scalar.

  • log_prob (optional, heterogeneous)T: Log probability tensor. If the output of softmax is prob, its value is log(prob).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

  • Tind tensor(int32), tensor(int64): Constrain target to integer types

OnnxSoftmax_1#

class skl2onnx.algebra.onnx_ops.OnnxSoftmax_1(*args, **kwargs)#

Version

Onnx name: Softmax

This version of the operator has been available since version 1.

Summary

The operator computes the softmax (normalized exponential) values for each layer in the batch

of the given input. The input is a 2-D tensor (Tensor<float>) of size

(batch_size x input_feature_dimensions). The output tensor has the same shape and contains the softmax values of the corresponding input.

Input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input in [a_0, a_1, …, a_{k-1}, a_k, …, a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * … * a_{k-1}, a_k * … * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * … * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * … * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Attributes

  • axis: Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: The input tensor that’s coerced into a 2D matrix of size (NxD) as described above.

Outputs

  • output (heterogeneous)T: The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSoftmax_11#

class skl2onnx.algebra.onnx_ops.OnnxSoftmax_11(*args, **kwargs)#

Version

Onnx name: Softmax

This version of the operator has been available since version 11.

Summary

The operator computes the softmax (normalized exponential) values for each layer in the batch

of the given input.

The input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input in [a_0, a_1, …, a_{k-1}, a_k, …, a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * … * a_{k-1}, a_k * … * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * … * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * … * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors. The output tensor has the same shape and contains the softmax values of the corresponding input.

Attributes

  • axis: Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: 1

Inputs

  • input (heterogeneous)T: The input tensor that’s coerced into a 2D matrix of size (NxD) as described above.

Outputs

  • output (heterogeneous)T: The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSoftmax_13#

class skl2onnx.algebra.onnx_ops.OnnxSoftmax_13(*args, **kwargs)#

Version

Onnx name: Softmax

This version of the operator has been available since version 13.

Summary

The operator computes the normalized exponential values for the given input:

Softmax(input, axis) = Exp(input) / ReduceSum(Exp(input), axis=axis, keepdims=1)

The “axis” attribute indicates the dimension along which Softmax will be performed. The output tensor has the same shape and contains the Softmax values of the corresponding input.

Attributes

  • axis:

Describes the dimension Softmax will be performed on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).

Default value is

name: "axis" type: INT i: -1

Inputs

  • input (heterogeneous)T: The input tensor of rank >= axis.

Outputs

  • output (heterogeneous)T: The output values with the same shape as the input tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSoftplus#

class skl2onnx.algebra.onnx_ops.OnnxSoftplus(*args, **kwargs)#

Version

Onnx name: Softplus

This version of the operator has been available since version 1.

Summary

Softplus takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the softplus function, y = ln(exp(x) + 1), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: 1D input tensor

Outputs

  • Y (heterogeneous)T: 1D input tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSoftplus_1#

class skl2onnx.algebra.onnx_ops.OnnxSoftplus_1(*args, **kwargs)#

Version

Onnx name: Softplus

This version of the operator has been available since version 1.

Summary

Softplus takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the softplus function, y = ln(exp(x) + 1), is applied to the tensor elementwise.

Inputs

  • X (heterogeneous)T: 1D input tensor

Outputs

  • Y (heterogeneous)T: 1D input tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSoftsign#

class skl2onnx.algebra.onnx_ops.OnnxSoftsign(*args, **kwargs)#

Version

Onnx name: Softsign

This version of the operator has been available since version 1.

Summary

Calculates the softsign (x/(1+|x|)) of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The softsign (x/(1+|x|)) values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSoftsign_1#

class skl2onnx.algebra.onnx_ops.OnnxSoftsign_1(*args, **kwargs)#

Version

Onnx name: Softsign

This version of the operator has been available since version 1.

Summary

Calculates the softsign (x/(1+|x|)) of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The softsign (x/(1+|x|)) values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSpaceToDepth#

class skl2onnx.algebra.onnx_ops.OnnxSpaceToDepth(*args, **kwargs)#

Version

Onnx name: SpaceToDepth

This version of the operator has been available since version 13.

Summary

SpaceToDepth rearranges blocks of spatial data into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C * blocksize * blocksize, H/blocksize, W/blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSpaceToDepth_1#

class skl2onnx.algebra.onnx_ops.OnnxSpaceToDepth_1(*args, **kwargs)#

Version

Onnx name: SpaceToDepth

This version of the operator has been available since version 1.

Summary

SpaceToDepth rearranges blocks of spatial data into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C * blocksize * blocksize, H/blocksize, W/blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSpaceToDepth_13#

class skl2onnx.algebra.onnx_ops.OnnxSpaceToDepth_13(*args, **kwargs)#

Version

Onnx name: SpaceToDepth

This version of the operator has been available since version 13.

Summary

SpaceToDepth rearranges blocks of spatial data into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension.

Attributes

Inputs

  • input (heterogeneous)T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

  • output (heterogeneous)T: Output tensor of [N, C * blocksize * blocksize, H/blocksize, W/blocksize].

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSplit#

class skl2onnx.algebra.onnx_ops.OnnxSplit(*args, **kwargs)#

Version

Onnx name: Split

This version of the operator has been available since version 18.

Summary

Split a tensor into a list of tensors, along the specified ‘axis’. Either input ‘split’ or the attribute ‘num_outputs’ should be specified, but not both. If the attribute ‘num_outputs’ is specified, then the tensor is split into equal sized parts. If the tensor is not evenly splittable into num_outputs, the last chunk will be smaller. If the input ‘split’ is specified, it indicates the sizes of each output in the split.

Attributes

  • axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1] where r = rank(input). Default value is name: "axis" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: The tensor to split

  • split (optional, heterogeneous)tensor(int64): Optional length of each output. Values should be >= 0.Sum of the values must be equal to the dim value at ‘axis’ specified.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic, heterogeneous)T: One or more outputs forming list of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSplitToSequence#

class skl2onnx.algebra.onnx_ops.OnnxSplitToSequence(*args, **kwargs)#

Version

Onnx name: SplitToSequence

This version of the operator has been available since version 11.

Summary

Split a tensor into a sequence of tensors, along the specified ‘axis’. Lengths of the parts can be specified using the optional argument ‘split’. If the argument `split’ is not specified, a default scalar value of 1 is used as the value of `split’. ‘split’ must contain only positive numbers. ‘split’ is either a scalar (tensor of empty shape), or a 1-D tensor. If ‘split’ is a scalar, then ‘input’ will be split into chunks all of size ‘split’ if possible. The last chunk alone may be smaller than ‘split’ if the ‘input’ size along the given axis ‘axis’ is not divisible by ‘split’. If ‘split’ is a 1-dimensional tensor, the input tensor is split into ‘size(split)’ chunks, with lengths of the parts on ‘axis’ specified in ‘split’. In this scenario, the sum of entries in ‘split’ must be equal to the dimension size of input tensor on ‘axis’.

Attributes

  • axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1]. Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the split dimension or not. Default 1, which means we keep split dimension. If input ‘split’ is specified, this attribute is ignored. Default value is name: "keepdims" type: INT i: 1

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: The tensor to split

  • split (optional, heterogeneous)I: Length of each output. It can be either a scalar(tensor of empty shape), or a 1-D tensor. All values must be >= 0.

Outputs

  • output_sequence (heterogeneous)S: One or more outputs forming a sequence of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input types to all tensor types.

  • I tensor(int32), tensor(int64): Constrain split size to integral tensor.

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output types to all tensor types.

OnnxSplitToSequence_11#

class skl2onnx.algebra.onnx_ops.OnnxSplitToSequence_11(*args, **kwargs)#

Version

Onnx name: SplitToSequence

This version of the operator has been available since version 11.

Summary

Split a tensor into a sequence of tensors, along the specified ‘axis’. Lengths of the parts can be specified using the optional argument ‘split’. If the argument `split’ is not specified, a default scalar value of 1 is used as the value of `split’. ‘split’ must contain only positive numbers. ‘split’ is either a scalar (tensor of empty shape), or a 1-D tensor. If ‘split’ is a scalar, then ‘input’ will be split into chunks all of size ‘split’ if possible. The last chunk alone may be smaller than ‘split’ if the ‘input’ size along the given axis ‘axis’ is not divisible by ‘split’. If ‘split’ is a 1-dimensional tensor, the input tensor is split into ‘size(split)’ chunks, with lengths of the parts on ‘axis’ specified in ‘split’. In this scenario, the sum of entries in ‘split’ must be equal to the dimension size of input tensor on ‘axis’.

Attributes

  • axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1]. Default value is name: "axis" type: INT i: 0

  • keepdims: Keep the split dimension or not. Default 1, which means we keep split dimension. If input ‘split’ is specified, this attribute is ignored. Default value is name: "keepdims" type: INT i: 1

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: The tensor to split

  • split (optional, heterogeneous)I: Length of each output. It can be either a scalar(tensor of empty shape), or a 1-D tensor. All values must be >= 0.

Outputs

  • output_sequence (heterogeneous)S: One or more outputs forming a sequence of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input types to all tensor types.

  • I tensor(int32), tensor(int64): Constrain split size to integral tensor.

  • S seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128)): Constrain output types to all tensor types.

OnnxSplit_1#

class skl2onnx.algebra.onnx_ops.OnnxSplit_1(*args, **kwargs)#

Version

Onnx name: Split

This version of the operator has been available since version 1.

Summary

Split a tensor into a list of tensors, along the specified ‘axis’. The lengths of the split can be specified using argument ‘axis’ or optional second input blob to the operator. Otherwise, the tensor is split to equal sized parts.

Attributes

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: The tensor to split

  • split (optional, heterogeneous)T: Optional list of output lengths (see also arg ‘split’)

Outputs

Between 1 and 2147483647 outputs.

  • outputs… (variadic, heterogeneous)T: One or more outputs forming list of tensors after splitting

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

OnnxSplit_11#

class skl2onnx.algebra.onnx_ops.OnnxSplit_11(*args, **kwargs)#

Version

Onnx name: Split

This version of the operator has been available since version 11.

Summary

Split a tensor into a list of tensors, along the specified ‘axis’. Lengths of the parts can be specified using argument ‘split’. Otherwise, the tensor is split to equal sized parts.

Attributes

  • axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1] where r = rank(input). Default value is name: "axis" type: INT i: 0

Inputs

  • input (heterogeneous)T: The tensor to split

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic, heterogeneous)T: One or more outputs forming list of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSplit_13#

class skl2onnx.algebra.onnx_ops.OnnxSplit_13(*args, **kwargs)#

Version

Onnx name: Split

This version of the operator has been available since version 13.

Summary

Split a tensor into a list of tensors, along the specified ‘axis’. Lengths of the parts can be specified using input ‘split’. Otherwise, the tensor is split to equal sized parts.

Attributes

  • axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1] where r = rank(input). Default value is name: "axis" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: The tensor to split

  • split (optional, heterogeneous)tensor(int64): Optional length of each output. Values should be >= 0.Sum of the values must be equal to the dim value at ‘axis’ specified.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic, heterogeneous)T: One or more outputs forming list of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSplit_18#

class skl2onnx.algebra.onnx_ops.OnnxSplit_18(*args, **kwargs)#

Version

Onnx name: Split

This version of the operator has been available since version 18.

Summary

Split a tensor into a list of tensors, along the specified ‘axis’. Either input ‘split’ or the attribute ‘num_outputs’ should be specified, but not both. If the attribute ‘num_outputs’ is specified, then the tensor is split into equal sized parts. If the tensor is not evenly splittable into num_outputs, the last chunk will be smaller. If the input ‘split’ is specified, it indicates the sizes of each output in the split.

Attributes

  • axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1] where r = rank(input). Default value is name: "axis" type: INT i: 0

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: The tensor to split

  • split (optional, heterogeneous)tensor(int64): Optional length of each output. Values should be >= 0.Sum of the values must be equal to the dim value at ‘axis’ specified.

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic, heterogeneous)T: One or more outputs forming list of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSplit_2#

class skl2onnx.algebra.onnx_ops.OnnxSplit_2(*args, **kwargs)#

Version

Onnx name: Split

This version of the operator has been available since version 2.

Summary

Split a tensor into a list of tensors, along the specified ‘axis’. Lengths of the parts can be specified using argument ‘split’. Otherwise, the tensor is split to equal sized parts.

Attributes

  • axis: Which axis to split on. Default value is name: "axis" type: INT i: 0

Inputs

  • input (heterogeneous)T: The tensor to split

Outputs

Between 1 and 2147483647 outputs.

  • outputs (variadic, heterogeneous)T: One or more outputs forming list of tensors after splitting

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSqrt#

class skl2onnx.algebra.onnx_ops.OnnxSqrt(*args, **kwargs)#

Version

Onnx name: Sqrt

This version of the operator has been available since version 13.

Summary

Square root takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the square root is, y = x^0.5, is applied to the tensor elementwise. If x is negative, then it will return NaN.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSqrt_1#

class skl2onnx.algebra.onnx_ops.OnnxSqrt_1(*args, **kwargs)#

Version

Onnx name: Sqrt

This version of the operator has been available since version 1.

Summary

Square root takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the square root is, y = x^0.5, is applied to the tensor elementwise. If x is negative, then it will return NaN.

Attributes

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSqrt_13#

class skl2onnx.algebra.onnx_ops.OnnxSqrt_13(*args, **kwargs)#

Version

Onnx name: Sqrt

This version of the operator has been available since version 13.

Summary

Square root takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the square root is, y = x^0.5, is applied to the tensor elementwise. If x is negative, then it will return NaN.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSqrt_6#

class skl2onnx.algebra.onnx_ops.OnnxSqrt_6(*args, **kwargs)#

Version

Onnx name: Sqrt

This version of the operator has been available since version 6.

Summary

Square root takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the square root is, y = x^0.5, is applied to the tensor elementwise. If x is negative, then it will return NaN.

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSqueeze#

class skl2onnx.algebra.onnx_ops.OnnxSqueeze(*args, **kwargs)#

Version

Onnx name: Squeeze

This version of the operator has been available since version 21.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes an input axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: Tensors with at least max(dims) dimensions.

  • axes (optional, heterogeneous)tensor(int64): List of integers indicating the dimensions to squeeze. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • squeezed (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types up to IRv10.

OnnxSqueeze_1#

class skl2onnx.algebra.onnx_ops.OnnxSqueeze_1(*args, **kwargs)#

Version

Onnx name: Squeeze

This version of the operator has been available since version 1.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Attributes

Inputs

  • data (heterogeneous)T: Tensors with at least max(dims) dimensions.

Outputs

  • squeezed (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSqueeze_11#

class skl2onnx.algebra.onnx_ops.OnnxSqueeze_11(*args, **kwargs)#

Version

Onnx name: Squeeze

This version of the operator has been available since version 11.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Attributes

Inputs

  • data (heterogeneous)T: Tensors with at least max(dims) dimensions.

Outputs

  • squeezed (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSqueeze_13#

class skl2onnx.algebra.onnx_ops.OnnxSqueeze_13(*args, **kwargs)#

Version

Onnx name: Squeeze

This version of the operator has been available since version 13.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes an input axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: Tensors with at least max(dims) dimensions.

  • axes (optional, heterogeneous)tensor(int64): List of integers indicating the dimensions to squeeze. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • squeezed (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxSqueeze_21#

class skl2onnx.algebra.onnx_ops.OnnxSqueeze_21(*args, **kwargs)#

Version

Onnx name: Squeeze

This version of the operator has been available since version 21.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes an input axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous)T: Tensors with at least max(dims) dimensions.

  • axes (optional, heterogeneous)tensor(int64): List of integers indicating the dimensions to squeeze. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • squeezed (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types up to IRv10.

OnnxStringConcat#

class skl2onnx.algebra.onnx_ops.OnnxStringConcat(*args, **kwargs)#

Version

Onnx name: StringConcat

This version of the operator has been available since version 20.

Summary

StringConcat concatenates string tensors elementwise (with NumPy-style broadcasting support)

Inputs

  • X (heterogeneous)T: Tensor to prepend in concatenation

  • Y (heterogeneous)T: Tensor to append in concatenation

Outputs

  • Z (heterogeneous)T: Concatenated string tensor

Type Constraints

  • T tensor(string): Inputs and outputs must be UTF-8 strings

OnnxStringConcat_20#

class skl2onnx.algebra.onnx_ops.OnnxStringConcat_20(*args, **kwargs)#

Version

Onnx name: StringConcat

This version of the operator has been available since version 20.

Summary

StringConcat concatenates string tensors elementwise (with NumPy-style broadcasting support)

Inputs

  • X (heterogeneous)T: Tensor to prepend in concatenation

  • Y (heterogeneous)T: Tensor to append in concatenation

Outputs

  • Z (heterogeneous)T: Concatenated string tensor

Type Constraints

  • T tensor(string): Inputs and outputs must be UTF-8 strings

OnnxStringNormalizer#

class skl2onnx.algebra.onnx_ops.OnnxStringNormalizer(*args, **kwargs)#

Version

Onnx name: StringNormalizer

This version of the operator has been available since version 10.

Summary

StringNormalization performs string operations for basic cleaning. This operator has only one input (denoted by X) and only one output (denoted by Y). This operator first examines the elements in the X, and removes elements specified in “stopwords” attribute. After removing stop words, the intermediate result can be further lowercased, uppercased, or just returned depending the “case_change_action” attribute. This operator only accepts [C]- and [1, C]-tensor. If all elements in X are dropped, the output will be the empty value of string tensor with shape [1] if input shape is [C] and shape [1, 1] if input shape is [1, C].

Attributes

  • case_change_action: string enum that cases output to be lowercased/uppercases/unchanged. Valid values are “LOWER”, “UPPER”, “NONE”. Default is “NONE” Default value is name: "case_change_action" type: STRING s: "NONE"

  • is_case_sensitive: Boolean. Whether the identification of stop words in X is case-sensitive. Default is false Default value is name: "is_case_sensitive" type: INT i: 0

Inputs

  • X (heterogeneous)tensor(string): UTF-8 strings to normalize

Outputs

  • Y (heterogeneous)tensor(string): UTF-8 Normalized strings

OnnxStringNormalizer_10#

class skl2onnx.algebra.onnx_ops.OnnxStringNormalizer_10(*args, **kwargs)#

Version

Onnx name: StringNormalizer

This version of the operator has been available since version 10.

Summary

StringNormalization performs string operations for basic cleaning. This operator has only one input (denoted by X) and only one output (denoted by Y). This operator first examines the elements in the X, and removes elements specified in “stopwords” attribute. After removing stop words, the intermediate result can be further lowercased, uppercased, or just returned depending the “case_change_action” attribute. This operator only accepts [C]- and [1, C]-tensor. If all elements in X are dropped, the output will be the empty value of string tensor with shape [1] if input shape is [C] and shape [1, 1] if input shape is [1, C].

Attributes

  • case_change_action: string enum that cases output to be lowercased/uppercases/unchanged. Valid values are “LOWER”, “UPPER”, “NONE”. Default is “NONE” Default value is name: "case_change_action" type: STRING s: "NONE"

  • is_case_sensitive: Boolean. Whether the identification of stop words in X is case-sensitive. Default is false Default value is name: "is_case_sensitive" type: INT i: 0

Inputs

  • X (heterogeneous)tensor(string): UTF-8 strings to normalize

Outputs

  • Y (heterogeneous)tensor(string): UTF-8 Normalized strings

OnnxStringSplit#

class skl2onnx.algebra.onnx_ops.OnnxStringSplit(*args, **kwargs)#

Version

Onnx name: StringSplit

This version of the operator has been available since version 20.

Summary

StringSplit splits a string tensor’s elements into substrings based on a delimiter attribute and a maxsplit attribute.

The first output of this operator is a tensor of strings representing the substrings from splitting each input string on the delimiter substring. This tensor has one additional rank compared to the input tensor in order to store the substrings for each input element (where the input tensor is not empty). Note that, in order to ensure the same number of elements are present in the final dimension, this tensor will pad empty strings as illustrated in the examples below. Consecutive delimiters are not grouped together and are deemed to delimit empty strings, except if the delimiter is unspecified or is the empty string (“”). In the case where the delimiter is unspecified or the empty string, consecutive whitespace characters are regarded as a single separator and leading or trailing whitespace is removed in the output.

The second output tensor represents the number of substrings generated. maxsplit can be used to limit the number of splits performed - after the maxsplit`th split if the string is not fully split, the trailing suffix of input string after the final split point is also added. For elements where fewer splits are possible than specified in `maxsplit, it has no effect.

Attributes

Inputs

  • X (heterogeneous)T1: Tensor of strings to split.

Outputs

  • Y (heterogeneous)T2: Tensor of substrings representing the outcome of splitting the strings in the input on the delimiter. Note that to ensure the same number of elements are present in the final rank, this tensor will pad any necessary empty strings.

  • Z (heterogeneous)T3: The number of substrings generated for each input element.

Type Constraints

  • T1 tensor(string): The input must be a UTF-8 string tensor

  • T2 tensor(string): Tensor of substrings.

  • T3 tensor(int64): The number of substrings generated.

OnnxStringSplit_20#

class skl2onnx.algebra.onnx_ops.OnnxStringSplit_20(*args, **kwargs)#

Version

Onnx name: StringSplit

This version of the operator has been available since version 20.

Summary

StringSplit splits a string tensor’s elements into substrings based on a delimiter attribute and a maxsplit attribute.

The first output of this operator is a tensor of strings representing the substrings from splitting each input string on the delimiter substring. This tensor has one additional rank compared to the input tensor in order to store the substrings for each input element (where the input tensor is not empty). Note that, in order to ensure the same number of elements are present in the final dimension, this tensor will pad empty strings as illustrated in the examples below. Consecutive delimiters are not grouped together and are deemed to delimit empty strings, except if the delimiter is unspecified or is the empty string (“”). In the case where the delimiter is unspecified or the empty string, consecutive whitespace characters are regarded as a single separator and leading or trailing whitespace is removed in the output.

The second output tensor represents the number of substrings generated. maxsplit can be used to limit the number of splits performed - after the maxsplit`th split if the string is not fully split, the trailing suffix of input string after the final split point is also added. For elements where fewer splits are possible than specified in `maxsplit, it has no effect.

Attributes

Inputs

  • X (heterogeneous)T1: Tensor of strings to split.

Outputs

  • Y (heterogeneous)T2: Tensor of substrings representing the outcome of splitting the strings in the input on the delimiter. Note that to ensure the same number of elements are present in the final rank, this tensor will pad any necessary empty strings.

  • Z (heterogeneous)T3: The number of substrings generated for each input element.

Type Constraints

  • T1 tensor(string): The input must be a UTF-8 string tensor

  • T2 tensor(string): Tensor of substrings.

  • T3 tensor(int64): The number of substrings generated.

OnnxSub#

class skl2onnx.algebra.onnx_ops.OnnxSub(*args, **kwargs)#

Version

Onnx name: Sub

This version of the operator has been available since version 14.

Summary

Performs element-wise binary subtraction (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxSub_1#

class skl2onnx.algebra.onnx_ops.OnnxSub_1(*args, **kwargs)#

Version

Onnx name: Sub

This version of the operator has been available since version 1.

Summary

Performs element-wise binary subtraction (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSub_13#

class skl2onnx.algebra.onnx_ops.OnnxSub_13(*args, **kwargs)#

Version

Onnx name: Sub

This version of the operator has been available since version 13.

Summary

Performs element-wise binary subtraction (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to high-precision numeric tensors.

OnnxSub_14#

class skl2onnx.algebra.onnx_ops.OnnxSub_14(*args, **kwargs)#

Version

Onnx name: Sub

This version of the operator has been available since version 14.

Summary

Performs element-wise binary subtraction (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

(Opset 14 change): Extend supported types to include uint8, int8, uint16, and int16.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to all numeric tensors.

OnnxSub_6#

class skl2onnx.algebra.onnx_ops.OnnxSub_6(*args, **kwargs)#

Version

Onnx name: Sub

This version of the operator has been available since version 6.

Summary

Performs element-wise binary subtraction (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Attributes

  • broadcast: Pass 1 to enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: First operand, should share the type with the second operand.

  • B (heterogeneous)T: Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

  • C (heterogeneous)T: Result, has same dimensions and type as A

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxSub_7#

class skl2onnx.algebra.onnx_ops.OnnxSub_7(*args, **kwargs)#

Version

Onnx name: Sub

This version of the operator has been available since version 7.

Summary

Performs element-wise binary subtraction (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First operand.

  • B (heterogeneous)T: Second operand.

Outputs

  • C (heterogeneous)T: Result, has same element type as two inputs

Type Constraints

  • T tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to high-precision numeric tensors.

OnnxSum#

class skl2onnx.algebra.onnx_ops.OnnxSum(*args, **kwargs)#

Version

Onnx name: Sum

This version of the operator has been available since version 13.

Summary

Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for sum.

Outputs

  • sum (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSum_1#

class skl2onnx.algebra.onnx_ops.OnnxSum_1(*args, **kwargs)#

Version

Onnx name: Sum

This version of the operator has been available since version 1.

Summary

Element-wise sum of each of the input tensors. All inputs and outputs must have the same shape and data type.

Attributes

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Sum.

Outputs

  • sum (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSum_13#

class skl2onnx.algebra.onnx_ops.OnnxSum_13(*args, **kwargs)#

Version

Onnx name: Sum

This version of the operator has been available since version 13.

Summary

Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for sum.

Outputs

  • sum (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxSum_6#

class skl2onnx.algebra.onnx_ops.OnnxSum_6(*args, **kwargs)#

Version

Onnx name: Sum

This version of the operator has been available since version 6.

Summary

Element-wise sum of each of the input tensors. All inputs and outputs must have the same shape and data type.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for Sum.

Outputs

  • sum (heterogeneous)T: Output tensor. Same dimension as inputs.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxSum_8#

class skl2onnx.algebra.onnx_ops.OnnxSum_8(*args, **kwargs)#

Version

Onnx name: Sum

This version of the operator has been available since version 8.

Summary

Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

  • data_0 (variadic, heterogeneous)T: List of tensors for sum.

Outputs

  • sum (heterogeneous)T: Output tensor.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxTan#

class skl2onnx.algebra.onnx_ops.OnnxTan(*args, **kwargs)#

Version

Onnx name: Tan

This version of the operator has been available since version 7.

Summary

Calculates the tangent of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The tangent of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxTan_7#

class skl2onnx.algebra.onnx_ops.OnnxTan_7(*args, **kwargs)#

Version

Onnx name: Tan

This version of the operator has been available since version 7.

Summary

Calculates the tangent of the given input tensor, element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The tangent of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxTanh#

class skl2onnx.algebra.onnx_ops.OnnxTanh(*args, **kwargs)#

Version

Onnx name: Tanh

This version of the operator has been available since version 13.

Summary

Calculates the hyperbolic tangent of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic tangent values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxTanh_1#

class skl2onnx.algebra.onnx_ops.OnnxTanh_1(*args, **kwargs)#

Version

Onnx name: Tanh

This version of the operator has been available since version 1.

Summary

Calculates the hyperbolic tangent of the given input tensor element-wise.

Attributes

Inputs

  • input (heterogeneous)T: 1-D input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic tangent values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxTanh_13#

class skl2onnx.algebra.onnx_ops.OnnxTanh_13(*args, **kwargs)#

Version

Onnx name: Tanh

This version of the operator has been available since version 13.

Summary

Calculates the hyperbolic tangent of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic tangent values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double), tensor(bfloat16): Constrain input and output types to float tensors.

OnnxTanh_6#

class skl2onnx.algebra.onnx_ops.OnnxTanh_6(*args, **kwargs)#

Version

Onnx name: Tanh

This version of the operator has been available since version 6.

Summary

Calculates the hyperbolic tangent of the given input tensor element-wise.

Inputs

  • input (heterogeneous)T: Input tensor

Outputs

  • output (heterogeneous)T: The hyperbolic tangent values of the input tensor computed element-wise

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxTfIdfVectorizer#

class skl2onnx.algebra.onnx_ops.OnnxTfIdfVectorizer(*args, **kwargs)#

Version

Onnx name: TfIdfVectorizer

This version of the operator has been available since version 9.

Summary

This transform extracts n-grams from the input sequence and save them as a vector. Input can be either a 1-D or 2-D tensor. For 1-D input, output is the n-gram representation of that input. For 2-D input, the output is also a 2-D tensor whose i-th row is the n-gram representation of the i-th input row. More specifically, if input shape is [C], the corresponding output shape would be [max(ngram_indexes) + 1]. If input shape is [N, C], this operator produces a [N, max(ngram_indexes) + 1]-tensor.

In contrast to standard n-gram extraction, here, the indexes of extracting an n-gram from the original sequence are not necessarily consecutive numbers. The discontinuity between indexes are controlled by the number of skips. If the number of skips is 2, we should skip two tokens when scanning through the original sequence. Let’s consider an example. Assume that input sequence is [94, 17, 36, 12, 28] and the number of skips is 2. The associated 2-grams are [94, 12] and [17, 28] respectively indexed by [0, 3] and [1, 4]. If the number of skips becomes 0, the 2-grams generated are [94, 17], [17, 36], [36, 12], [12, 28] indexed by [0, 1], [1, 2], [2, 3], [3, 4], respectively.

The output vector (denoted by Y) stores the count of each n-gram; Y[ngram_indexes[i]] indicates the times that the i-th n-gram is found. The attribute ngram_indexes is used to determine the mapping between index i and the corresponding n-gram’s output coordinate. If pool_int64s is [94, 17, 17, 36], ngram_indexes is [1, 0], ngram_counts=[0, 0], then the Y[0] (first element in Y) and Y[1] (second element in Y) are the counts of [17, 36] and [94, 17], respectively. An n-gram which cannot be found in pool_strings/pool_int64s should be ignored and has no effect on the output. Note that we may consider all skips up to S when generating the n-grams.

The examples used above are true if mode is “TF”. If mode is “IDF”, all the counts larger than 1 would be truncated to 1 and the i-th element in weights would be used to scale (by multiplication) the count of the i-th n-gram in pool. If mode is “TFIDF”, this operator first computes the counts of all n-grams and then scale them by the associated values in the weights attribute.

Only one of pool_strings and pool_int64s can be set. If pool_int64s is set, the input should be an integer tensor. If pool_strings is set, the input must be a string tensor.

Attributes

Inputs

  • X (heterogeneous)T: Input for n-gram extraction

Outputs

  • Y (heterogeneous)T1: Ngram results

Type Constraints

  • T tensor(string), tensor(int32), tensor(int64): Input is ether string UTF-8 or int32/int64

  • T1 tensor(float): 1-D tensor of floats

OnnxTfIdfVectorizer_9#

class skl2onnx.algebra.onnx_ops.OnnxTfIdfVectorizer_9(*args, **kwargs)#

Version

Onnx name: TfIdfVectorizer

This version of the operator has been available since version 9.

Summary

This transform extracts n-grams from the input sequence and save them as a vector. Input can be either a 1-D or 2-D tensor. For 1-D input, output is the n-gram representation of that input. For 2-D input, the output is also a 2-D tensor whose i-th row is the n-gram representation of the i-th input row. More specifically, if input shape is [C], the corresponding output shape would be [max(ngram_indexes) + 1]. If input shape is [N, C], this operator produces a [N, max(ngram_indexes) + 1]-tensor.

In contrast to standard n-gram extraction, here, the indexes of extracting an n-gram from the original sequence are not necessarily consecutive numbers. The discontinuity between indexes are controlled by the number of skips. If the number of skips is 2, we should skip two tokens when scanning through the original sequence. Let’s consider an example. Assume that input sequence is [94, 17, 36, 12, 28] and the number of skips is 2. The associated 2-grams are [94, 12] and [17, 28] respectively indexed by [0, 3] and [1, 4]. If the number of skips becomes 0, the 2-grams generated are [94, 17], [17, 36], [36, 12], [12, 28] indexed by [0, 1], [1, 2], [2, 3], [3, 4], respectively.

The output vector (denoted by Y) stores the count of each n-gram; Y[ngram_indexes[i]] indicates the times that the i-th n-gram is found. The attribute ngram_indexes is used to determine the mapping between index i and the corresponding n-gram’s output coordinate. If pool_int64s is [94, 17, 17, 36], ngram_indexes is [1, 0], ngram_counts=[0, 0], then the Y[0] (first element in Y) and Y[1] (second element in Y) are the counts of [17, 36] and [94, 17], respectively. An n-gram which cannot be found in pool_strings/pool_int64s should be ignored and has no effect on the output. Note that we may consider all skips up to S when generating the n-grams.

The examples used above are true if mode is “TF”. If mode is “IDF”, all the counts larger than 1 would be truncated to 1 and the i-th element in weights would be used to scale (by multiplication) the count of the i-th n-gram in pool. If mode is “TFIDF”, this operator first computes the counts of all n-grams and then scale them by the associated values in the weights attribute.

Only one of pool_strings and pool_int64s can be set. If pool_int64s is set, the input should be an integer tensor. If pool_strings is set, the input must be a string tensor.

Attributes

Inputs

  • X (heterogeneous)T: Input for n-gram extraction

Outputs

  • Y (heterogeneous)T1: Ngram results

Type Constraints

  • T tensor(string), tensor(int32), tensor(int64): Input is ether string UTF-8 or int32/int64

  • T1 tensor(float): 1-D tensor of floats

OnnxThresholdedRelu#

class skl2onnx.algebra.onnx_ops.OnnxThresholdedRelu(*args, **kwargs)#

Version

Onnx name: ThresholdedRelu

This version of the operator has been available since version 10.

Summary

ThresholdedRelu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = x for x > alpha, y = 0 otherwise, is applied to the tensor elementwise.

Attributes

  • alpha: Threshold value Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxThresholdedRelu_10#

class skl2onnx.algebra.onnx_ops.OnnxThresholdedRelu_10(*args, **kwargs)#

Version

Onnx name: ThresholdedRelu

This version of the operator has been available since version 10.

Summary

ThresholdedRelu takes one input data (Tensor<T>) and produces one output data (Tensor<T>) where the rectified linear function, y = x for x > alpha, y = 0 otherwise, is applied to the tensor elementwise.

Attributes

  • alpha: Threshold value Default value is name: "alpha" type: FLOAT f: 1

Inputs

  • X (heterogeneous)T: Input tensor

Outputs

  • Y (heterogeneous)T: Output tensor

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

OnnxTile#

class skl2onnx.algebra.onnx_ops.OnnxTile(*args, **kwargs)#

Version

Onnx name: Tile

This version of the operator has been available since version 13.

Summary

Constructs a tensor by tiling a given tensor. This is the same as function tile in Numpy, but no broadcast. For example A = [[1, 2], [3, 4]], B = [1, 2], tile(A, B) = [[1, 2, 1, 2], [3, 4, 3, 4]]

Inputs

  • input (heterogeneous)T: Input tensor of any shape.

  • repeats (heterogeneous)T1: 1D int64 tensor of the same length as input’s dimension number, includes numbers of repeated copies along input’s dimensions.

Outputs

  • output (heterogeneous)T: Output tensor of the same dimensions and type as tensor input. output_dim[i] = input_dim[i] * repeats[i]

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • T1 tensor(int64): Constrain repeat’s type to int64 tensors.

OnnxTile_1#

class skl2onnx.algebra.onnx_ops.OnnxTile_1(*args, **kwargs)#

Version

Onnx name: Tile

This version of the operator has been available since version 1.

Summary

Repeat the elements of a tensor along an axis.

Inputs

  • input (heterogeneous)T: Input tensor of any shape.

  • tiles (heterogeneous)T: Number of repeated copies to make of the input tensor.

  • axis (heterogeneous)T: Axis along which to repeat.

Outputs

  • output (heterogeneous)T: Output tensor of same shape and type as input.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input types to float tensors.

  • T1 tensor(int64): Constrain tiles and axis’s type to int64 tensors.

OnnxTile_13#

class skl2onnx.algebra.onnx_ops.OnnxTile_13(*args, **kwargs)#

Version

Onnx name: Tile

This version of the operator has been available since version 13.

Summary

Constructs a tensor by tiling a given tensor. This is the same as function tile in Numpy, but no broadcast. For example A = [[1, 2], [3, 4]], B = [1, 2], tile(A, B) = [[1, 2, 1, 2], [3, 4, 3, 4]]

Inputs

  • input (heterogeneous)T: Input tensor of any shape.

  • repeats (heterogeneous)T1: 1D int64 tensor of the same length as input’s dimension number, includes numbers of repeated copies along input’s dimensions.

Outputs

  • output (heterogeneous)T: Output tensor of the same dimensions and type as tensor input. output_dim[i] = input_dim[i] * repeats[i]

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • T1 tensor(int64): Constrain repeat’s type to int64 tensors.

OnnxTile_6#

class skl2onnx.algebra.onnx_ops.OnnxTile_6(*args, **kwargs)#

Version

Onnx name: Tile

This version of the operator has been available since version 6.

Summary

Constructs a tensor by tiling a given tensor. This is the same as function tile in Numpy, but no broadcast. For example A = [[1, 2], [3, 4]], B = [1, 2], tile(A, B) = [[1, 2, 1, 2], [3, 4, 3, 4]]

Inputs

  • input (heterogeneous)T: Input tensor of any shape.

  • repeats (heterogeneous)T1: 1D int64 tensor of the same length as input’s dimension number, includes numbers of repeated copies along input’s dimensions.

Outputs

  • output (heterogeneous)T: Output tensor of the same dimensions and type as tensor input. output_dim[i] = input_dim[i] * repeats[i]

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

  • T1 tensor(int64): Constrain repeat’s type to int64 tensors.

OnnxTopK#

class skl2onnx.algebra.onnx_ops.OnnxTopK(*args, **kwargs)#

Version

Onnx name: TopK

This version of the operator has been available since version 11.

Summary

Retrieve the top-K largest or smallest elements along a specified axis. Given an input tensor of shape [a_1, a_2, …, a_n, r] and integer argument k, return two outputs:

  • Value tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] which contains the values of the top k elements along the specified axis

  • Index tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] which contains the indices of the top k elements (original indices from the input tensor).

  • If “largest” is 1 (the default value) then the k largest elements are returned.

  • If “sorted” is 1 (the default value) then the resulting k elements will be sorted.

  • If “sorted” is 0, order of returned ‘Values’ and ‘Indices’ are undefined.

Given two equivalent values, this operator uses the indices along the axis as a tiebreaker. That is, the element with the lower index will appear first.

Attributes

  • axis: Dimension on which to do the sort. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: -1

  • largest: Whether to return the top-K largest or smallest elements. Default value is name: "largest" type: INT i: 1

  • sorted: Whether to return the elements in sorted order. Default value is name: "sorted" type: INT i: 1

Inputs

  • X (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_n, r]

  • K (heterogeneous)tensor(int64): A 1-D tensor containing a single positive value corresponding to the number of top elements to retrieve

Outputs

  • Values (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing top K values from the input tensor

  • Indices (heterogeneous)I: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing the corresponding input tensor indices for the top K values.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to numeric tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxTopK_1#

class skl2onnx.algebra.onnx_ops.OnnxTopK_1(*args, **kwargs)#

Version

Onnx name: TopK

This version of the operator has been available since version 1.

Summary

Retrieve the top-K elements along a specified axis. Given an input tensor of shape [a_1, a_2, …, a_n, r] and integer argument k, return two outputs:

-Value tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n]

which contains the values of the top k elements along the specified axis

-Index tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] which

contains the indices of the top k elements (original indices from the input tensor).

Given two equivalent values, this operator uses the indices along the axis as

a tiebreaker. That is, the element with the lower index will appear first.

Attributes

  • axis: Dimension on which to do the sort. Default value is name: "axis" type: INT i: -1

Inputs

  • X (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_n, r]

Outputs

  • Values (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing top K values from the input tensor

  • Indices (heterogeneous)I: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing the corresponding input tensor indices for the top K values.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxTopK_10#

class skl2onnx.algebra.onnx_ops.OnnxTopK_10(*args, **kwargs)#

Version

Onnx name: TopK

This version of the operator has been available since version 10.

Summary

Retrieve the top-K elements along a specified axis. Given an input tensor of shape [a_1, a_2, …, a_n, r] and integer argument k, return two outputs:

-Value tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n]

which contains the values of the top k elements along the specified axis

-Index tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] which

contains the indices of the top k elements (original indices from the input tensor).

Given two equivalent values, this operator uses the indices along the axis as

a tiebreaker. That is, the element with the lower index will appear first.

Attributes

  • axis: Dimension on which to do the sort. Default value is name: "axis" type: INT i: -1

Inputs

  • X (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_n, r]

  • K (heterogeneous)tensor(int64): A 1-D tensor containing a single positive value corresponding to the number of top elements to retrieve

Outputs

  • Values (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing top K values from the input tensor

  • Indices (heterogeneous)I: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing the corresponding input tensor indices for the top K values.

Type Constraints

  • T tensor(float16), tensor(float), tensor(double): Constrain input and output types to float tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxTopK_11#

class skl2onnx.algebra.onnx_ops.OnnxTopK_11(*args, **kwargs)#

Version

Onnx name: TopK

This version of the operator has been available since version 11.

Summary

Retrieve the top-K largest or smallest elements along a specified axis. Given an input tensor of shape [a_1, a_2, …, a_n, r] and integer argument k, return two outputs:

  • Value tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] which contains the values of the top k elements along the specified axis

  • Index tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] which contains the indices of the top k elements (original indices from the input tensor).

  • If “largest” is 1 (the default value) then the k largest elements are returned.

  • If “sorted” is 1 (the default value) then the resulting k elements will be sorted.

  • If “sorted” is 0, order of returned ‘Values’ and ‘Indices’ are undefined.

Given two equivalent values, this operator uses the indices along the axis as a tiebreaker. That is, the element with the lower index will appear first.

Attributes

  • axis: Dimension on which to do the sort. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input). Default value is name: "axis" type: INT i: -1

  • largest: Whether to return the top-K largest or smallest elements. Default value is name: "largest" type: INT i: 1

  • sorted: Whether to return the elements in sorted order. Default value is name: "sorted" type: INT i: 1

Inputs

  • X (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_n, r]

  • K (heterogeneous)tensor(int64): A 1-D tensor containing a single positive value corresponding to the number of top elements to retrieve

Outputs

  • Values (heterogeneous)T: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing top K values from the input tensor

  • Indices (heterogeneous)I: Tensor of shape [a_1, a_2, …, a_{axis-1}, k, a_{axis+1}, … a_n] containing the corresponding input tensor indices for the top K values.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double): Constrain input and output types to numeric tensors.

  • I tensor(int64): Constrain index tensor to int64

OnnxTranspose#

class skl2onnx.algebra.onnx_ops.OnnxTranspose(*args, **kwargs)#

Version

Onnx name: Transpose

This version of the operator has been available since version 21.

Summary

Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).

Attributes

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • transposed (heterogeneous)T: Transposed output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types.

OnnxTranspose_1#

class skl2onnx.algebra.onnx_ops.OnnxTranspose_1(*args, **kwargs)#

Version

Onnx name: Transpose

This version of the operator has been available since version 1.

Summary

Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).

Attributes

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • transposed (heterogeneous)T: Transposed output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxTranspose_13#

class skl2onnx.algebra.onnx_ops.OnnxTranspose_13(*args, **kwargs)#

Version

Onnx name: Transpose

This version of the operator has been available since version 13.

Summary

Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).

Attributes

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • transposed (heterogeneous)T: Transposed output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxTranspose_21#

class skl2onnx.algebra.onnx_ops.OnnxTranspose_21(*args, **kwargs)#

Version

Onnx name: Transpose

This version of the operator has been available since version 21.

Summary

Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).

Attributes

Inputs

  • data (heterogeneous)T: An input tensor.

Outputs

  • transposed (heterogeneous)T: Transposed output.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types.

OnnxTreeEnsembleClassifier#

class skl2onnx.algebra.onnx_ops.OnnxTreeEnsembleClassifier(*args, **kwargs)#

Version

Onnx name: TreeEnsembleClassifier

This version of the operator has been available since version 3 of domain ai.onnx.ml.

Summary

Tree Ensemble classifier. Returns the top class for each of N inputs.

The attributes named ‘nodes_X’ form a sequence of tuples, associated by index into the sequences, which must all be of equal length. These tuples define the nodes.

Similarly, all fields prefixed with ‘class_’ are tuples of votes at the leaves. A leaf may have multiple votes, where each vote is weighted by the associated class_weights index.

One and only one of classlabels_strings or classlabels_int64s will be defined. The class_ids are indices into this list. All fields ending with <i>_as_tensor</i> can be used instead of the same parameter without the suffix if the element type is double and not float.

Attributes

  • post_transform: Indicates the transform to apply to the score. <br> One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT.’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Input of shape [N,F]

Outputs

  • Y (heterogeneous)T2: N, Top class for each point

  • Z (heterogeneous)tensor(float): The class score for each class, for each point, a tensor of shape [N,E].

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

  • T2 tensor(string), tensor(int64): The output type will be a tensor of strings or integers, depending on which of the classlabels_* attributes is used.

OnnxTreeEnsembleClassifier_1#

class skl2onnx.algebra.onnx_ops.OnnxTreeEnsembleClassifier_1(*args, **kwargs)#

Version

Onnx name: TreeEnsembleClassifier

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Tree Ensemble classifier. Returns the top class for each of N inputs.

The attributes named ‘nodes_X’ form a sequence of tuples, associated by index into the sequences, which must all be of equal length. These tuples define the nodes.

Similarly, all fields prefixed with ‘class_’ are tuples of votes at the leaves. A leaf may have multiple votes, where each vote is weighted by the associated class_weights index.

One and only one of classlabels_strings or classlabels_int64s will be defined. The class_ids are indices into this list.

Attributes

  • post_transform: Indicates the transform to apply to the score. <br> One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT.’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Input of shape [N,F]

Outputs

  • Y (heterogeneous)T2: N, Top class for each point

  • Z (heterogeneous)tensor(float): The class score for each class, for each point, a tensor of shape [N,E].

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

  • T2 tensor(string), tensor(int64): The output type will be a tensor of strings or integers, depending on which of the classlabels_* attributes is used.

OnnxTreeEnsembleClassifier_3#

class skl2onnx.algebra.onnx_ops.OnnxTreeEnsembleClassifier_3(*args, **kwargs)#

Version

Onnx name: TreeEnsembleClassifier

This version of the operator has been available since version 3 of domain ai.onnx.ml.

Summary

Tree Ensemble classifier. Returns the top class for each of N inputs.

The attributes named ‘nodes_X’ form a sequence of tuples, associated by index into the sequences, which must all be of equal length. These tuples define the nodes.

Similarly, all fields prefixed with ‘class_’ are tuples of votes at the leaves. A leaf may have multiple votes, where each vote is weighted by the associated class_weights index.

One and only one of classlabels_strings or classlabels_int64s will be defined. The class_ids are indices into this list. All fields ending with <i>_as_tensor</i> can be used instead of the same parameter without the suffix if the element type is double and not float.

Attributes

  • post_transform: Indicates the transform to apply to the score. <br> One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT.’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T1: Input of shape [N,F]

Outputs

  • Y (heterogeneous)T2: N, Top class for each point

  • Z (heterogeneous)tensor(float): The class score for each class, for each point, a tensor of shape [N,E].

Type Constraints

  • T1 tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

  • T2 tensor(string), tensor(int64): The output type will be a tensor of strings or integers, depending on which of the classlabels_* attributes is used.

OnnxTreeEnsembleRegressor#

class skl2onnx.algebra.onnx_ops.OnnxTreeEnsembleRegressor(*args, **kwargs)#

Version

Onnx name: TreeEnsembleRegressor

This version of the operator has been available since version 3 of domain ai.onnx.ml.

Summary

Tree Ensemble regressor. Returns the regressed values for each input in N.

All args with nodes_ are fields of a tuple of tree nodes, and it is assumed they are the same length, and an index i will decode the tuple across these inputs. Each node id can appear only once for each tree id.

All fields prefixed with target_ are tuples of votes at the leaves.

A leaf may have multiple votes, where each vote is weighted by the associated target_weights index.

All fields ending with <i>_as_tensor</i> can be used instead of the same parameter without the suffix if the element type is double and not float. All trees must have their node ids start at 0 and increment by 1.

Mode enum is BRANCH_LEQ, BRANCH_LT, BRANCH_GTE, BRANCH_GT, BRANCH_EQ, BRANCH_NEQ, LEAF

Attributes

  • aggregate_function: Defines how to aggregate leaf values within a target. <br>One of ‘AVERAGE,’ ‘SUM,’ ‘MIN,’ ‘MAX.’ Default value is name: "aggregate_function" type: STRING s: "SUM"

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T: Input of shape [N,F]

Outputs

  • Y (heterogeneous)tensor(float): N classes

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

OnnxTreeEnsembleRegressor_1#

class skl2onnx.algebra.onnx_ops.OnnxTreeEnsembleRegressor_1(*args, **kwargs)#

Version

Onnx name: TreeEnsembleRegressor

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Tree Ensemble regressor. Returns the regressed values for each input in N.

All args with nodes_ are fields of a tuple of tree nodes, and it is assumed they are the same length, and an index i will decode the tuple across these inputs. Each node id can appear only once for each tree id.

All fields prefixed with target_ are tuples of votes at the leaves.

A leaf may have multiple votes, where each vote is weighted by the associated target_weights index.

All trees must have their node ids start at 0 and increment by 1.

Mode enum is BRANCH_LEQ, BRANCH_LT, BRANCH_GTE, BRANCH_GT, BRANCH_EQ, BRANCH_NEQ, LEAF

Attributes

  • aggregate_function: Defines how to aggregate leaf values within a target. <br>One of ‘AVERAGE,’ ‘SUM,’ ‘MIN,’ ‘MAX.’ Default value is name: "aggregate_function" type: STRING s: "SUM"

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T: Input of shape [N,F]

Outputs

  • Y (heterogeneous)tensor(float): N classes

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

OnnxTreeEnsembleRegressor_3#

class skl2onnx.algebra.onnx_ops.OnnxTreeEnsembleRegressor_3(*args, **kwargs)#

Version

Onnx name: TreeEnsembleRegressor

This version of the operator has been available since version 3 of domain ai.onnx.ml.

Summary

Tree Ensemble regressor. Returns the regressed values for each input in N.

All args with nodes_ are fields of a tuple of tree nodes, and it is assumed they are the same length, and an index i will decode the tuple across these inputs. Each node id can appear only once for each tree id.

All fields prefixed with target_ are tuples of votes at the leaves.

A leaf may have multiple votes, where each vote is weighted by the associated target_weights index.

All fields ending with <i>_as_tensor</i> can be used instead of the same parameter without the suffix if the element type is double and not float. All trees must have their node ids start at 0 and increment by 1.

Mode enum is BRANCH_LEQ, BRANCH_LT, BRANCH_GTE, BRANCH_GT, BRANCH_EQ, BRANCH_NEQ, LEAF

Attributes

  • aggregate_function: Defines how to aggregate leaf values within a target. <br>One of ‘AVERAGE,’ ‘SUM,’ ‘MIN,’ ‘MAX.’ Default value is name: "aggregate_function" type: STRING s: "SUM"

  • post_transform: Indicates the transform to apply to the score. <br>One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is name: "post_transform" type: STRING s: "NONE"

Inputs

  • X (heterogeneous)T: Input of shape [N,F]

Outputs

  • Y (heterogeneous)tensor(float): N classes

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

OnnxTrilu#

class skl2onnx.algebra.onnx_ops.OnnxTrilu(*args, **kwargs)#

Version

Onnx name: Trilu

This version of the operator has been available since version 14.

Summary

Given a 2-D matrix or batches of 2-D matrices, returns the upper or lower triangular part of the tensor(s). The attribute “upper” determines whether the upper or lower part is retained. If set to true, the upper triangular matrix is retained. Lower triangular matrix is retained otherwise. Default value for the “upper” attribute is true. Trilu takes one input tensor of shape [*, N, M], where * is zero or more batch dimensions. The upper triangular part consists of the elements on and above the given diagonal (k). The lower triangular part consists of elements on and below the diagonal. All other elements in the matrix are set to zero. If k = 0, the triangular part on and above/below the main diagonal is retained. If upper is set to true, a positive k retains the upper triangular matrix excluding the main diagonal and (k-1) diagonals above it. A negative k value retains the main diagonal and |k| diagonals below it. If upper is set to false, a positive k retains the lower triangular matrix including the main diagonal and k diagonals above it. A negative k value excludes the main diagonal and (|k|-1) diagonals below it.

Attributes

  • upper: Boolean. Indicates whether upper or lower part of matrix is retained. Default is true. Default value is name: "upper" type: INT i: 1

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: Input tensor of rank 2 or higher.

  • k (optional, heterogeneous)tensor(int64): A 0-D tensor containing a single value corresponding to the number diagonals above or below the main diagonal to exclude or include. Default value is 0 if it’s not specified.

Outputs

  • output (heterogeneous)T: Output tensor of the same type and shape as the input tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxTrilu_14#

class skl2onnx.algebra.onnx_ops.OnnxTrilu_14(*args, **kwargs)#

Version

Onnx name: Trilu

This version of the operator has been available since version 14.

Summary

Given a 2-D matrix or batches of 2-D matrices, returns the upper or lower triangular part of the tensor(s). The attribute “upper” determines whether the upper or lower part is retained. If set to true, the upper triangular matrix is retained. Lower triangular matrix is retained otherwise. Default value for the “upper” attribute is true. Trilu takes one input tensor of shape [*, N, M], where * is zero or more batch dimensions. The upper triangular part consists of the elements on and above the given diagonal (k). The lower triangular part consists of elements on and below the diagonal. All other elements in the matrix are set to zero. If k = 0, the triangular part on and above/below the main diagonal is retained. If upper is set to true, a positive k retains the upper triangular matrix excluding the main diagonal and (k-1) diagonals above it. A negative k value retains the main diagonal and |k| diagonals below it. If upper is set to false, a positive k retains the lower triangular matrix including the main diagonal and k diagonals above it. A negative k value excludes the main diagonal and (|k|-1) diagonals below it.

Attributes

  • upper: Boolean. Indicates whether upper or lower part of matrix is retained. Default is true. Default value is name: "upper" type: INT i: 1

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous)T: Input tensor of rank 2 or higher.

  • k (optional, heterogeneous)tensor(int64): A 0-D tensor containing a single value corresponding to the number diagonals above or below the main diagonal to exclude or include. Default value is 0 if it’s not specified.

Outputs

  • output (heterogeneous)T: Output tensor of the same type and shape as the input tensor.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxUnique#

class skl2onnx.algebra.onnx_ops.OnnxUnique(*args, **kwargs)#

Version

Onnx name: Unique

This version of the operator has been available since version 11.

Summary

Find the unique elements of a tensor. When an optional attribute ‘axis’ is provided, unique subtensors sliced along the ‘axis’ are returned. Otherwise the input tensor is flattened and unique values of the flattened tensor are returned.

This operator returns the unique values or sliced unique subtensors of the input tensor and three optional outputs. The first output tensor ‘Y’ contains all unique values or subtensors of the input. The second optional output tensor ‘indices’ contains indices of ‘Y’ elements’ first occurrence in ‘X’. The third optional output tensor ‘inverse_indices’ contains, for elements of ‘X’, its corresponding indices in ‘Y’. The fourth optional output tensor ‘counts’ contains the count of each element of ‘Y’ in the input.

Outputs are either sorted in ascending order or optionally in the order of the first occurrence of the values in the input.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.unique.html

Example 1:

input_X = [2, 1, 1, 3, 4, 3]
attribute_sorted = 0
attribute_axis = None
output_Y = [2, 1, 3, 4]
output_indices = [0, 1, 3, 4]
output_inverse_indices = [0, 1, 1, 2, 3, 2]
output_counts = [1, 2, 2, 1]

Example 2:

input_X = [[1, 3], [2, 3]]
attribute_sorted = 1
attribute_axis = None
output_Y = [1, 2, 3]
output_indices = [0, 2, 1]
output_inverse_indices = [0, 2, 1, 2]
output_counts = [1, 1, 2]

Example 3:

input_X = [[1, 0, 0], [1, 0, 0], [2, 3, 4]]
attribute_sorted = 1
attribute_axis = 0
output_Y = [[1, 0, 0], [2, 3, 4]]
output_indices = [0, 2]
output_inverse_indices = [0, 0, 1]
output_counts = [2, 1]

Example 4:

input_x = [[[1., 1.], [0., 1.], [2., 1.], [0., 1.]],
            [[1., 1.], [0., 1.], [2., 1.], [0., 1.]]]
attribute_sorted = 1
attribute_axis = 1

intermediate data are presented below for better understanding: there are 4 subtensors sliced along axis 1 of input_x (shape = (2, 4, 2)):

A: [[1, 1], [1, 1]],
   [[0, 1], [0, 1]],
   [[2, 1], [2, 1]],
   [[0, 1], [0, 1]].

there are 3 unique subtensors:

[[1, 1], [1, 1]],
[[0, 1], [0, 1]],
[[2, 1], [2, 1]].

sorted unique subtensors:

B: [[0, 1], [0, 1]],
   [[1, 1], [1, 1]],
   [[2, 1], [2, 1]].

output_Y is constructed from B:

[[[0. 1.], [1. 1.], [2. 1.]],
 [[0. 1.], [1. 1.], [2. 1.]]]

output_indices is to map from B to A:

[1, 0, 2]

output_inverse_indices is to map from A to B:

[1, 0, 2, 0]

output_counts:

[2, 1, 1]

Attributes

  • sorted: (Optional) Whether to sort the unique elements in ascending order before returning as output. Must be one of 0, or 1 (default). Default value is name: "sorted" type: INT i: 1

Inputs

  • X (heterogeneous)T: A N-D input tensor that is to be processed.

Outputs

Between 1 and 4 outputs.

  • Y (heterogeneous)T: A tensor of the same type as ‘X’ containing all the unique values or subtensors sliced along a provided ‘axis’ in ‘X’, either sorted or maintained in the same order they occur in input ‘X’

  • indices (optional, heterogeneous)tensor(int64): A 1-D INT64 tensor containing indices of ‘Y’ elements’ first occurrence in ‘X’. When ‘axis’ is provided, it contains indices to subtensors in input ‘X’ on the ‘axis’. When ‘axis’ is not provided, it contains indices to values in the flattened input tensor.

  • inverse_indices (optional, heterogeneous)tensor(int64): A 1-D INT64 tensor containing, for elements of ‘X’, its corresponding indices in ‘Y’. When ‘axis’ is provided, it contains indices to subtensors in output ‘Y’ on the ‘axis’. When ‘axis’ is not provided, it contains indices to values in output ‘Y’.

  • counts (optional, heterogeneous)tensor(int64): A 1-D INT64 tensor containing the count of each element of ‘Y’ in input ‘X’

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input can be of any tensor type.

OnnxUnique_11#

class skl2onnx.algebra.onnx_ops.OnnxUnique_11(*args, **kwargs)#

Version

Onnx name: Unique

This version of the operator has been available since version 11.

Summary

Find the unique elements of a tensor. When an optional attribute ‘axis’ is provided, unique subtensors sliced along the ‘axis’ are returned. Otherwise the input tensor is flattened and unique values of the flattened tensor are returned.

This operator returns the unique values or sliced unique subtensors of the input tensor and three optional outputs. The first output tensor ‘Y’ contains all unique values or subtensors of the input. The second optional output tensor ‘indices’ contains indices of ‘Y’ elements’ first occurrence in ‘X’. The third optional output tensor ‘inverse_indices’ contains, for elements of ‘X’, its corresponding indices in ‘Y’. The fourth optional output tensor ‘counts’ contains the count of each element of ‘Y’ in the input.

Outputs are either sorted in ascending order or optionally in the order of the first occurrence of the values in the input.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.unique.html

Example 1:

input_X = [2, 1, 1, 3, 4, 3]
attribute_sorted = 0
attribute_axis = None
output_Y = [2, 1, 3, 4]
output_indices = [0, 1, 3, 4]
output_inverse_indices = [0, 1, 1, 2, 3, 2]
output_counts = [1, 2, 2, 1]

Example 2:

input_X = [[1, 3], [2, 3]]
attribute_sorted = 1
attribute_axis = None
output_Y = [1, 2, 3]
output_indices = [0, 2, 1]
output_inverse_indices = [0, 2, 1, 2]
output_counts = [1, 1, 2]

Example 3:

input_X = [[1, 0, 0], [1, 0, 0], [2, 3, 4]]
attribute_sorted = 1
attribute_axis = 0
output_Y = [[1, 0, 0], [2, 3, 4]]
output_indices = [0, 2]
output_inverse_indices = [0, 0, 1]
output_counts = [2, 1]

Example 4:

input_x = [[[1., 1.], [0., 1.], [2., 1.], [0., 1.]],
            [[1., 1.], [0., 1.], [2., 1.], [0., 1.]]]
attribute_sorted = 1
attribute_axis = 1

intermediate data are presented below for better understanding: there are 4 subtensors sliced along axis 1 of input_x (shape = (2, 4, 2)):

A: [[1, 1], [1, 1]],
   [[0, 1], [0, 1]],
   [[2, 1], [2, 1]],
   [[0, 1], [0, 1]].

there are 3 unique subtensors:

[[1, 1], [1, 1]],
[[0, 1], [0, 1]],
[[2, 1], [2, 1]].

sorted unique subtensors:

B: [[0, 1], [0, 1]],
   [[1, 1], [1, 1]],
   [[2, 1], [2, 1]].

output_Y is constructed from B:

[[[0. 1.], [1. 1.], [2. 1.]],
 [[0. 1.], [1. 1.], [2. 1.]]]

output_indices is to map from B to A:

[1, 0, 2]

output_inverse_indices is to map from A to B:

[1, 0, 2, 0]

output_counts:

[2, 1, 1]

Attributes

  • sorted: (Optional) Whether to sort the unique elements in ascending order before returning as output. Must be one of 0, or 1 (default). Default value is name: "sorted" type: INT i: 1

Inputs

  • X (heterogeneous)T: A N-D input tensor that is to be processed.

Outputs

Between 1 and 4 outputs.

  • Y (heterogeneous)T: A tensor of the same type as ‘X’ containing all the unique values or subtensors sliced along a provided ‘axis’ in ‘X’, either sorted or maintained in the same order they occur in input ‘X’

  • indices (optional, heterogeneous)tensor(int64): A 1-D INT64 tensor containing indices of ‘Y’ elements’ first occurrence in ‘X’. When ‘axis’ is provided, it contains indices to subtensors in input ‘X’ on the ‘axis’. When ‘axis’ is not provided, it contains indices to values in the flattened input tensor.

  • inverse_indices (optional, heterogeneous)tensor(int64): A 1-D INT64 tensor containing, for elements of ‘X’, its corresponding indices in ‘Y’. When ‘axis’ is provided, it contains indices to subtensors in output ‘Y’ on the ‘axis’. When ‘axis’ is not provided, it contains indices to values in output ‘Y’.

  • counts (optional, heterogeneous)tensor(int64): A 1-D INT64 tensor containing the count of each element of ‘Y’ in input ‘X’

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Input can be of any tensor type.

OnnxUnsqueeze#

class skl2onnx.algebra.onnx_ops.OnnxUnsqueeze(*args, **kwargs)#

Version

Onnx name: Unsqueeze

This version of the operator has been available since version 21.

Summary

Insert single-dimensional entries to the shape of an input tensor (data). Takes one required input axes - which contains a list of dimension indices and this operator will insert a dimension of value 1 into the corresponding index of the output tensor (expanded).

For example, given an input tensor (data) of shape [3, 4, 5], then Unsqueeze(data, axes=[0, 4]) outputs a tensor (expanded) containing same data as data but with shape [1, 3, 4, 5, 1].

The input axes should not contain any duplicate entries. It is an error if it contains duplicates. The rank of the output tensor (output_rank) is the rank of the input tensor (data) plus the number of values in axes. Each value in axes should be within the (inclusive) range [-output_rank , output_rank - 1]. The order of values in axes does not matter and can come in any order.

Inputs

  • data (heterogeneous)T: Original tensor

  • axes (heterogeneous)tensor(int64): List of integers indicating the dimensions to be inserted. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(expanded).

Outputs

  • expanded (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types up to IRv10.

OnnxUnsqueeze_1#

class skl2onnx.algebra.onnx_ops.OnnxUnsqueeze_1(*args, **kwargs)#

Version

Onnx name: Unsqueeze

This version of the operator has been available since version 1.

Summary

Insert single-dimensional entries to the shape of a tensor. Takes one required argument axes, a list of dimensions that will be inserted. Dimension indices in axes are as seen in the output tensor. For example:

Given a tensor such that tensor with shape [3, 4, 5], then Unsqueeze(tensor, axes=[0, 4]) has shape [1, 3, 4, 5, 1]

Attributes

Inputs

  • data (heterogeneous)T: Original tensor

Outputs

  • expanded (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxUnsqueeze_11#

class skl2onnx.algebra.onnx_ops.OnnxUnsqueeze_11(*args, **kwargs)#

Version

Onnx name: Unsqueeze

This version of the operator has been available since version 11.

Summary

Insert single-dimensional entries to the shape of an input tensor (data). Takes one required argument axes - which contains a list of dimension indices and this operator will insert a dimension of value 1 into the corresponding index of the output tensor (expanded).

For example:

Given an input tensor (data) of shape [3, 4, 5], then Unsqueeze(data, axes=[0, 4]) outputs a tensor (expanded) containing same data as data but with shape [1, 3, 4, 5, 1].

The attribute axes should not contain any duplicate entries. It is an error if it contains duplicates. The rank of the output tensor (output_rank) is the rank of the input tensor (data) plus the number of values in axes. Each value in axes should be within the (inclusive) range [-output_rank , output_rank - 1]. The order of values in axes does not matter and can come in any order.

Attributes

Inputs

  • data (heterogeneous)T: Original tensor

Outputs

  • expanded (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxUnsqueeze_13#

class skl2onnx.algebra.onnx_ops.OnnxUnsqueeze_13(*args, **kwargs)#

Version

Onnx name: Unsqueeze

This version of the operator has been available since version 13.

Summary

Insert single-dimensional entries to the shape of an input tensor (data). Takes one required input axes - which contains a list of dimension indices and this operator will insert a dimension of value 1 into the corresponding index of the output tensor (expanded).

For example, given an input tensor (data) of shape [3, 4, 5], then Unsqueeze(data, axes=[0, 4]) outputs a tensor (expanded) containing same data as data but with shape [1, 3, 4, 5, 1].

The input axes should not contain any duplicate entries. It is an error if it contains duplicates. The rank of the output tensor (output_rank) is the rank of the input tensor (data) plus the number of values in axes. Each value in axes should be within the (inclusive) range [-output_rank , output_rank - 1]. The order of values in axes does not matter and can come in any order.

Inputs

  • data (heterogeneous)T: Original tensor

  • axes (heterogeneous)tensor(int64): List of integers indicating the dimensions to be inserted. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(expanded).

Outputs

  • expanded (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxUnsqueeze_21#

class skl2onnx.algebra.onnx_ops.OnnxUnsqueeze_21(*args, **kwargs)#

Version

Onnx name: Unsqueeze

This version of the operator has been available since version 21.

Summary

Insert single-dimensional entries to the shape of an input tensor (data). Takes one required input axes - which contains a list of dimension indices and this operator will insert a dimension of value 1 into the corresponding index of the output tensor (expanded).

For example, given an input tensor (data) of shape [3, 4, 5], then Unsqueeze(data, axes=[0, 4]) outputs a tensor (expanded) containing same data as data but with shape [1, 3, 4, 5, 1].

The input axes should not contain any duplicate entries. It is an error if it contains duplicates. The rank of the output tensor (output_rank) is the rank of the input tensor (data) plus the number of values in axes. Each value in axes should be within the (inclusive) range [-output_rank , output_rank - 1]. The order of values in axes does not matter and can come in any order.

Inputs

  • data (heterogeneous)T: Original tensor

  • axes (heterogeneous)tensor(int64): List of integers indicating the dimensions to be inserted. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(expanded).

Outputs

  • expanded (heterogeneous)T: Reshaped tensor with same data as input.

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4): Constrain input and output types to all tensor types up to IRv10.

OnnxUpsample#

class skl2onnx.algebra.onnx_ops.OnnxUpsample(*args, **kwargs)#

Version

Onnx name: Upsample

This version of the operator has been deprecated since version 10.

Summary

Upsample the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * scale).

Attributes

  • mode: Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc) Default value is name: "mode" type: STRING s: "nearest"

Inputs

  • X (heterogeneous)T: N-D tensor

  • scales (heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than or equal to 1. The number of elements of ‘scales’ should be the same as the rank of input ‘X’.

Outputs

  • Y (heterogeneous)T: N-D tensor after resizing

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

OnnxUpsample_10#

class skl2onnx.algebra.onnx_ops.OnnxUpsample_10(*args, **kwargs)#

Version

Onnx name: Upsample

This version of the operator has been deprecated since version 10.

Summary

Upsample the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * scale).

Attributes

  • mode: Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc) Default value is name: "mode" type: STRING s: "nearest"

Inputs

  • X (heterogeneous)T: N-D tensor

  • scales (heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than or equal to 1. The number of elements of ‘scales’ should be the same as the rank of input ‘X’.

Outputs

  • Y (heterogeneous)T: N-D tensor after resizing

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

OnnxUpsample_7#

class skl2onnx.algebra.onnx_ops.OnnxUpsample_7(*args, **kwargs)#

Version

Onnx name: Upsample

This version of the operator has been available since version 7.

Summary

Upsample the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * scale).

Attributes

  • mode: Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc) Default value is name: "mode" type: STRING s: "nearest"

Inputs

  • X (heterogeneous)T: N-D tensor

Outputs

  • Y (heterogeneous)T: N-D tensor after resizing

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxUpsample_9#

class skl2onnx.algebra.onnx_ops.OnnxUpsample_9(*args, **kwargs)#

Version

Onnx name: Upsample

This version of the operator has been available since version 9.

Summary

Upsample the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * scale).

Attributes

  • mode: Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc) Default value is name: "mode" type: STRING s: "nearest"

Inputs

  • X (heterogeneous)T: N-D tensor

  • scales (heterogeneous)tensor(float): The scale array along each dimension. It takes value greater than or equal to 1. The number of elements of ‘scales’ should be the same as the rank of input ‘X’.

Outputs

  • Y (heterogeneous)T: N-D tensor after resizing

Type Constraints

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input ‘X’ and output ‘Y’ to all tensor types.

OnnxWhere#

class skl2onnx.algebra.onnx_ops.OnnxWhere(*args, **kwargs)#

Version

Onnx name: Where

This version of the operator has been available since version 16.

Summary

Return elements, either from X or Y, depending on condition. Where behaves like [numpy.where](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) with three parameters.

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • condition (heterogeneous)B: When True (nonzero), yield X, otherwise yield Y

  • X (heterogeneous)T: values selected at indices where condition is True

  • Y (heterogeneous)T: values selected at indices where condition is False

Outputs

  • output (heterogeneous)T: Tensor of shape equal to the broadcasted shape of condition, X, and Y.

Type Constraints

  • B tensor(bool): Constrain to boolean tensors.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types (including bfloat).

OnnxWhere_16#

class skl2onnx.algebra.onnx_ops.OnnxWhere_16(*args, **kwargs)#

Version

Onnx name: Where

This version of the operator has been available since version 16.

Summary

Return elements, either from X or Y, depending on condition. Where behaves like [numpy.where](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) with three parameters.

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • condition (heterogeneous)B: When True (nonzero), yield X, otherwise yield Y

  • X (heterogeneous)T: values selected at indices where condition is True

  • Y (heterogeneous)T: values selected at indices where condition is False

Outputs

  • output (heterogeneous)T: Tensor of shape equal to the broadcasted shape of condition, X, and Y.

Type Constraints

  • B tensor(bool): Constrain to boolean tensors.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types (including bfloat).

OnnxWhere_9#

class skl2onnx.algebra.onnx_ops.OnnxWhere_9(*args, **kwargs)#

Version

Onnx name: Where

This version of the operator has been available since version 9.

Summary

Return elements, either from X or Y, depending on condition. Where behaves like [numpy.where](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) with three parameters.

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • condition (heterogeneous)B: When True (nonzero), yield X, otherwise yield Y

  • X (heterogeneous)T: values selected at indices where condition is True

  • Y (heterogeneous)T: values selected at indices where condition is False

Outputs

  • output (heterogeneous)T: Tensor of shape equal to the broadcasted shape of condition, X, and Y.

Type Constraints

  • B tensor(bool): Constrain to boolean tensors.

  • T tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128): Constrain input and output types to all tensor types.

OnnxXor#

class skl2onnx.algebra.onnx_ops.OnnxXor(*args, **kwargs)#

Version

Onnx name: Xor

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the xor logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxXor_1#

class skl2onnx.algebra.onnx_ops.OnnxXor_1(*args, **kwargs)#

Version

Onnx name: Xor

This version of the operator has been available since version 1.

Summary

Returns the tensor resulted from performing the xor logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Attributes

  • broadcast: Enable broadcasting Default value is name: "broadcast" type: INT i: 0

Inputs

  • A (heterogeneous)T: Left input tensor for the logical operator.

  • B (heterogeneous)T: Right input tensor for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxXor_7#

class skl2onnx.algebra.onnx_ops.OnnxXor_7(*args, **kwargs)#

Version

Onnx name: Xor

This version of the operator has been available since version 7.

Summary

Returns the tensor resulted from performing the xor logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

  • A (heterogeneous)T: First input operand for the logical operator.

  • B (heterogeneous)T: Second input operand for the logical operator.

Outputs

  • C (heterogeneous)T1: Result tensor.

Type Constraints

  • T tensor(bool): Constrain input to boolean tensor.

  • T1 tensor(bool): Constrain output to boolean tensor.

OnnxZipMap#

class skl2onnx.algebra.onnx_ops.OnnxZipMap(*args, **kwargs)#

Version

Onnx name: ZipMap

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Creates a map from the input and the attributes.

The values are provided by the input tensor, while the keys are specified by the attributes. Must provide keys in either classlabels_strings or classlabels_int64s (but not both).

The columns of the tensor correspond one-by-one to the keys specified by the attributes. There must be as many columns as keys.

Attributes

Inputs

  • X (heterogeneous)tensor(float): The input values

Outputs

  • Z (heterogeneous)T: The output map

Type Constraints

  • T seq(map(string, float)), seq(map(int64, float)): The output will be a sequence of string or integer maps to float.

OnnxZipMap_1#

class skl2onnx.algebra.onnx_ops.OnnxZipMap_1(*args, **kwargs)#

Version

Onnx name: ZipMap

This version of the operator has been available since version 1 of domain ai.onnx.ml.

Summary

Creates a map from the input and the attributes.

The values are provided by the input tensor, while the keys are specified by the attributes. Must provide keys in either classlabels_strings or classlabels_int64s (but not both).

The columns of the tensor correspond one-by-one to the keys specified by the attributes. There must be as many columns as keys.

Attributes

Inputs

  • X (heterogeneous)tensor(float): The input values

Outputs

  • Z (heterogeneous)T: The output map

Type Constraints

  • T seq(map(string, float)), seq(map(int64, float)): The output will be a sequence of string or integer maps to float.