Skip to content

Commit fe96846

Browse files
navahgaraocsa
authored andcommitted
Adding a flag to enable CPU fusion in benchmarks (pytorch#48612)
Summary: Pull Request resolved: pytorch#48612 Test Plan: python -m benchmarks.tensorexpr --device cpu --mode fwd --jit_mode trace --cpu_fusion element Reviewed By: heitorschueroff Differential Revision: D26548643 Pulled By: navahgar fbshipit-source-id: adb537818d77c9b6b0fe434ae6d963a5f348ad24
1 parent aae9e6d commit fe96846

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

benchmarks/tensorexpr/__main__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def main():
116116
action='store_true',
117117
help="Disable shape randomization in dynamic benchmarks.",
118118
)
119+
parser.add_argument(
120+
"--cpu_fusion",
121+
default=False,
122+
action='store_true',
123+
help="Enable CPU fusion.",
124+
)
119125

120126
args = parser.parse_args()
121127

@@ -139,6 +145,13 @@ def main():
139145
else :
140146
raise ValueError("Undefined fuser: {}".format(args.cuda_fuser))
141147

148+
if args.cpu_fusion:
149+
import torch
150+
torch._C._jit_override_can_fuse_on_cpu(True)
151+
else:
152+
import torch
153+
torch._C._jit_override_can_fuse_on_cpu(False)
154+
142155
def set_global_threads(num_threads):
143156
os.environ["OMP_NUM_THREADS"] = str(num_threads)
144157
os.environ["MKL_NUM_THREADS"] = str(num_threads)

0 commit comments

Comments
 (0)