[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:
vfdev
2021-12-17 17:31:42 +01:00
committed by Jon Janzen
parent dc3eb6af00
commit c94446a04d
45 changed files with 837 additions and 475 deletions

View File

@ -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))