Skip to content

Commit d7765e5

Browse files
Merge pull request #1409 from NiklasGustafsson/unit
Further adjustments based on API compat
2 parents c32a467 + 5055e9a commit d7765e5

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ jobs:
448448
- script: dotnet restore pkg/pack.proj /p:Configuration=Release
449449
displayName: Restore package projects
450450

451-
- script: dotnet pack -c $(BuildConfig) --no-build -v:n /p:SkipNative=true /p:SkipTests=true /p:IncludeTorchSharpPackage=false /p:IncludeLibTorchCpuPackages=false /p:IncludeLibTorchCudaPackages=true pkg/pack.proj
451+
- script: dotnet pack -c $(BuildConfig) --no-build -v:n /p:SkipNative=true /p:SkipTests=true /p:ApiCompatGenerateSuppressionFile=true /p:IncludeTorchSharpPackage=false /p:IncludeLibTorchCpuPackages=false /p:IncludeLibTorchCudaPackages=true pkg/pack.proj
452452
displayName: Create Packages
453453

454454
# We are 10GB space-constrained on the Azure Pipelines CI system so clean up what we can

src/TorchSharp/NN/Activation/Sigmoid.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static Sigmoid Sigmoid()
4545
/// </summary>
4646
/// <param name="inplace">Do the operation in-place. Default: False</param>
4747
/// <returns></returns>
48-
public static Sigmoid Sigmoid(bool inplace = false)
48+
public static Sigmoid Sigmoid(bool inplace)
4949
{
5050
return new Sigmoid(inplace);
5151
}

src/TorchSharp/NN/Activation/Softsign.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,19 @@ public static partial class torch
3232
{
3333
public static partial class nn
3434
{
35+
/// <summary>
36+
/// Softsign
37+
/// </summary>
38+
public static Softsign Softsign()
39+
{
40+
return new Softsign(false);
41+
}
42+
3543
/// <summary>
3644
/// Softsign
3745
/// </summary>
3846
/// <param name="inplace">Do the operation in-place. Default: False</param>
39-
public static Softsign Softsign(bool inplace = false)
47+
public static Softsign Softsign(bool inplace)
4048
{
4149
return new Softsign(inplace);
4250
}

src/TorchSharp/NN/Activation/Tanhshrink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static Tensor tanhshrink(Tensor x, bool inplace = false)
6767
/// </summary>
6868
/// <param name="x">The input tensor</param>
6969
[Obsolete("Not using the PyTorch naming convention.",false)]
70-
public static Tensor tanhshrink(Tensor x) => tanhshrink(x, false);
70+
public static Tensor Tanhshrink(Tensor x) => tanhshrink(x, false);
7171
}
7272
}
7373
}

src/TorchSharp/NN/Activation/Threshold.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public static Tensor threshold(Tensor x, double threshold, double value, bool in
7070
/// <param name="x">The input tensor</param>
7171
/// <param name="threshold">The value to threshold at</param>
7272
/// <param name="value">The value to replace with</param>
73+
/// <param name="inplace">Do the operation in-place</param>
7374
[Obsolete("Not using the PyTorch naming convention.",false)]
74-
public static Tensor Threshold(Tensor x, double threshold, double value) => nn.functional.threshold(x, threshold, value, false);
75+
public static Tensor Threshold(Tensor x, double threshold, double value, bool inplace = false) => nn.functional.threshold(x, threshold, value, inplace);
7576
}
7677
}
7778
}

src/TorchSharp/NN/Module.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,11 @@ public virtual void register_module(string name, Module submodule)
818818
}
819819
}
820820

821+
protected void ConditionallyRegisterParameter(string name, Tensor value)
822+
{
823+
ConditionallyRegisterParameter(name, value as Parameter);
824+
}
825+
821826
protected void ConditionallyRegisterParameter(string name, Parameter? value)
822827
{
823828
if (value is null) {

src/TorchSharp/Tensor/Tensor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,19 +2812,19 @@ public Tensor celu_(Scalar alpha)
28122812
return this;
28132813
}
28142814

2815-
public Tensor elu(double alpha = 1) => elu1(alpha, 1.0, 1.0);
2815+
public Tensor elu(double alpha = 1) => elu(alpha, 1.0, 1.0);
28162816

2817-
public Tensor elu_(double alpha = 1) => elu2(alpha, 1.0, 1.0);
2817+
public Tensor elu_(double alpha = 1) => elu(alpha, 1.0, 1.0);
28182818

2819-
private Tensor elu1(Scalar alpha, Scalar scale, Scalar input_scale)
2819+
public Tensor elu(Scalar alpha, Scalar scale, Scalar input_scale)
28202820
{
28212821
var res = NativeMethods.THSTensor_elu(Handle, alpha.Handle, scale.Handle, input_scale.Handle);
28222822
if (res == IntPtr.Zero)
28232823
CheckForErrors();
28242824
return new Tensor(res);
28252825
}
28262826

2827-
private Tensor elu2(Scalar alpha, Scalar scale, Scalar input_scale)
2827+
public Tensor elu_(Scalar alpha, Scalar scale, Scalar input_scale)
28282828
{
28292829
NativeMethods.THSTensor_elu_(Handle, alpha.Handle, scale.Handle, input_scale.Handle);
28302830
CheckForErrors();

0 commit comments

Comments
 (0)