qualia_codegen_core.graph package

Subpackages

Submodules

Module contents

Qualia-CodeGen-Core graph package contains modules to create and manage internal model graph representation.

class qualia_codegen_core.graph.ModelGraph(nodes: list[LayerNode] | None = None)[source]

Bases: object

add_node(node: LayerNode, innodes: Iterable[LayerNode] | None = None, outnodes: Iterable[LayerNode] | None = None) None[source]
delete_node(node: LayerNode) None[source]
delete_node_if(predicate: Callable[[LayerNode], bool]) None[source]
replace_node(oldnode: LayerNode, newnode: LayerNode) None[source]
find_node_from_layer(layer: TBaseLayer) LayerNode | None[source]
get_nodes_for_layers(layers: TBaseLayer | Iterable[TBaseLayer]) tuple[LayerNode | None, ...][source]
no_none_in_nodes(nodes: Iterable[LayerNode | None]) TypeGuard[Iterable[LayerNode]][source]
add_layer(layer: TBaseLayer, inlayers: list[TBaseLayer] | None = None, outlayers: list[TBaseLayer] | None = None) None[source]
property nodes: list[LayerNode]
graphviz() str | None[source]
classmethod auto_detect(obj: keras.Model | nn.Module) ModelGraph[source]
class qualia_codegen_core.graph.Quantization(number_type: type[int | float] | None = None, width: int | None = None, long_width: int | None = None, weights_width: int | None = None, bias_width: int | None = None, output_width: int | None = None, weights_scale_factor: int | None = None, bias_scale_factor: int | None = None, output_scale_factor: int | None = None, weights_round_mode: RoundMode | None = None, output_round_mode: RoundMode | None = None)[source]

Bases: object

Holds quantization settings in a model graph node.

number_type: type[int | float] | None = None

Number abstract data type, either float for floating-point coding or int for fixed-point coding

width: int | None = None

Total number of bits to use to encode a value (output, bias and weights)

long_width: int | None = None

Larger number of bits to use for temporary values during computation in C code

weights_width: int | None = None

Not used in C code, total number of bits to use to encode weights

bias_width: int | None = None

Not used in C code, total number of bits to use to encode biases

output_width: int | None = None

Not used in C code, total number of bits to use to encode outputs

weights_scale_factor: int | None = None

Number of bits for the fractional part of weights

bias_scale_factor: int | None = None

Number of bits for the fractional part of biases

output_scale_factor: int | None = None

Number of bits for the fractional part of outputs

weights_round_mode: RoundMode | None = None

Rounding mode to use when quantizing weights

output_round_mode: RoundMode | None = None

Rounding mode to use when quantizing outputs

asdict() dict[str, Any][source]

Return the data from this class as a dictionary.

Returns:

a dictionary with each attribute and property of this dataclass as keys and the associated values