Skip to content

Commit

Permalink
Allow addmm and mm to call dynamic fp32 kernels Xnnpack
Browse files Browse the repository at this point in the history
Differential Revision: D66898281

Pull Request resolved: #7232
  • Loading branch information
JacobSzwejbka authored Dec 13, 2024
1 parent 3fcf0bd commit 7924942
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backends/xnnpack/partition/config/gemm_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@ def __init__(self, **kwargs):
self.src_partitions = None
self.linear_modules = [torch.nn.functional.linear, torch.nn.Linear]

def _get_weight_deps(
self, node: torch.fx.Node, ep: ExportedProgram, precision: ConfigPrecisionType
) -> Tuple[bool, List[torch.fx.Node]]:
# TODO(maxren, T210537195):
if precision == ConfigPrecisionType.FP32 and self.force_fp32_dynamic_linear:
# if force fp32_dynamic_linear is on and we detected this as fp32, then we
# do not partition the weight node
return (True, [])

return super()._get_weight_deps(node, ep, precision)

def get_deps(
self,
node: torch.fx.Node,
Expand Down Expand Up @@ -436,6 +447,16 @@ def __init__(self, **kwargs):
self.weight_idx = 1
self.act_idx = 0

def _get_weight_deps(
self, node: torch.fx.Node, ep: ExportedProgram, precision: ConfigPrecisionType
) -> Tuple[bool, List[torch.fx.Node]]:
if precision == ConfigPrecisionType.FP32 and self.force_fp32_dynamic_linear:
# if force fp32_dynamic_linear is on and we detected this as fp32, then we
# do not partition the weight node
return (True, [])

return super()._get_weight_deps(node, ep, precision)

def supported_precision_types(self):
return [
ConfigPrecisionType.FP32,
Expand Down

0 comments on commit 7924942

Please sign in to comment.