quark.onnx.tools.remove_qdq_between_ops

quark.onnx.tools.remove_qdq_between_ops#

Remove QuantizeLinear (q) and DequantizeLinear (dq) nodes between specified operator pairs.

Module Contents#

Functions#

remove_qdq_between_ops(→ Any)

Modify an ONNX quantized model to remove q and dq ops between specified operation pairs.

find_node_by_output(→ Optional[onnx.NodeProto])

Find a node that produces the specified output.

quark.onnx.tools.remove_qdq_between_ops.remove_qdq_between_ops(model: onnx.ModelProto, between_ops: list[Tuple[str, str]] | Any) Any#

Modify an ONNX quantized model to remove q and dq ops between specified operation pairs. Start from lower_op nodes and traverse upwards to upper_op.

Parameters:
  • model – The input ONNX model to be modified.

  • between_ops – A list of tuples where each tuple contains two operator types. The function will look for q and dq nodes between these pairs.

Returns:

The modified ONNX model with the specified q and dq nodes removed.

quark.onnx.tools.remove_qdq_between_ops.find_node_by_output(nodes: List[onnx.NodeProto], output_name: str) onnx.NodeProto | None#

Find a node that produces the specified output.

Parameters:
  • nodes – List of nodes to search.

  • output_name – The output name to match.

Returns:

The node that matches the output or None if not found.