mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[functorch] Fixed python code formatting and added flake8 setup (pytorch/functorch#346)
* Fixed python code formatting and added flake8 setup * Fixes config.yaml * Added missing setup.cfg * Removed flake8 job from circle ci and setup GHA * More flake8 fixes * Fixed test_conv2d * Fixed failing flake8
This commit is contained in:
@ -8,9 +8,11 @@ from functorch import grad, nnc_jit, make_fx, make_nnc
|
||||
import torch
|
||||
import time
|
||||
|
||||
|
||||
def f(x):
|
||||
return torch.sin(x).sum()
|
||||
|
||||
|
||||
inp = torch.randn(100)
|
||||
grad_pt = grad(f)
|
||||
grad_fx = make_fx(grad_pt)(inp)
|
||||
@ -18,6 +20,7 @@ grad_nnc = nnc_jit(grad_pt, skip_specialization=True)
|
||||
loopnest = make_nnc(grad_pt)(inp)
|
||||
print(loopnest)
|
||||
|
||||
|
||||
def bench(name, f, iters=10000, warmup=3):
|
||||
for _ in range(warmup):
|
||||
f()
|
||||
@ -26,6 +29,7 @@ def bench(name, f, iters=10000, warmup=3):
|
||||
f()
|
||||
print(f"{name}: ", time.time() - begin)
|
||||
|
||||
|
||||
bench("Pytorch: ", lambda: grad_pt(inp))
|
||||
bench("FX: ", lambda: grad_fx(inp))
|
||||
bench("NNC: ", lambda: grad_nnc(inp))
|
||||
|
Reference in New Issue
Block a user