Merge pull request #415 from Jittor/from_torch

add from_torch
This commit is contained in:
zhouwy19 2022-12-02 22:00:39 +08:00 committed by GitHub
commit fe6970efc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -1985,3 +1985,9 @@ def cpu(x): return x.clone()
jt.Var.cpu = cpu
def to(x, *args, **kargs): return x.clone()
jt.Var.to = to
def from_torch(x):
'''
Convert torch Tensor to Jittor Var
'''
return jt.Var(x.cpu().numpy())