forked from dotnet/TorchSharp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPad.cs
46 lines (41 loc) · 1.71 KB
/
Pad.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. See LICENSE in the project root for license information.
using static TorchSharp.torch;
namespace TorchSharp
{
public static partial class torchvision
{
internal class Pad : ITransform
{
internal Pad(long[] pad, PaddingModes mode = PaddingModes.Constant, double value = 0)
{
this.pad = pad;
this.mode = mode;
this.value = value;
}
public Tensor call(Tensor input)
{
return TorchSharp.torch.nn.functional.pad(input, pad, mode, value);
}
private long[] pad;
private PaddingModes mode;
private double value;
}
public static partial class transforms
{
/// <summary>
/// Pad the given image on all sides with the given “pad” value.
/// </summary>
/// <param name="padding">
/// Padding on each border. If a single int is provided this is used to pad all borders.
/// If sequence of length 2 is provided this is the padding on left/right and top/bottom respectively.
/// If a sequence of length 4 is provided this is the padding for the left, top, right and bottom borders respectively.
/// </param>
/// <param name="fill">Pixel fill value for constant fill.</param>
/// <param name="mode">Type of padding.</param>
static public ITransform Pad(long[] padding, PaddingModes mode = PaddingModes.Constant, double fill = 0)
{
return new Pad(padding, mode, fill);
}
}
}
}