/// <summary> /// Invokes the specified kernels. /// </summary> /// <param name="kernels">The kernels.</param> /// <param name="result">The result.</param> /// <param name="srcA">The source a.</param> /// <param name="srcB">The source b.</param> /// <param name="weight">The weight.</param> /// <returns>Tensor.</returns> public static NDArray Invoke(ElementwiseKernels kernels, NDArray result, NDArray srcA, NDArray srcB, float weight) { var context = CudaHelpers.TSContextForTensor(srcA); var cudaContext = context.CudaContextForTensor(srcA); var writeTarget = TensorResultBuilder.GetWriteTarget(result, srcA, false, srcA.Shape); var elementCount = writeTarget.ElementCount(); var ptx = kernels.GetPtx(context.Compiler); ApplyOpInvoke.Invoke(context, cudaContext, ptx, "lerp", writeTarget, srcA, srcB, weight, elementCount); return(writeTarget); }
/// <summary> /// Invokes the specified kernels. /// </summary> /// <param name="kernels">The kernels.</param> /// <param name="result">The result.</param> /// <param name="srcY">The source y.</param> /// <param name="srcX">The source x.</param> /// <returns>Tensor.</returns> public static Tensor Invoke(ElementwiseKernels kernels, Tensor result, Tensor srcY, Tensor srcX) { var context = CudaHelpers.TSContextForTensor(srcY); var cudaContext = context.CudaContextForTensor(srcY); var writeTarget = TensorResultBuilder.GetWriteTarget(result, srcY, false, srcY.Shape); var elementCount = writeTarget.ElementCount(); var ptx = kernels.GetPtx(context.Compiler); ApplyOpInvoke.Invoke(context, cudaContext, ptx, "atan2", writeTarget, srcY, srcX, elementCount); return(writeTarget); }
public static Tensor Invoke(ElementwiseKernels kernels, Tensor result, Tensor srcA, Tensor srcB, float weight) { TSCudaContext context = CudaHelpers.TSContextForTensor(srcA); CudaContext cudaContext = context.CudaContextForTensor(srcA); cudaContext.SetCurrent(); Tensor writeTarget = TensorResultBuilder.GetWriteTarget(result, srcA, false, srcA.Sizes); long elementCount = writeTarget.ElementCount(); byte[] ptx = kernels.GetPtx(context.Compiler); ApplyOpInvoke.Invoke(context, cudaContext, ptx, "lerp", writeTarget, srcA, srcB, weight, elementCount); return(writeTarget); }
/// <summary> /// Invokes the specified kernels. /// </summary> /// <param name="kernels">The kernels.</param> /// <param name="funcName">Name of the function.</param> /// <param name="result">The result.</param> /// <param name="lhs">The LHS.</param> /// <param name="rhs">The RHS.</param> /// <returns>Tensor.</returns> public static NDArray Invoke(ElementwiseKernels kernels, string funcName, NDArray result, NDArray lhs, NDArray rhs) { var context = CudaHelpers.TSContextForTensor(lhs); var cudaContext = context.CudaContextForTensor(lhs); var writeTarget = TensorResultBuilder.GetWriteTarget(result, lhs, false, lhs.Shape); var elementCount = writeTarget.ElementCount(); var ptx = kernels.GetPtx(context.Compiler); if (result == lhs) { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t1_" + funcName, writeTarget, rhs, elementCount); } else { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t2_" + funcName, writeTarget, lhs, rhs, elementCount); } return(writeTarget); }
/// <summary> /// Invokes the specified kernels. /// </summary> /// <param name="kernels">The kernels.</param> /// <param name="funcName">Name of the function.</param> /// <param name="result">The result.</param> /// <param name="src">The source.</param> /// <param name="value">The value.</param> /// <returns>Tensor.</returns> public static Tensor Invoke(ElementwiseKernels kernels, string funcName, Tensor result, Tensor src, float value) { var context = CudaHelpers.TSContextForTensor(src); var cudaContext = context.CudaContextForTensor(src); var writeTarget = TensorResultBuilder.GetWriteTarget(result, src, false, src.Shape); var elementCount = writeTarget.ElementCount(); var ptx = kernels.GetPtx(context.Compiler); if (result == src) { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t1_" + funcName, writeTarget, value, elementCount); } else { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t2_" + funcName, writeTarget, src, value, elementCount); } return(writeTarget); }
/// <summary> /// Invokes the specified kernels. /// </summary> /// <param name="kernels">The kernels.</param> /// <param name="result">The result.</param> /// <param name="src">The source.</param> /// <param name="min">The minimum.</param> /// <param name="max">The maximum.</param> /// <returns>Tensor.</returns> public static NDArray Invoke(ElementwiseKernels kernels, NDArray result, NDArray src, float min, float max) { var funcName = "clamp"; var context = CudaHelpers.TSContextForTensor(src); var cudaContext = context.CudaContextForTensor(src); var writeTarget = TensorResultBuilder.GetWriteTarget(result, src, false, src.Shape); var elementCount = writeTarget.ElementCount(); var ptx = kernels.GetPtx(context.Compiler); if (result == src) { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t1_" + funcName, writeTarget, min, max, elementCount); } else { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t2_" + funcName, writeTarget, src, min, max, elementCount); } return(writeTarget); }
public static Tensor Invoke(ElementwiseKernels kernels, string funcName, Tensor result, Tensor lhs, Tensor rhs, Tensor rhs2, Tensor rhs3) { TSCudaContext context = CudaHelpers.TSContextForTensor(lhs); CudaContext cudaContext = context.CudaContextForTensor(lhs); cudaContext.SetCurrent(); Tensor writeTarget = TensorResultBuilder.GetWriteTarget(result, lhs, false, lhs.Sizes); long elementCount = writeTarget.ElementCount(); byte[] ptx = kernels.GetPtx(context.Compiler); if (result == lhs) { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t1_" + funcName, writeTarget, rhs, rhs2, rhs3, elementCount); } else { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t2_" + funcName, writeTarget, lhs, rhs, rhs2, rhs3, elementCount); } return(writeTarget); }
public static Tensor Invoke(ElementwiseKernels kernels, string funcName, Tensor result, Tensor src, Tensor src2, float step_size, float value) { TSCudaContext context = CudaHelpers.TSContextForTensor(src); CudaContext cudaContext = context.CudaContextForTensor(src); cudaContext.SetCurrent(); Tensor writeTarget = TensorResultBuilder.GetWriteTarget(result, src, false, src.Sizes); long elementCount = writeTarget.ElementCount(); byte[] ptx = kernels.GetPtx(context.Compiler); if (result == src) { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t1_" + funcName, writeTarget, src2, step_size, value, elementCount); } else { ApplyOpInvoke.Invoke(context, cudaContext, ptx, "t2_" + funcName, writeTarget, src, src2, step_size, value, elementCount); } return(writeTarget); }