Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
onnx-array-api 0.3.1 documentation
Logo
onnx-array-api 0.3.1 documentation

Contents

More

Back to top

reference

ExtendedReferenceEvaluator

classonnx_array_api.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 Array API extends many operator to all types not supportedby the onnx specifications. The evaluator allows to testscenarios outside what an onnx backend bound to the official onnxoperators definition could do.

fromonnx.referenceimportReferenceEvaluatorfromonnx.reference.c_opsimportConvref=ReferenceEvaluator(...,new_ops=[Conv])
run(*args,**kwargs)[source]

Seeonnx.reference.ReferenceEvaluator.run().

ResultType

classonnx_array_api.reference.ResultType(*values)[source]

ResultExecution

classonnx_array_api.reference.ResultExecution(kind:ResultType,dtype:object,shape:tuple,summary:str,op_type:str,name:str,value:Any|None=None)[source]

The description of a result.

YieldEvaluator

classonnx_array_api.reference.YieldEvaluator(onnx_model:ModelProto,recursive:bool=False,cls:type[ExtendedReferenceEvaluator]|None=None)[source]

This class implements methodenumerate_results which iterates onintermediates results. By default, it usesonnx_array_api.reference.ExtendedReferenceEvaluator.

Parameters:
  • onnx_model – model to run

  • recursive – dig into subgraph and functions as well

  • cls – evaluator to use, default value isExtendedReferenceEvaluator

enumerate_results(output_names:List[str]|None=None,feed_inputs:Dict[str,Any]|None=None,raise_exc:bool=True)Iterator[Tuple[ResultType,str,Any]][source]

Executes the onnx model and enumerate all the intermediate results.

Args:

output_names: requested outputs by names, None for allfeed_inputs: dictionary{ input name: input value }

Returns:

iterator on tuple(result kind, name, value, node.op_type or None)

enumerate_summarized(output_names:List[str]|None=None,feed_inputs:Dict[str,Any]|None=None,raise_exc:bool=True,keep_tensor:bool=False)Iterator[ResultExecution][source]

Executes the onnx model and enumerate intermediate results without their names.

Parameters:
  • output_names – requested outputs by names, None for all

  • feed_inputs – dictionary{inputname:inputvalue}

  • raise_exc – raises an exception if the execution fails or stop where it is

  • keep_tensor – keep the tensor in order to compute precise distances

Returns:

iterator on ResultExecution

DistanceExecution

classonnx_array_api.reference.DistanceExecution(max_lag:int=50)[source]

Computes a distance between two results.

distance_pair(r1:ResultExecution,r2:ResultExecution)float[source]

(ResultType.RESULT, np.dtype(“float32”), (2, 2), “CEIO”, “Abs”),

Parameters:
  • r1 – first result

  • r2 – second result

Returns:

distance

distance_sequence(s1:List[ResultExecution],s2:List[ResultExecution])Tuple[float,List[Tuple[int,int]]][source]

Computes the distance between two sequences of results.

Parameters:
  • s1 – first sequence

  • s2 – second sequence

Returns:

distance and alignment

to_str(s1:List[ResultExecution],s2:List[ResultExecution],alignment:List[Tuple[int,int]],column_size:int=60)str[source]

Prints out the alignment between two sequences into a string.:param s1: first sequence:param s2: second sequence:param alignment: alignment:param column_size: column size:return: test

compare_onnx_execution

onnx_array_api.reference.compare_onnx_execution(model1:ModelProto,model2:ModelProto,inputs:List[Any]|Tuple[Dict[str,Any]]|None=None,verbose:int=0,raise_exc:bool=True,mode:str='execute',keep_tensor:bool=False,cls:type[ReferenceEvaluator]|None=None)Tuple[List[ResultExecution],List[ResultExecution],List[Tuple[int,int]]][source]

Compares the execution of two onnx models.The function assumes both models takes the same inputs.SeeCompares the conversions of the same model with different options to see a full example usingthis function.

Parameters:
  • model1 – first model

  • model2 – second model

  • inputs – inputs to use, a list of inputs if both models havethe same number of inputs or two dictionaries, one for each model

  • verbose – verbosity

  • raise_exc – raise exception if the execution fails or stop at the error

  • mode – the model should be executed but the function can be executedbut the comparison may append on nodes only

  • keep_tensor – keeps the tensor in order to compute a precise distance

  • cls – evaluator class to use

Returns:

four results, a sequence of resultsfor the first model and the second model,the alignment between the two, DistanceExecution

On this page

[8]ページ先頭

©2009-2025 Movatter.jp