Skip to content

Commit 77bf378

Browse files
Merge branch 'main' into unit
2 parents b48a5e5 + 829aae2 commit 77bf378

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/TorchVision/Functional.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,21 +443,21 @@ public static Tensor erase(Tensor img, int top, int left, int height, int width,
443443
/// The image is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions.
444444
/// </summary>
445445
/// <returns></returns>
446-
public static Tensor gaussian_blur(Tensor input, IList<long> kernelSize, ReadOnlySpan<float> sigma)
446+
public static Tensor gaussian_blur(Tensor input, IList<long> kernelSize, IList<float> sigma)
447447
{
448448
var dtype = torch.is_integral(input.dtype) ? ScalarType.Float32 : input.dtype;
449449

450450
if (kernelSize.Count == 1) {
451451
kernelSize = new long[] { kernelSize[0], kernelSize[0] };
452452
}
453453

454-
if (sigma == null || sigma.Length == 0)
454+
if (sigma == null || sigma.Count == 0)
455455
{
456456
sigma = new float[] {
457457
0.3f * ((kernelSize[0] - 1) * 0.5f - 1) + 0.8f,
458458
0.3f * ((kernelSize[1] - 1) * 0.5f - 1) + 0.8f,
459459
};
460-
} else if (sigma.Length == 1) {
460+
} else if (sigma.Count == 1) {
461461
sigma = new float[] {
462462
sigma[0],
463463
sigma[0],
@@ -892,7 +892,7 @@ private static Tensor GetGaussianKernel1d(long size, float sigma)
892892
return pdf / sum;
893893
}
894894

895-
private static Tensor GetGaussianKernel2d(IList<long> kernelSize, ReadOnlySpan<float> sigma, ScalarType dtype, torch.Device device)
895+
private static Tensor GetGaussianKernel2d(IList<long> kernelSize, IList<float> sigma, ScalarType dtype, torch.Device device)
896896
{
897897
using var tX1 = GetGaussianKernel1d(kernelSize[0], sigma[0]);
898898
using var tX2 = tX1.to(dtype, device);

src/TorchVision/GaussianBlur.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal GaussianBlur(IList<long> kernelSize, float sigma_min, float sigma_max)
4040
public override Tensor forward(Tensor input)
4141
{
4242
var s = sigma.HasValue ? sigma.Value : torch.empty(1).uniform_(sigma_min, sigma_max).item<float>();
43-
return transforms.functional.gaussian_blur(input, kernelSize, stackalloc[]{s, s});
43+
return transforms.functional.gaussian_blur(input, kernelSize, new []{s,s});
4444
}
4545

4646
protected long[] kernelSize;

0 commit comments

Comments
 (0)