validation.cpu

C API

_validation

class onnx_extended.validation.cpu._validation.ElementTime
onnx_extended.validation.cpu._validation.benchmark_cache(size: int, verbose: bool = True) float

Runs a benchmark to measure the cache performance. The function measures the time for N random accesses in array of size N and returns the time divided by N. It copies random elements taken from the array size to random position in another of the same size. It does that size times and return the average time per move. See example Measuring CPU performance.

Parameters:

size – array size

Returns:

average time per move

The function measures the time spent in this loop.

for (int64_t i = 0; i < arr_size; ++i) {
    // index k will jump forth and back, to generate cache misses
    int64_t k = (i / 2) + (i % 2) * arr_size / 2;
    arr_b[k] = arr_a[k] + 1;
 }

The code is benchmark_cache.

onnx_extended.validation.cpu._validation.benchmark_cache_tree(n_rows: int = 100000, n_features: int = 50, n_trees: int = 200, tree_size: int = 4096, max_depth: int = 10, search_step: int = 64) List[onnx_extended.validation.cpu._validation.ElementTime]

Simulates the prediction of a random forest. Returns the time taken by every rows for a function doing random addition between an element from the same short buffer and another one taken from a list of trees. See example Measuring CPU performance.

Parameters:
  • n_rows – number of rows of the whole batch size

  • n_features – number of features

  • n_trees – number of trees

  • tree_size – size of a tree (= number of nodes * sizeof(node) / sizeof(float))

  • max_depth – depth of a tree

  • search_step – evaluate every…

Returns:

array of time take for every row

The code is benchmark_cache_tree

onnx_extended.validation.cpu._validation.double2float_rn(d: float) float

Converts a double into float.

onnx_extended.validation.cpu._validation.murmurhash3_bytes_s32(key: str, seed: int = 0) int

Calls murmurhash3_bytes_s32 from scikit-learn.

Parameters:
  • key – string

  • seed – unsigned integer

Returns:

hash

onnx_extended.validation.cpu._validation.float2half_rn(d: float) int

Converts a float into half represented as an unsigned short.

onnx_extended.validation.cpu._validation.half2float(d: int) float

Converts a half represented as an unsigned short into float.

onnx_extended.validation.cpu._validation.has_sse3() bool

Tells if SSE3 instructions are available. They are needed to convert floart to half and half to float.