public NDArray Gather(NDArray result, NDArray src, int dim, NDArray indices) { if (result != null && result.DimensionCount != src.DimensionCount) { throw new InvalidOperationException("result and src must have same number of dimensions"); } if (result != null && dim < 0 && dim >= result.DimensionCount) { throw new ArgumentOutOfRangeException("dim"); } if (indices.DimensionCount != src.DimensionCount) { throw new InvalidOperationException("src and indices must have same number of dimensions"); } if (result != null && !result.IsSameSizeAs(indices)) { throw new InvalidOperationException("result and indices must be the same size"); } if (result != null && !TensorResultBuilder.ArrayEqualExcept(src.Shape, result.Shape, dim)) { throw new InvalidOperationException("result and src must be the same size except in dimension dim"); } var writeTarget = TensorResultBuilder.GetWriteTarget(result, indices.Allocator, src.ElementType, false, indices.Shape); NativeWrapper.InvokeTypeMatch(gather_func, writeTarget, src, dim, indices); return(writeTarget); }
public NDArray ScatterFill(NDArray result, float value, int dim, NDArray indices) { if (result == null) { throw new ArgumentNullException("result"); } if (dim < 0 && dim >= result.DimensionCount) { throw new ArgumentOutOfRangeException("dim"); } if (indices.DimensionCount != result.DimensionCount) { throw new InvalidOperationException("result and indices must have same number of dimensions"); } if (!TensorResultBuilder.ArrayEqualExcept(indices.Shape, result.Shape, dim)) { throw new InvalidOperationException("result and indices must be the same size except in dimension dim"); } var writeTarget = result; NativeWrapper.InvokeTypeMatch(scatterFill_func, writeTarget, value, dim, indices); return(writeTarget); }
public void Cols2Im(NDArray col, NDArray im, int channels, int height, int width, int patch_h, int patch_w, int pad_h, int pad_w, int stride_h, int stride_w, int dilation_h, int dilation_w) { int height_col = (height + 2 * pad_h - (dilation_h * (patch_h - 1) + 1)) / stride_h + 1; int width_col = (width + 2 * pad_w - (dilation_w * (patch_w - 1) + 1)) / stride_w + 1; NativeWrapper.InvokeTypeMatch(cols2im_func, col, height, width, channels, patch_h, patch_w, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, height_col, width_col, im); }
public void Im2Cols(NDArray im, NDArray col, int channels, int height, int width, int ksize_h, int ksize_w, int pad_h, int pad_w, int stride_h, int stride_w, int dilation_h, int dilation_w) { int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; NativeWrapper.InvokeTypeMatch(im2cols_func, im, height, width, channels, ksize_h, ksize_w, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, height_col, width_col, col); }
// allArgs should start with a null placeholder for the RNG object /// <summary> /// Invokes the with RNG. /// </summary> /// <param name="seed">The seed.</param> /// <param name="method">The method.</param> /// <param name="allArgs">All arguments.</param> private static void InvokeWithRng(int?seed, MethodInfo method, params object[] allArgs) { if (!seed.HasValue) { seed = seedGen.Next(); } IntPtr rng; NativeWrapper.CheckResult(CpuOpsNative.TS_NewRNG(out rng)); NativeWrapper.CheckResult(CpuOpsNative.TS_SetRNGSeed(rng, seed.Value)); allArgs[0] = rng; NativeWrapper.InvokeTypeMatch(method, allArgs); NativeWrapper.CheckResult(CpuOpsNative.TS_DeleteRNG(rng)); }
public void Fill(NDArray result, float value) { NativeWrapper.InvokeTypeMatch(fill_func, result, value); }