Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceleration by Hybridization... But not actually accelerating for PyTorch #2155

Open
GrandArth opened this issue Jun 14, 2022 · 1 comment
Assignees

Comments

@GrandArth
Copy link

https://d2l.ai/chapter_computational-performance/hybridize.html#acceleration-by-hybridization

In the PyTorch tab:

net = get_net()
with Benchmark('Without torchscript'):
    for i in range(1000): net(x)

net = torch.jit.script(net)
with Benchmark('With torchscript'):
    for i in range(1000): net(x)
Without torchscript: 1.6357 sec
With torchscript: 1.6502 sec

I am reading that torchscript increased the time by 0.02.

I tried it out on my end, and get;

Without torchscript: 0.0580 sec
With torchscript: 0.0922 sec

Either i am getting the whole idea wrong, or torchscript isn't accelerating and

As is observed in the above results, after an nn.Sequential instance is scripted using the torch.jit.script function, computing performance is improved through the use of symbolic programming.

dosen't hold.

@AnirudhDagar
Copy link
Member

Thanks @GrandArth, this is also flagged in #1601. We'll probably update and improve the section here. Initially, the idea was to be consistent with mxnet hybridization and torchscript is the closest analogue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants