Open xhuan8 opened 1 year ago
Could you post a little bit more of your code? I'd like to reproduce it, but what does the code look like that causes the error?
thanks, there is only one line of code in a WPF project
private void button3_Click(object sender, RoutedEventArgs e)
{
try
{
var resNet = torch.nn.Sequential();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
So, nothing happens in a console app, presumably? I wonder if things work better if there's some call to TorchSharp on the main thread when the app starts -- some threading issue... If there's a first call on the main thread, maybe that will initialize things.
I'm really grasping at straws. I'll have to look into this later this week.
ok, it's strange, also occurs in a console application
I wonder if it's because the Sequential is empty.
I tried version 99.2 it's gone, maybe because my local code is corrupt.
It happens on latest code when build from source, all tests passed, but Sequential still throws excpetion.
even with some submodules as parameter
var resNet = torch.nn.Sequential(("lin1", nn.Linear(1000, 100, false)));
but version 99.2 from nuget can work, so maybe the packing process has some problem.
THSNN_Module_get_named_parameters failed to retriver parameters from module, seems the pointer point to some invalid address
System.OverflowException: Arithmetic operation resulted in an overflow.at System.lntPtr.op Explicit(lntPtr value)at TorchSharp.PinnedArray 1.CreateArray(lntPtr length)at
TorchSharp.PInvoke.LibTorchSharp.THSNN Module get named parameters(HType module, AllocatePinnedArray allocator1, AllocatePinnedArray allocator2)at TorchSharp.torch.nn.Module. named parameters()at TorchSharp.torch.nn.Module..ctor(lntPtr handle, Nullable'1 boxedHandle,
Boolean ownsHandle)at TorchSharp.torch.nn.Module2..ctor(IntPtr handle, IntPtr boxedHandle)at TorchSharp.ModulesLinear..ctor(lntPtr handle, IntPtr boxedHandle)at TorchSharp.torch.nn.Linear(lnt64 inputSize, Int64 outputSize, BooleanhasBias, Device device, Nullable'1 dtype)at TorchSharpTest.MainWindow.button3 Click(Object sender,RoutedEventArgs e) inD:\Code TorchSharpTest TorchSharpTest TorchSharpTest MainWindow.xaml.cs
@xhuan8 -- is this still happening?
haven't tested on the latest version.
With a simple call to Sequential
from unit test it can work, but when call from test project it throws exception.
try to accesse the variable still got exception