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

[WIP: Help] PyTorch to TorchSharp: the python way #83

Open
GeorgeS2019 opened this issue Sep 26, 2022 · 1 comment
Open

[WIP: Help] PyTorch to TorchSharp: the python way #83

GeorgeS2019 opened this issue Sep 26, 2022 · 1 comment

Comments

@GeorgeS2019
Copy link

GeorgeS2019 commented Sep 26, 2022

PyTorch

my_tensor = torch. Tensor([[1,2,3],[4,5,6]], dtype = torch.float32)

PyToCs

using System.Collections.Generic;
public static class testModule {
    
    public object my_tensor = torch.tensor(new List<object> {
        new List<object> {
            1,
            2,
            3
        },
        new List<object> {
            4,
            5,
            6
        }
    }, dtype: torch.float32);
}

Desired c# TorchSharp's python way

var my_tensor = torch. Tensor(new int[,]{{1,2,3},{3,5,6}}, ScalarType.Float32)

In PyToCs terms

  • FieldName: my_tensor
  • Method: torch.tesnsor()
  • Arguments:
    • [[1,2,3], [4,5,6]]
    • dtype = torch.float32

suggestion

Once torch is detected in method, TorchSharp specific argument translation is applied

  • [[1,2,3], [4,5,6]] => new int[,]{{1,2,3},{3,5,6}}
  • dtype: torch.float32 => ScalarType.Float32

I need idea which part of the PyToCs codes for implementing the TorchSharp specific statement translation

@GeorgeS2019
Copy link
Author

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

1 participant