forked from SciSharp/Tensor.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormal.cs
More file actions
20 lines (19 loc) · 962 Bytes
/
Copy pathNormal.cs
File metadata and controls
20 lines (19 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using Tensornet.Common;
using Tensornet.Native;
using Tensornet.Native.Param;
namespace Tensornet{
public static partial class Tensor{
public static partial class Random{
public static Tensor<T> Normal<T>(TensorShape shape, double mean = .0, double std = .1) where T : struct, IConvertible, IEquatable<T>{
Tensor<T> res = new Tensor<T>(shape, TensorTypeInfo.GetTypeInfo(typeof(T))._dtype);
NormalInternal<T>(res, mean, std);
return res;
}
private unsafe static void NormalInternal<T>(Tensor<T> t, double mean, double std) where T : struct, IConvertible, IEquatable<T>{
NormalParam param = new NormalParam() { mean = mean, std = std };
IntPtr status = NativeExecutor.Execute(NativeApi.Normal, t.TMemory, t.TLayout, new IntPtr(¶m), Tensor<T>.Provider);
NativeStatus.AssertOK(status);
}
}
}
}