(
cls, tensor_node: torch.fx.Node, ep: Optional[ExportedProgram] = None
)
| 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( |
no test coverage detected