vollo_trees_compiler

Bindings for the Vollo tree compiler.

This module provides functions to compile models to vollo-trees programs, and to evaluate these programs.

class vollo_trees_compiler.Config

Hardware configuration for compiling a forest to a program

static from_json(json_path: str) Config

Load a configuration from a JSON file

max_input_features

Maximum number of input features

max_tree_depth

Maximum depth of a tree

num_tree_units

Number of tree units

unit_ram_depth

Maximum number of nodes in each tree unit

class vollo_trees_compiler.Forest

An internal representation of a forest of decision trees

static from_onnx(path: str) Forest

Convert an ONNX model with a TreeEnsembleRegressor (https://onnx.ai/onnx/operators/onnx_aionnxml_TreeEnsembleRegressor.html) node to a vollo-trees Forest representation

max_depth() int

Get the maximum depth of the trees in the forest

num_input_features() int

Get the number of input features expected by the forest

num_trees() int

Get the number of trees in the forest

to_program_bf16(config: Config) ProgramBf16

Compile the forest to a program where nodes have bf16 comparators, and the inputs and output are bf16

to_program_f32(config: Config) ProgramF32

Compile the forest to a program where nodes have f32 comparators, and the inputs and output are f32

class vollo_trees_compiler.ProgramF32

A compiled program where comparators and leaves are float32 values

config() Config
eval(input: List[float], model_ix: int = 0) float

Evaluate the program on a given input

eval_with_cycle_estimate(&self, input: Vec<f32>, model_ix: int = 0) -> (f32, int)

Evaluate a program on a given input, and return the result along with the estimated number of cycles For a worst-case cycle count estimate see pessimistic_cycle_estimate().

static load(input_path: str) ProgramF32

Load the program from the specified file path

pessimistic_cycle_estimate(model_ix: int = 0) int

Return a pessimistic estimate of the number of cycles required to calculate the result of an inference. This is calculated based on the maximum length branch in each tree. For an input-based cycle count see eval_with_cycle_estimate().

save(output_path: str)

Save the program to the specified file path

class vollo_trees_compiler.ProgramBf16

A compiled program where comparators and leaves are bf16 valuess

config() Config
eval(input: List[float], model_ix: int = 0) float

Evaluate the program on a given input.

The input float32 values are converted to bf16 before evaluating the program, and the result is converted from bf16 to float32

eval_with_cycle_estimate(&self, input: Vec<f32>, model_ix: int = 0) -> (f32, int)

Evaluate a program on a given input, and return the result along with the estimated number of cycles. For a worst-case cycle count estimate see pessimistic_cycle_estimate().

static load(input_path: str) ProgramBf16

Load the program from the specified file path

pessimistic_cycle_estimate(model_ix: int = 0) int

Return a pessimistic estimate of the number of cycles required to calculate the result of an inference. This is calculated based on the maximum length branch in each tree. For an input-based cycle count see eval_with_cycle_estimate().

save(output_path: str)

Save the program to the specified file path

exception vollo_trees_compiler.FromOnnxError

Error occuring while converting an ONNX model to a vollo-trees Forest

exception vollo_trees_compiler.ForestCompileError

Error occuring while compiling a Forest to a Program