mirror of
https://github.com/luxfi/torus-ml.git
synced 2026-10-30 15:15:23 +00:00
The distribution called itself torus-ml while shipping a package directory named concrete, so the name a user installs and the name they import disagreed — and most of the tree already said torus.ml, which could not resolve against src/concrete. Moved src/concrete to src/torus and pointed the include at it. The dependency was Zama's concrete-python from their index. It is torus-fhe from ours, which is what luxfhe/torus already ships: that frontend declares torus-fhe and ships a torus/fhe module, so every 'from torus.fhe' in this tree was already naming our compiler and only the dependency lagged. Two distributions share one namespace, which is the shape the upstream this forked from used and the reason the split works: torus-fhe gives torus.fhe, torus-ml gives torus.ml. Swept every other spelling — identifiers, enum members, workflow variables, filenames, notebooks. LICENSE and NOTICE keep the upstream attribution a fork owes; the figures carry the old name in JPEG metadata a text sweep cannot reach.
4.6 KiB
4.6 KiB
module torus.ml.onnx.onnx_utils
Utils to interpret an ONNX model with numpy.
Global Variables
- ATTR_TYPES
- ATTR_GETTERS
- ONNX_OPS_TO_NUMPY_IMPL
- ONNX_COMPARISON_OPS_TO_NUMPY_IMPL_FLOAT
- ONNX_COMPARISON_OPS_TO_NUMPY_IMPL_BOOL
- ONNX_COMPARISON_OPS_TO_ROUNDED_TREES_NUMPY_IMPL_BOOL
- ONNX_OPS_TO_NUMPY_IMPL_BOOL
- IMPLEMENTED_ONNX_OPS
function get_attribute
get_attribute(attribute: AttributeProto) → Any
Get the attribute from an ONNX AttributeProto.
Args:
attribute(onnx.AttributeProto): The attribute to retrieve the value from.
Returns:
Any: The stored attribute value.
function get_op_type
get_op_type(node)
Construct the qualified type name of the ONNX operator.
Args:
node(Any): ONNX graph node
Returns:
result(str): qualified name
function execute_onnx_with_numpy
execute_onnx_with_numpy(graph: GraphProto, *inputs: ndarray) → Tuple[ndarray, ]
Execute the provided ONNX graph on the given inputs.
Args:
graph(onnx.GraphProto): The ONNX graph to execute.*inputs: The inputs of the graph.
Returns:
Tuple[numpy.ndarray]: The result of the graph's execution.
function execute_onnx_with_numpy_trees
execute_onnx_with_numpy_trees(
graph: GraphProto,
lsbs_to_remove_for_trees: Optional[Tuple[int, int]],
*inputs: ndarray
) → Tuple[ndarray, ]
Execute the provided ONNX graph on the given inputs for tree-based models only.
Args:
graph(onnx.GraphProto): The ONNX graph to execute.lsbs_to_remove_for_trees(Optional[Tuple[int, int]]): This parameter is exclusively used for optimizing tree-based models. It contains the values of the least significant bits to remove during the tree traversal, where the first value refers to the first comparison (either "less" or "less_or_equal"), while the second value refers to the "Equal" comparison operation. Default to None.*inputs: The inputs of the graph.
Returns:
Tuple[numpy.ndarray]: The result of the graph's execution.
function remove_initializer_from_input
remove_initializer_from_input(model: ModelProto)
Remove initializers from model inputs.
In some cases, ONNX initializers may appear, erroneously, as graph inputs. This function searches all model inputs and removes those that are initializers.
Args:
model(onnx.ModelProto): the model to clean
Returns:
onnx.ModelProto: the cleaned model
function check_onnx_model
check_onnx_model(onnx_model: ModelProto) → None
Check an ONNX model, handling large models (>2GB) by using external data.
Args:
onnx_model(onnx.ModelProto): The ONNX model to check.
Raises:
ValueError: If the model is too large (>2GB) or if there's another ValueError.