MCPcopy Create free account
hub / github.com/pytorch/executorch / from_weights

Method from_weights

backends/xnnpack/operators/quant_params.py:325–346  ·  view source on GitHub ↗
(
        cls, tensor_node: torch.fx.Node, ep: Optional[ExportedProgram] = None
    )

Source from the content-addressed store, hash-verified

323
324 @classmethod
325 def from_weights(
326 cls, tensor_node: torch.fx.Node, ep: Optional[ExportedProgram] = None
327 ) -> Optional[QuantParams]:
328 if not is_dequant(tensor_node):
329 return None
330
331 # source node for quant params
332 src = tensor_node
333
334 # is input of dq is q?
335 dq_input = src.all_input_nodes[0]
336 if is_quant(dq_input):
337 src = dq_input
338
339 # replace this with pointing to the actual weight value.
340 # if no one else uses this weight value then take it out of the toplevel module
341 check_or_raise(
342 src.all_input_nodes[0].op in ["get_attr", "placeholder"],
343 f"q->dq->permute_copy not derived from static weight, input to the q or dq (for folded quant) node: {src.all_input_nodes[0]}",
344 )
345
346 return cls.from_q_dq_node(src, ep)
347
348 @classmethod
349 def from_inputs(

Callers 4

define_nodeMethod · 0.80
define_nodeMethod · 0.80
check_constraintsMethod · 0.80

Calls 4

is_dequantFunction · 0.90
is_quantFunction · 0.90
check_or_raiseFunction · 0.90
from_q_dq_nodeMethod · 0.80

Tested by

no test coverage detected