Skip to content

Commit d22c585

Browse files
AhmedZeroalinpahontu2912
authored andcommitted
Remove IDisposable and constructor checks from Normalize
1 parent 7c51d14 commit d22c585

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

src/TorchVision/Normalize.cs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ namespace TorchSharp
77
{
88
public static partial class torchvision
99
{
10-
internal class Normalize : ITransform, IDisposable
10+
internal class Normalize : ITransform
1111
{
1212
internal Normalize(double[] means, double[] stdevs,bool inplace = false)
1313
{
1414
if (means is null) throw new ArgumentNullException(nameof(means));
1515
if (stdevs is null) throw new ArgumentNullException(nameof(stdevs));
16-
if (means.Length != stdevs.Length)
17-
throw new ArgumentException($"{nameof(means)} and {nameof(stdevs)} must be the same length in call to Normalize");
18-
if (means.Length != 1 && means.Length != 3)
19-
throw new ArgumentException($"Since they correspond to the number of channels in an image, {nameof(means)} and {nameof(stdevs)} must both be either 1 or 3 long");
2016
this.means = means;
2117
this.stdevs = stdevs;
2218
this.inplace = inplace;
@@ -31,27 +27,7 @@ public Tensor call(Tensor input)
3127
private readonly double[] means;
3228
private readonly double[] stdevs;
3329
private readonly bool inplace;
34-
bool disposedValue;
35-
36-
protected virtual void Dispose(bool disposing)
37-
{
38-
if (!disposedValue) {
39-
disposedValue = true;
40-
}
41-
}
42-
43-
~Normalize()
44-
{
45-
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
46-
Dispose(disposing: false);
47-
}
48-
49-
public void Dispose()
50-
{
51-
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
52-
Dispose(disposing: true);
53-
GC.SuppressFinalize(this);
54-
}
30+
5531
}
5632

5733
public static partial class transforms

0 commit comments

Comments
 (0)