.xoptim.repeated_optim¶
- experimental_experiment.xoptim.repeated_optim.find_largest_repeated_pattern(onx: Sequence[NodeProto] | ModelProto | GraphProto | FunctionProto, min_freq: int = 2, verbose: int = 0, all_instances: bool = False, name: str = 'RepeatedPattern') Tuple[List[int] | List[List[int]], OnnxEasyPatternOptimization] | None [source]¶
Finds the largest repeated pattern in a graph.
- Parameters:
onx – any object containing a sequence of NodeProto
min_freq – do not consider any frequency below that threshold
verbose – verbosity
all_instances – if True, returns all instances
name – class name for the instance of
OnnxEasyPatternOptimization
- Returns:
list of node indices in the pattern, the pattern as a subtype of
OnnxEasyPatternOptimization
The opset are correct if the input is a ModelProto.
- experimental_experiment.xoptim.repeated_optim.make_function_from_nodes(nodes: List[NodeProto], name: str = 'function', domain: str = 'repeated') FunctionProto [source]¶
Creates a function from a list of nodes. Looks into inputs not created by one of the nodes, looks into unused outputs. Opset versions are all set to one.
- Parameters:
nodes – list of nodes
name – function name
domain – domain name
- Returns:
function proto
- experimental_experiment.xoptim.repeated_optim.node_type_frequency(onx: Sequence[NodeProto] | ModelProto | GraphProto | FunctionProto, min_freq: int = 2) Tuple[Dict[Tuple[str, str], int], Dict[Tuple[str, str], int], int, List[Tuple[str, str]]] [source]¶
Computes the frequency of every node type in a list.
- Parameters:
onx – any object containing a sequence of NodeProto
min_freq – do not consider any frequency below that threshold
- Returns:
4 results, the frequencies of the node types, the frequencies of the frequencies, the most frequent frequency (the estimation of the number of layers), all types having the exact same frequency as the previous one
Note
This function assumes at least one type of node is present only once in every layer.