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

tools

Benchmark

onnx_array_api.ext_test_case.measure_time(stmt:Callable,context:Dict[str,Any]|None=None,repeat:int=10,number:int=50,div_by_number:bool=True,max_time:float|None=None)Dict[str,Any][source]

Measures a statement and returns the results as a dictionary.

Parameters:
  • stmt – string

  • context – variable to know in a dictionary

  • repeat – average overrepeat experiment

  • number – number of executions in one row

  • div_by_number – divide by the number of executions

  • max_time – execute the statement until the total goesbeyond this time (approximatively),repeat is ignored,div_by_number must be set to True

Returns:

dictionary

<<<

fromonnx_array_api.ext_test_caseimportmeasure_timefrommathimportcosres=measure_time(lambda:cos(0.5))print(res)

>>>

{'average':np.float64(1.0851398110389709e-07),'deviation':np.float64(1.562810334436561e-07),'min_exec':np.float64(5.359994247555733e-08),'max_exec':np.float64(5.773200246039778e-07),'repeat':10,'number':50,'ttime':np.float64(1.0851398110389708e-06),'context_size':64}

SeeTimer.repeatfor a better understanding of parameterrepeat andnumber.The function returns a duration corresponding tonumber times the execution of the main statement.

Changed in version 0.4:Parametermax_time was added.

Manipulations

onnx_array_api.tools.replace_constants.replace_initializer_by_constant_of_shape(onx,threshold=128,op_type='ConstantOfShape',domain='')[source]

Replaces initializers by nodesConstantOfShape to reducethe size and still write a unit test.

Parameters:
  • onx – ModelProto

  • threshold – every initializer under this threshold is not impacted

  • op_type – replace by this node

  • domain – replace by this domain

Returns:

onx, modified ModelProto

Examples

onnx_array_api.ext_test_case.example_path(path:str)str[source]

Fixes a path for the examples.Helps running the example within a unit test.

Unit tests

onnx_array_api.ext_test_case.ignore_warnings(warns:List[Warning])Callable[source]

Catches warnings.

Parameters:

warns – warnings to ignore

classonnx_array_api.ext_test_case.ExtTestCase(methodName='runTest')[source]
capture(fct:Callable)[source]

Runs a function and capture standard output and error.

Parameters:

fct – function to run

Returns:

result offct, output, error

relative_path(filename:str,*names:List[str])str[source]

Returns a path relative to the folderfilenameis in. The function checks the path existence.

Parameters:
  • filename – filename

  • names – additional path pieces

Returns:

new path

classmethodtearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

On this page

[8]ページ先頭

©2009-2025 Movatter.jp