hummingbird.ml._topology

Converters for topology IR are stored in this file.

class hummingbird.ml._topology.Topology(input_container)[source]

Bases: object

declare_logical_operator(alias, model=None)[source]

This function is used to declare new logical operator.

declare_logical_variable(original_input_name, type=None)[source]

This function creates a new logical variable within the topology. If original_input_name has been used to create other variables, the new variable will hide all other variables created using original_input_name.

property input_container

Returns the input container wrapping the original input model.

topological_operator_iterator()[source]

This is an iterator of all operators in the Topology object. Operators are returned in a topological order.

property variables

Returns all the logical variables of the topology.

hummingbird.ml._topology._compile_to_tvm(topology, executor, trace_input, target, ctx, config, extra_config)[source]
hummingbird.ml._topology._get_batch_size(batch)[source]
hummingbird.ml._topology._get_trace_input_from_test_input(input, remainder_size=None, extra_config={})[source]

Utility function used to properly put the inputs into a format understandable by torch. If remainder_size is provided, also return inputs for a remainder model (see below).

hummingbird.ml._topology._jit_trace(executor, trace_input, device, extra_config)[source]

Function used to convert an input pytorch model into torchscript.

hummingbird.ml._topology.convert(topology, backend, test_input, device, extra_config={})[source]

This function is used to convert a Topology object into a backend model.

Args:

topology: The Topology object that will be converted into a backend model backend: Which backend the model should be run on test_input: Inputs for PyTorch model tracing device: Which device the translated model will be run on extra_config: Extra configurations to be used by individual operator converters

Returns:

A model implemented in the selected backend