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

[JIT] Can't use ndim in script #23890

Open
jamesr66a opened this issue Aug 6, 2019 · 4 comments
Open

[JIT] Can't use ndim in script #23890

jamesr66a opened this issue Aug 6, 2019 · 4 comments
Labels
jit-backlog oncall: jit Add this issue/PR to JIT oncall triage queue triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@jamesr66a
Copy link
Collaborator

jamesr66a commented Aug 6, 2019

import torch

def foo(x):
    if x.ndim > 3:
        return torch.neg(x)
    else:
        return x


x = torch.ones(3, 4)
x2 = torch.ones(3, 4, 5, 6)

print(foo(x))
print(foo(x2))

scripted = torch.jit.script(foo)
import torch

def foo(x):
    if x.ndim > 3:
        return torch.neg(x)
    else:
        return x


x = torch.ones(3, 4)
x2 = torch.ones(3, 4, 5, 6)

print(foo(x))
print(foo(x2))

scripted = torch.jit.script(foo)

cc @suo

@jamesr66a jamesr66a added the oncall: jit Add this issue/PR to JIT oncall triage queue label Aug 6, 2019
@eellison
Copy link
Contributor

eellison commented Aug 6, 2019

You can call x.dim() in script

@jamesr66a
Copy link
Collaborator Author

@eellison yeah but this should still work

@eellison
Copy link
Contributor

eellison commented Aug 7, 2019

ndim is deprecated & isn't in the docs. And the error message for this will show dim in the list of similar operators

@jamesr66a
Copy link
Collaborator Author

huh? it's on the docs:

image

@suo suo added the jit-backlog label Oct 3, 2019
@suo suo added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jit-backlog oncall: jit Add this issue/PR to JIT oncall triage queue triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants