Skip to content

Commit

Permalink
Make check_feature_gate_key PT2 compatible (pytorch#3426)
Browse files Browse the repository at this point in the history
Summary:

X-link: facebookresearch/FBGEMM#513

Add a new API for `check_feature_gate_key` that is PT2 compatible.
PT2 complains when an op does not take/return a tensor.  Thus,
`check_feature_gate_key_pt2` (the new API) takes a dummy tensor as an
input and returns a boolean tensor as an output.

Differential Revision: D66611785
  • Loading branch information
sryap authored and facebook-github-bot committed Nov 30, 2024
1 parent 1e290d3 commit e890a97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fbgemm_gpu/fbgemm_gpu/config/feature_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class FeatureGate:
FeatureGate.is_enabled(FeatureGateName.TBE_V2)
"""

dummy_tensor = torch.empty(1)

@classmethod
def is_enabled(cls, feature: FeatureGateName) -> bool:
return torch.ops.fbgemm.check_feature_gate_key(feature.name)
return torch.ops.fbgemm.check_feature_gate_key_pt2(
cls.dummy_tensor, feature.name
)[0].item()

0 comments on commit e890a97

Please sign in to comment.