コード例 #1
0
ファイル: Upsample.cs プロジェクト: losttech/TorchSharp
            static public Upsample Upsample(long[]?size = null, double[]?scale_factor = null, UpsampleMode mode = UpsampleMode.Nearest, bool?alignCorners = null)
            {
                unsafe
                {
                    fixed(long *psize = size)
                    {
                        fixed(double *pSF = scale_factor)
                        {
                            byte ac  = (byte)((alignCorners.HasValue) ? (alignCorners.Value ? 1 : 2) : 0);
                            var  res = THSNN_Upsample_ctor((IntPtr)psize, size is null ? 0 : size.Length, (IntPtr)pSF, scale_factor is null ? 0 : scale_factor.Length, (byte)mode, ac, out var boxedHandle);

                            if (res == IntPtr.Zero)
                            {
                                torch.CheckForErrors();
                            }
                            return(new Upsample(res, boxedHandle));
                        }
                    }
                }
            }
コード例 #2
0
ファイル: Upsample.cs プロジェクト: losttech/TorchSharp
 static public Tensor upsample(Tensor x, long[]?size = null, double[]?scale_factor = null, UpsampleMode mode = UpsampleMode.Nearest, bool alignCorners = false)
 {
     using (var d = nn.Upsample(size, scale_factor, mode, alignCorners)) {
         return(d.forward(x));
     }
 }
コード例 #3
0
 void SetUpsampleMode(UpsampleMode value)
 {
     _upsampleMode = value;
     UpdateBilateralDownsampleModeSwitch();
 }