afe.ir.transform.requantization_hoisting.requantization_use_analysis

This module defines analyze_needs, an analysis that determines how every node’s output will be requantized. For every node in the graph (exceptions are listed below), it records what requantization was performed for all uses of the node’s output, no matter where those requantizations occur in the graph. Use without requantization is also recorded. Additionally, it records the same information about the inputs of a subnet.

The analysis proceeds as a backward pass over the graph. Each time it finds a requantization node, it records how the node’s input tensor was requantized. That information is propagated to the node that produced the tensor.

Requantize, Tuple, TupleGetItem, and Placeholder nodes are not recorded. Instead, their output information is transformed and propagated to their input.

Functions

join_need_lists(...)

Concatenate two lists of Need and remove duplicate items.

join_needs(...)

update_need_dict(d, k, v)

propagate_node_need(results, node)

Determine the needs of an AwesomeNode.

sima_ir_needs(...)

Determine the needs of a SiMaIR's input, given the needs of

net_needs(...)

Determine the needs of an AwesomeNet and of all nodes that it contains.

analyze_needs(→ Tuple[Dict[afe.ir.defines.NodeName, ...)

Determine the needs of all nodes in a top-level AwesomeNet.

Module Contents

afe.ir.transform.requantization_hoisting.requantization_use_analysis.join_need_lists(xs: List[afe.ir.transform.requantization_hoisting.defines.Need], ys: List[afe.ir.transform.requantization_hoisting.defines.Need]) List[afe.ir.transform.requantization_hoisting.defines.Need][source]

Concatenate two lists of Need and remove duplicate items. Each input list is assumed not to contain duplicate items.

afe.ir.transform.requantization_hoisting.requantization_use_analysis.join_needs(x: afe.ir.transform.requantization_hoisting.defines.DataNeeds, y: afe.ir.transform.requantization_hoisting.defines.DataNeeds) afe.ir.transform.requantization_hoisting.defines.DataNeeds[source]
afe.ir.transform.requantization_hoisting.requantization_use_analysis.update_need_dict(d: Dict[afe.ir.defines.NodeName, afe.ir.transform.requantization_hoisting.defines.DataNeeds], k: afe.ir.defines.NodeName, v: afe.ir.transform.requantization_hoisting.defines.DataNeeds)[source]
afe.ir.transform.requantization_hoisting.requantization_use_analysis.propagate_node_need(results: _RequantizationAnalysisResult, node: afe.ir.node.AwesomeNode)[source]

Determine the needs of an AwesomeNode.

Parameters:
  • results – Results of analysis. Holds previously collected results, which may be read. Will be updated with results of analyzing node.

  • node – Node to analyze

afe.ir.transform.requantization_hoisting.requantization_use_analysis.sima_ir_needs(node: afe.ir.sima_ir.SiMaIR, output_need: afe.ir.transform.requantization_hoisting.defines.DataNeeds) List[afe.ir.transform.requantization_hoisting.defines.DataNeeds][source]

Determine the needs of a SiMaIR’s input, given the needs of its output.

Parameters:
  • node – Node to get the needs of.

  • output_need – Need of the output node.

Returns:

Needs of the node’s inputs. The list has the same order as the inputs in the node’s type.

afe.ir.transform.requantization_hoisting.requantization_use_analysis.net_needs(results: _RequantizationAnalysisResult, net: afe.ir.net.AwesomeNet, output_needs: afe.ir.transform.requantization_hoisting.defines.DataNeeds) List[afe.ir.transform.requantization_hoisting.defines.DataNeeds][source]

Determine the needs of an AwesomeNet and of all nodes that it contains.

Parameters:
  • results – Results of analysis. Holds previously collected results, which may be read. Will be updated with results of analyzing net.

  • net – Network to analyze

  • output_needs – Needs of the net’s output

Returns:

The needs of the net’s inputs.

afe.ir.transform.requantization_hoisting.requantization_use_analysis.analyze_needs(net: afe.ir.net.AwesomeNet) Tuple[Dict[afe.ir.defines.NodeName, afe.ir.transform.requantization_hoisting.defines.DataNeeds], Dict[afe.ir.defines.NodeName, List[afe.ir.transform.requantization_hoisting.defines.DataNeeds]]][source]

Determine the needs of all nodes in a top-level AwesomeNet.

Parameters:

net – Network to analyze

Returns:

Needs on the outputs of all nodes in the network