uxmal / pytocs

Converts Python source to C#
Apache License 2.0
552 stars 167 forks source link

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

Open GeorgeS2019 opened 1 year ago

GeorgeS2019 commented 1 year ago

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

suggestion

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

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

GeorgeS2019 commented 1 year ago

Progress: add TorchSharp replace