Skip to content

Commit 2ba7bb2

Browse files
Merge pull request #1294 from yueyinqiu/normal
leaf normal
2 parents 737c5cb + 9f70780 commit 2ba7bb2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __API Changes__:
1010

1111
__Bug Fixes__:
1212

13+
- `torch.normal` will now correctly return a leaf tensor.
1314

1415
# NuGet Version 0.102.4
1516

src/TorchSharp/Tensor/Factories/Tensor.Factories.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public static Tensor eye(long rows, long columns = -1L, ScalarType? dtype = null
116116
/// <returns></returns>
117117
public static Tensor normal(double mean, double std, ReadOnlySpan<long> size, ScalarType? dtype = null, Device? device = null, bool requires_grad = false, Generator? generator = null, string[]? names = null)
118118
{
119-
return randn(size, dtype: dtype, device: device, requires_grad: requires_grad, generator: generator) * std + mean;
119+
return randn(size, dtype, device, requires_grad: false, generator, names)
120+
.mul_(std).add_(mean).requires_grad_(requires_grad);
120121
}
121122

122123
/// <summary>

0 commit comments

Comments
 (0)