From d1852486cb81f317c063597c0630e7b3a2b4e176 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:54:29 -0800 Subject: [PATCH 1/4] Remove invalid P/Invoke methods These 3 methods have incorrect signatures for their entrypoint. Each of them has an overload with the correct signature. --- .../PInvoke/LibTorchSharp.THSTensor.cs | 9 --------- src/TorchSharp/Tensor/Tensor.cs | 4 ++-- .../Tensor/TensorTyped.handwritten.cs | 20 +++++++++++-------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs b/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs index bb568ae68..a40738802 100644 --- a/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs +++ b/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs @@ -1038,9 +1038,6 @@ internal static extern IntPtr THSTensor_upsample_nearest3d(IntPtr input, [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_mean_along_dimensions(IntPtr tensor, IntPtr dimensions, int length, [MarshalAs(UnmanagedType.U1)] bool keepdim, [MarshalAs(UnmanagedType.U1)] bool has_type, sbyte scalar_type); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSTensor_var_along_dimensions(IntPtr tensor, IntPtr dimensions, int length, [MarshalAs(UnmanagedType.U1)] bool keepdim, [MarshalAs(UnmanagedType.U1)] bool has_type, sbyte scalar_type); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_median(IntPtr tensor); @@ -1353,18 +1350,12 @@ internal static extern IntPtr THSTensor_upsample_nearest3d(IntPtr input, [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_istft(IntPtr x, long n_fft, long hop_length, long win_length, IntPtr window, [MarshalAs(UnmanagedType.U1)] bool center, [MarshalAs(UnmanagedType.U1)] bool normalized, long onesided, long length, [MarshalAs(UnmanagedType.U1)] bool return_complex); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSTensor_to_type(IntPtr handle, sbyte scalar_type); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_arange(IntPtr start, IntPtr stop, IntPtr step, sbyte scalarType, int deviceType, int deviceIndex, [MarshalAs(UnmanagedType.U1)] bool requireGrad); [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_newComplexFloat32Scalar(float real, float imaginary, int deviceType, int deviceIndex, [MarshalAs(UnmanagedType.U1)] bool requires_grad); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSTensor_randint(long max, IntPtr psizes, int length, sbyte scalarType, int deviceType, int deviceIndex, [MarshalAs(UnmanagedType.U1)] bool requires_grad); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_randint(IntPtr generator, long low, long high, IntPtr psizes, int length, sbyte scalarType, int deviceType, int deviceIndex, [MarshalAs(UnmanagedType.U1)] bool requires_grad); diff --git a/src/TorchSharp/Tensor/Tensor.cs b/src/TorchSharp/Tensor/Tensor.cs index c17995a52..6a3ecd00e 100644 --- a/src/TorchSharp/Tensor/Tensor.cs +++ b/src/TorchSharp/Tensor/Tensor.cs @@ -4300,11 +4300,11 @@ public Tensor mean(long[] dimensions, bool keepdim = false, ScalarType? type = n } } - public Tensor var(long[] dimensions, bool keepdim = false, ScalarType? type = null) + public Tensor var(long[] dimensions, bool unbiased = true, bool keepdim = false, ScalarType? type = null) { unsafe { fixed (long* pdims = dimensions) { - var res = NativeMethods.THSTensor_var_along_dimensions(Handle, (IntPtr)pdims, dimensions.Length, keepdim, type.HasValue, (sbyte)type.GetValueOrDefault()); + var res = NativeMethods.THSTensor_var_along_dimensions(Handle, (IntPtr)pdims, dimensions.Length, unbiased, keepdim); if (res == IntPtr.Zero) { CheckForErrors(); } return new Tensor(res); } diff --git a/src/TorchSharp/Tensor/TensorTyped.handwritten.cs b/src/TorchSharp/Tensor/TensorTyped.handwritten.cs index 7c1083553..5a5a2cacf 100644 --- a/src/TorchSharp/Tensor/TensorTyped.handwritten.cs +++ b/src/TorchSharp/Tensor/TensorTyped.handwritten.cs @@ -28,7 +28,7 @@ public static Tensor arange(Scalar start, Scalar stop, Scalar step, torch.Device } if (handle == IntPtr.Zero) { torch.CheckForErrors(); } - var res = THSTensor_to_type(handle, (sbyte)ScalarType.ComplexFloat32); + var res = THSTensor_to_type(handle, (sbyte)ScalarType.ComplexFloat32, false, false); if (res == IntPtr.Zero) torch.CheckForErrors(); @@ -61,7 +61,7 @@ public static Tensor from(float real, float imaginary = 0.0f, torch.Device devic /// Create a new tensor filled with random integer values taken from a uniform distribution in [0, max). /// The real and imaginary parts will be filled independently of each other. /// - public static Tensor randint(long max, long[] size, torch.Device device = null, bool requires_grad = false) + public static Tensor randint(long low, long high, long[] size, torch.Device device = null, bool requires_grad = false, Generator generator = null) { device = torch.InitializeDevice(device); @@ -70,6 +70,8 @@ public static Tensor randint(long max, long[] size, torch.Device device = null, sz.Add(2); var size2 = sz.ToArray(); + var genHandle = (generator is null) ? IntPtr.Zero : generator.Handle; + unsafe { fixed (long* psizes = size2) { // @@ -77,11 +79,11 @@ public static Tensor randint(long max, long[] size, torch.Device device = null, // but we can get around that by adding another dimension, creating a float tensor, and then // converting it to a complex tensor in the end. // - var handle = THSTensor_randint(max, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float32, (int)device.type, device.index, requires_grad); + var handle = THSTensor_randint(genHandle, low, high, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float32, (int)device.type, device.index, requires_grad); if (handle == IntPtr.Zero) { GC.Collect(); GC.WaitForPendingFinalizers(); - handle = THSTensor_randint(max, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float32, (int)device.type, device.index, requires_grad); + handle = THSTensor_randint(genHandle, low, high, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float32, (int)device.type, device.index, requires_grad); } if (handle == IntPtr.Zero) { torch.CheckForErrors(); } @@ -127,7 +129,7 @@ public static Tensor arange(Scalar start, Scalar stop, Scalar step, torch.Device } if (handle == IntPtr.Zero) { torch.CheckForErrors(); } - var res = THSTensor_to_type(handle, (sbyte)ScalarType.ComplexFloat64); + var res = THSTensor_to_type(handle, (sbyte)ScalarType.ComplexFloat64, false, false); if (res == IntPtr.Zero) torch.CheckForErrors(); @@ -160,7 +162,7 @@ public static Tensor from(double real, double imaginary = 0.0f, torch.Device dev /// Create a new tensor filled with random integer values taken from a uniform distribution in [0, max). /// The real and imaginary parts will be filled independently of each other. /// - public static Tensor randint(long max, long[] size, torch.Device device = null, bool requires_grad = false) + public static Tensor randint(long low, long high, long[] size, torch.Device device = null, bool requires_grad = false, Generator generator = null) { device = torch.InitializeDevice(device); @@ -169,6 +171,8 @@ public static Tensor randint(long max, long[] size, torch.Device device = null, sz.Add(2); var size2 = sz.ToArray(); + var genHandle = (generator is null) ? IntPtr.Zero : generator.Handle; + unsafe { fixed (long* psizes = size2) { // @@ -176,11 +180,11 @@ public static Tensor randint(long max, long[] size, torch.Device device = null, // but we can get around that by adding another dimension, creating a float tensor, and then // converting it to a complex tensor in the end. // - var handle = THSTensor_randint(max, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float64, (int)device.type, device.index, requires_grad); + var handle = THSTensor_randint(genHandle, low, high, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float64, (int)device.type, device.index, requires_grad); if (handle == IntPtr.Zero) { GC.Collect(); GC.WaitForPendingFinalizers(); - handle = THSTensor_randint(max, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float64, (int)device.type, device.index, requires_grad); + handle = THSTensor_randint(genHandle, low, high, (IntPtr)psizes, size2.Length, (sbyte)ScalarType.Float64, (int)device.type, device.index, requires_grad); } if (handle == IntPtr.Zero) { torch.CheckForErrors(); } From ce978c6a143cd17940615053094a2da215949343 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Thu, 20 Nov 2025 13:10:11 -0800 Subject: [PATCH 2/4] Fix var compile error --- src/TorchSharp/Tensor/Tensor.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/TorchSharp/Tensor/Tensor.cs b/src/TorchSharp/Tensor/Tensor.cs index 6a3ecd00e..46a35db04 100644 --- a/src/TorchSharp/Tensor/Tensor.cs +++ b/src/TorchSharp/Tensor/Tensor.cs @@ -4300,17 +4300,6 @@ public Tensor mean(long[] dimensions, bool keepdim = false, ScalarType? type = n } } - public Tensor var(long[] dimensions, bool unbiased = true, bool keepdim = false, ScalarType? type = null) - { - unsafe { - fixed (long* pdims = dimensions) { - var res = NativeMethods.THSTensor_var_along_dimensions(Handle, (IntPtr)pdims, dimensions.Length, unbiased, keepdim); - if (res == IntPtr.Zero) { CheckForErrors(); } - return new Tensor(res); - } - } - } - /// /// Returns the median of the values in input. /// From f6526102356a052bafadba830cc6e2d627c120ed Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Tue, 2 Dec 2025 12:39:44 -0800 Subject: [PATCH 3/4] Fix method documentation --- src/TorchSharp/Tensor/TensorTyped.handwritten.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TorchSharp/Tensor/TensorTyped.handwritten.cs b/src/TorchSharp/Tensor/TensorTyped.handwritten.cs index 5a5a2cacf..312fbf4ae 100644 --- a/src/TorchSharp/Tensor/TensorTyped.handwritten.cs +++ b/src/TorchSharp/Tensor/TensorTyped.handwritten.cs @@ -58,7 +58,7 @@ public static Tensor from(float real, float imaginary = 0.0f, torch.Device devic } /// - /// Create a new tensor filled with random integer values taken from a uniform distribution in [0, max). + /// Create a new tensor filled with random integer values taken from a uniform distribution in [low, high). /// The real and imaginary parts will be filled independently of each other. /// public static Tensor randint(long low, long high, long[] size, torch.Device device = null, bool requires_grad = false, Generator generator = null) @@ -159,7 +159,7 @@ public static Tensor from(double real, double imaginary = 0.0f, torch.Device dev } /// - /// Create a new tensor filled with random integer values taken from a uniform distribution in [0, max). + /// Create a new tensor filled with random integer values taken from a uniform distribution in [low, high). /// The real and imaginary parts will be filled independently of each other. /// public static Tensor randint(long low, long high, long[] size, torch.Device device = null, bool requires_grad = false, Generator generator = null) From 86c2dcacf9b2f03f0cf1b0f7249f3778955a902c Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Sun, 7 Dec 2025 22:32:46 -0800 Subject: [PATCH 4/4] Remove pinvoke methods without a native entrypoint --- src/TorchSharp/JIT/ScriptModule.cs | 7 -- .../PInvoke/LibTorchSharp.THSJIT.cs | 6 - src/TorchSharp/PInvoke/LibTorchSharp.THSNN.cs | 105 ------------------ .../PInvoke/LibTorchSharp.THSTensor.cs | 3 - 4 files changed, 121 deletions(-) diff --git a/src/TorchSharp/JIT/ScriptModule.cs b/src/TorchSharp/JIT/ScriptModule.cs index 14e5d4773..85512a5ad 100644 --- a/src/TorchSharp/JIT/ScriptModule.cs +++ b/src/TorchSharp/JIT/ScriptModule.cs @@ -238,13 +238,6 @@ public Type GetInputType(int index) return GetType(type); } - public Type GetOutputType(int index) - { - var type = new Type(THSJIT_getOutputType(handle, index), Type.TypeKind.AnyType); - - return GetType(type); - } - private Type GetType(Type type) { switch (type.Kind) { diff --git a/src/TorchSharp/PInvoke/LibTorchSharp.THSJIT.cs b/src/TorchSharp/PInvoke/LibTorchSharp.THSJIT.cs index 074fcc247..1f1380a58 100644 --- a/src/TorchSharp/PInvoke/LibTorchSharp.THSJIT.cs +++ b/src/TorchSharp/PInvoke/LibTorchSharp.THSJIT.cs @@ -38,9 +38,6 @@ internal static partial class NativeMethods [DllImport("LibTorchSharp")] internal static extern void THSJIT_Module_named_children(torch.nn.Module.HType module, AllocatePinnedArray allocator1, AllocatePinnedArray allocator2); - [DllImport("LibTorchSharp")] - internal static extern long THSJIT_getNumModules(torch.nn.Module.HType module); - [DllImport("LibTorchSharp")] internal static extern int THSJIT_Module_num_inputs(torch.nn.Module.HType module); @@ -69,9 +66,6 @@ internal static partial class NativeMethods [DllImport("LibTorchSharp")] internal static extern IntPtr THSJIT_Module_getInputType(torch.nn.Module.HType module, int index); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSJIT_getOutputType(torch.jit.Type.HType module, int index); - [DllImport("LibTorchSharp")] internal static extern void THSJIT_Module_forward(torch.nn.Module.HType module, IntPtr tensors, int length, AllocateIndexedNativeTensorOrScalarArray allocator, out sbyte typeCode, int idx); diff --git a/src/TorchSharp/PInvoke/LibTorchSharp.THSNN.cs b/src/TorchSharp/PInvoke/LibTorchSharp.THSNN.cs index 2b97b61eb..099c485d6 100644 --- a/src/TorchSharp/PInvoke/LibTorchSharp.THSNN.cs +++ b/src/TorchSharp/PInvoke/LibTorchSharp.THSNN.cs @@ -38,10 +38,6 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern torch.nn.utils.rnn.PackedSequence.HType THSNN_GRU_forward_with_packed_input(torch.nn.Module.HType module, torch.nn.utils.rnn.PackedSequence.HType input, IntPtr h_0, out IntPtr h_n); - [DllImport("LibTorchSharp")] - // align_corners -- 0=None, 1=true, 2=false - internal static extern IntPtr THSNN_Upsample_ctor(IntPtr size, int size_length, IntPtr scale_factor, int scale_factor_length, byte mode, byte align_corners, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] // align_corners -- 0=None, 1=true, 2=false internal static extern IntPtr THSNN_interpolate(IntPtr input, IntPtr size, int size_len, IntPtr scale_factor, int scale_factor_len, byte mode, byte align_corners, [MarshalAs(UnmanagedType.U1)] bool recompute_scale_factor, [MarshalAs(UnmanagedType.U1)] bool antialias); @@ -65,26 +61,6 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_dropout2d(IntPtr input, double p, [MarshalAs(UnmanagedType.U1)] bool training, [MarshalAs(UnmanagedType.U1)] bool inplace); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout_ctor(double p, [MarshalAs(UnmanagedType.U1)] bool inplace, out IntPtr pBoxedModule); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout1d_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout1d_ctor(double p, [MarshalAs(UnmanagedType.U1)] bool inplace, out IntPtr pBoxedModule); - - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout2d_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout2d_ctor(double p, [MarshalAs(UnmanagedType.U1)] bool inplace, out IntPtr pBoxedModule); - - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_Embedding_forward(torch.nn.Module.HType module, IntPtr tensor); @@ -100,12 +76,6 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_Embedding_from_pretrained(IntPtr embeddings, [MarshalAs(UnmanagedType.U1)] bool freeze, long padding_idx, [MarshalAs(UnmanagedType.U1)] bool hasPI, double max_norm, [MarshalAs(UnmanagedType.U1)] bool hasMN, double norm_type, [MarshalAs(UnmanagedType.U1)] bool scale_grad_by_freq, [MarshalAs(UnmanagedType.U1)] bool sparse, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout3d_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Dropout3d_ctor(double p, [MarshalAs(UnmanagedType.U1)] bool inplace, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_dropout3d(IntPtr input, double p, [MarshalAs(UnmanagedType.U1)] bool training, [MarshalAs(UnmanagedType.U1)] bool inplace); @@ -223,9 +193,6 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern void THSNN_Module_train(torch.nn.Module.HType module, [MarshalAs(UnmanagedType.U1)] bool on); - [DllImport("LibTorchSharp")] - internal static extern void THSNN_Module_eval(torch.nn.Module.HType module); - [DllImport("LibTorchSharp")] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool THSNN_Module_is_training(torch.nn.Module.HType module); @@ -308,39 +275,9 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_RNNCell_ctor(long input_size, long hidden_size, long nonlinearity, [MarshalAs(UnmanagedType.U1)] bool bias, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Linear_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Linear_bias(torch.nn.Module.HType module); - - [DllImport("LibTorchSharp")] - internal static extern void THSNN_Linear_set_bias(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Linear_weight(torch.nn.Module.HType module); - - [DllImport("LibTorchSharp")] - internal static extern void THSNN_Linear_set_weight(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Linear_ctor(long input_size, long output_size, [MarshalAs(UnmanagedType.U1)] bool bias, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_functional_linear(IntPtr input, IntPtr weights, IntPtr bias); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Flatten_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Flatten_ctor(long startDim, long endDim, out IntPtr pBoxedModule); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Identity_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Identity_ctor(out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_LSTMCell_forward(torch.nn.Module.HType module, IntPtr input, IntPtr h_0, IntPtr c_0, out IntPtr c_n); @@ -491,9 +428,6 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_TransformerEncoderLayer_ctor(long d_model, long nhead, long dim_feedforward, double dropout, long activation, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Upsample_forward(torch.nn.Module.HType module, IntPtr tensor); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_TransformerEncoder_ctor(torch.nn.Module.HType encoder_layer, long num_layers, out IntPtr pBoxedModule); @@ -506,12 +440,6 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_affine_grid(IntPtr theta, IntPtr size, int size_len, [MarshalAs(UnmanagedType.U1)] bool align_corners); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Unflatten_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Unflatten_ctor(long dim, IntPtr shape, long shape_len, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_normalize(IntPtr input, double p, long dim, double eps); @@ -530,41 +458,8 @@ internal static extern IntPtr THSNN_custom_module( [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_local_response_norm(IntPtr input, long size, double alpha, double beta, double k); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_ConvTranspose2d_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_ConvTranspose2d_bias(torch.nn.Module.HType module); - - [DllImport("LibTorchSharp")] - internal static extern void THSNN_ConvTranspose2d_set_bias(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_ConvTranspose2d_weight(torch.nn.Module.HType module); - - [DllImport("LibTorchSharp")] - internal static extern void THSNN_ConvTranspose2d_set_weight(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_ConvTranspose2d_ctor(long inputChannel, long outputChannel, long kernel_size, long stride, long padding, long outputPadding, long dilation, long paddingMode, long groups, [MarshalAs(UnmanagedType.U1)] bool bias, out IntPtr pBoxedModule); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_ConvTranspose2d_ctor_1(long inputChannel, long outputChannel, long kernelSizeX, long kernelSizeY, long strideX, long strideY, long paddingX, long paddingY, long outputPaddingX, long outputPaddingY, long dilationX, long dilationY, long paddingMode, long groups, [MarshalAs(UnmanagedType.U1)] bool bias, out IntPtr pBoxedModule); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSNN_scaled_dot_product_attention(IntPtr query, IntPtr key, IntPtr value, IntPtr attention_mask, double p, [MarshalAs(UnmanagedType.U1)] bool casual); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Softshrink_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Softshrink_ctor(double lambd, out IntPtr pBoxedModule); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Threshold_forward(torch.nn.Module.HType module, IntPtr tensor); - - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSNN_Threshold_ctor(double threshold, double value, [MarshalAs(UnmanagedType.U1)] bool inplace, out IntPtr pBoxedModule); } #pragma warning restore CA2101 } diff --git a/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs b/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs index a40738802..bb5d2dbd9 100644 --- a/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs +++ b/src/TorchSharp/PInvoke/LibTorchSharp.THSTensor.cs @@ -526,9 +526,6 @@ internal static extern IntPtr THSTensor_upsample_nearest3d(IntPtr input, [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_t(IntPtr tensor); - [DllImport("LibTorchSharp")] - internal static extern IntPtr THSTensor_H(IntPtr tensor); - [DllImport("LibTorchSharp")] internal static extern IntPtr THSTensor_mT(IntPtr tensor);