experimental_experiment.reference

ExtendedReferenceEvaluator

class experimental_experiment.reference.ExtendedReferenceEvaluator(proto: Any, opsets: Dict[str, int] | None = None, functions: List[ReferenceEvaluator | FunctionProto] | None = None, verbose: int = 0, new_ops: List[OpRun] | None = None, **kwargs)[source]

This class replaces the python implementation by custom implementation. The evaluator allows to test scenarios outside what an onnx backend bound to the official onnx operators definition could do such as optimization patterns involving onnxruntime contrib operators.

from experimental_experiment.reference import ExtendedReferenceEvaluator
ref = ExtendedReferenceEvaluator(...)

The class overloads or adds the following operators by default:

<<<

import pprint
from experimental_experiment.reference import ExtendedReferenceEvaluator

pprint.pprint(ExtendedReferenceEvaluator.default_ops)

>>>

    [<class 'experimental_experiment.reference.ops.op_add_add_mul_mul.AddAdd'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.AddMul'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.AddSharedInput'>,
     <class 'experimental_experiment.reference.ops.op_average_pool_grad.AveragePoolGrad'>,
     <class 'experimental_experiment.reference.ops.op_concat.Concat'>,
     <class 'experimental_experiment.reference.ops.op_cast_like.CastLike_15'>,
     <class 'experimental_experiment.reference.ops.op_cast_like.CastLike_19'>,
     <class 'experimental_experiment.reference.ops.op_constant_of_shape.ConstantOfShape'>,
     <class 'experimental_experiment.reference.ops.op_fused_matmul.FusedMatMul'>,
     <class 'experimental_experiment.reference.ops.op_gather_grad.GatherGrad'>,
     <class 'experimental_experiment.reference.ops.op_scatternd_of_shape.MaskedScatterNDOfShape'>,
     <class 'experimental_experiment.reference.ops.op_memcpy_host.MemcpyFromHost'>,
     <class 'experimental_experiment.reference.ops.op_memcpy_host.MemcpyToHost'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.MulAdd'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.MulMul'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.MulSharedInput'>,
     <class 'experimental_experiment.reference.ops.op_mul_sigmoid.MulSigmoid'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.MulSub'>,
     <class 'experimental_experiment.reference.ops.op_negxplus1.NegXplus1'>,
     <class 'experimental_experiment.reference.ops.op_quick_gelu.QuickGelu'>,
     <class 'experimental_experiment.reference.ops.op_replace_zero.ReplaceZero'>,
     <class 'experimental_experiment.reference.ops.op_rotary.Rotary'>,
     <class 'experimental_experiment.reference.ops.op_scatter_elements.ScatterElements'>,
     <class 'experimental_experiment.reference.ops.op_scatternd_of_shape.ScatterNDOfShape'>,
     <class 'experimental_experiment.reference.ops.op_simplified_layer_normalization.SimplifiedLayerNormalization'>,
     <class 'experimental_experiment.reference.ops.op_slice.Slice_1'>,
     <class 'experimental_experiment.reference.ops.op_slice.Slice_10'>,
     <class 'experimental_experiment.reference.ops.op_add_add_mul_mul.SubMul'>,
     <class 'experimental_experiment.reference.ops.op_transpose_cast.Transpose2DCastFP16'>,
     <class 'experimental_experiment.reference.ops.op_transpose_cast.Transpose2DCastFP32'>,
     <class 'experimental_experiment.reference.ops.op_tri_matrix.TriMatrix'>]
run(*args, **kwargs)[source]

See onnx.reference.ReferenceEvaluator.run().

Other functions

experimental_experiment.reference.from_array_extended(tensor: ndarray, name: str | None = None) TensorProto[source]

Converts an array into a TensorProto.

Parameters:
  • tensor – numpy array

  • name – name

Returns:

TensorProto