Skip to content

Commit 5d71d4a

Browse files
mcr229facebook-github-bot
authored andcommitted
quant params from static inputs (#573)
Summary: Since we allow tensor constants to be quantized inputs, we need to adjust the from_inputs api to search if this input is static or not. If it is static, then we take the first q node in get_attr --> q --> dq. If it is not static, then we just take the dq node to create the QuantParams object. In the past, we can take in static quant inputs only on weights and biases. Differential Revision: D49850149
1 parent 17fee78 commit 5d71d4a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

backends/xnnpack/operators/quant_params.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ def from_inputs(cls, tensor_node: torch.fx.Node) -> Optional[QuantParams]:
183183
if is_dequant(tensor_node) and TagImplicitQDqPass.is_tagged_as_implicit_q_dq(
184184
tensor_node
185185
):
186+
dq_input = cast(torch.fx.Node, tensor_node.args[0])
187+
if is_quant(dq_input):
188+
q_input = cast(torch.fx.Node, dq_input.args[0])
189+
if q_input.op == "placeholder":
190+
return cls.from_q_dq_node(dq_input)
186191
return cls.from_q_dq_node(tensor_node)
187192

188193
return None

0 commit comments

Comments
 (0)