Library/ManagedCuda/CudaDNN/CudaDNNContext.cs
/// <summary>
/// This function implements the equation C = op(alpha1[0] * A, alpha2[0] * B) + beta[0] * C, 
/// given tensors A, B, and C and scaling factors alpha1, alpha2, and beta.The op to use is 
/// indicated by the descriptor opTensorDesc.Currently-supported ops are listed by the 
/// cudnnOpTensorOp_t enum. Each dimension of the input tensor A must match the corresponding 
/// dimension of the destination tensor C, and each dimension of the input tensor B must match 
/// the corresponding dimension of the destination tensor C or must be equal to 1. In the latter 
/// case, the same value from the input tensor B for those dimensions will be used to blend into the 
/// C tensor.The data types of the input tensors A and B must match. If the data type of the 
/// destination tensor C is double, then the data type of the input tensors also must be double. If 
/// the data type of the destination tensor C is double, then opTensorCompType in opTensorDesc must 
/// be double. Else opTensorCompType must be float. If the input tensor B is the same tensor as 
/// the destination tensor C, then the input tensor A also must be the same tensor as the 
/// destination tensor C.
/// </summary>
/// <param name="op_desc">Handle to a previously initialized op tensor descriptor.</param>
/// <param name="alpha1">Pointer to the scaling factor(in host memory) used to blend the source value with prior 
/// value in the destination tensor as indicated by the above op equation.</param>
/// <param name="a_desc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="a">Pointer to data of the tensor described by the a_desc.</param>
/// <param name="alpha2">Pointer to the scaling factor(in host memory) used to blend the source value with prior 
/// value in the destination tensor as indicated by the above op equation.</param>
/// <param name="b_desc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="b">Pointer to data of the tensor described by the b_desc.</param>
/// <param name="beta">Pointer to the scaling factor(in host memory) used to blend the source value with prior 
/// value in the destination tensor as indicated by the above op equation.</param>
/// <param name="c_desc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="c">Output pointer to data of the tensor described by the c_desc.</param>
This function implements the equation C = op(alpha1[0] * A, alpha2[0] * B) + beta[0] * C,
given tensors A, B, and C and scaling factors alpha1, alpha2, and beta.The op to use is
indicated by the descriptor opTensorDesc.Currently-supported ops are listed by the
cudnnOpTensorOp_t enum. Each dimension of the input tensor A must match the corresponding
dimension of the destination tensor C, and each dimension of the input tensor B must match
the corresponding dimension of the destination tensor C or must be equal to 1. In the latter
case, the same value from the input tensor B for those dimensions will be used to blend into the
C tensor.The data types of the input tensors A and B must match. If the data type of the
destination tensor C is double, then the data type of the input tensors also must be double. If
the data type of the destination tensor C is double, then opTensorCompType in opTensorDesc must
be double. Else opTensorCompType must be float. If the input tensor B is the same tensor as
the destination tensor C, then the input tensor A also must be the same tensor as the
destination tensor C.
This function implements the equation C = op ( alpha1 [ 0 ] * A alpha2 [ 0 ] * B ) + beta [ 0 ] * C given tensors A B and C and scaling factors alpha1 alpha2 and beta . The op to use is indicated by the descriptor opTensorDesc . Currently - supported ops are listed by the cudnnOpTensorOp_t enum . Each dimension of the input tensor A must match the corresponding dimension of the destination tensor C and each dimension of the input tensor B must match the corresponding dimension of the destination tensor C or must be equal to 1 . In the latter case the same value from the input tensor B for those dimensions will be used to blend into the C tensor . The data types of the input tensors A and B must match . If the data type of the destination tensor C is double then the data type of the input tensors also must be double . If the data type of the destination tensor C is double then opTensorCompType in opTensorDesc must be double . Else opTensorCompType must be float . If the input tensor B is the same tensor as the destination tensor C then the input tensor A also must be the same tensor as the destination tensor C .
public void OpTensor(OpTensorDescriptor op_desc,
            float alpha1, TensorDescriptor a_desc, CudaDeviceVariable<float> a,
            float alpha2, TensorDescriptor b_desc, CudaDeviceVariable<float> b,
            float beta, TensorDescriptor c_desc, CudaDeviceVariable<float> c)
        {
            res = CudaDNNNativeMethods.cudnnOpTensor(_handle, op_desc.Desc,
                ref alpha1, a_desc.Desc, a.DevicePointer,
                ref alpha2, b_desc.Desc, b.DevicePointer,
                ref beta, c_desc.Desc, c.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "BatchNormalizationBackward", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
public void OpTensor ( OpTensorDescriptor op_desc , float alpha1 , TensorDescriptor a_desc , CudaDeviceVariable < float > a , float alpha2 , TensorDescriptor b_desc , CudaDeviceVariable < float > b , float beta , TensorDescriptor c_desc , CudaDeviceVariable < float > c ) { res = CudaDNNNativeMethods . cudnnOpTensor ( _handle , op_desc . Desc , ref alpha1 , a_desc . Desc , a . DevicePointer , ref alpha2 , b_desc . Desc , b . DevicePointer , ref beta , c_desc . Desc , c . DevicePointer ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != cudnnStatus . Success ) throw new CudaDNNException ( res ) ; }
This function implements the equation C = op(alpha1[0] * A, alpha2[0] * B) + beta[0] * C,
given tensors A, B, and C and scaling factors alpha1, alpha2, and beta.The op to use is
indicated by the descriptor opTensorDesc.Currently-supported ops are listed by the
cudnnOpTensorOp_t enum.
This function implements the equation C = op ( alpha1 [ 0 ] * A alpha2 [ 0 ] * B ) + beta [ 0 ] * C given tensors A B and C and scaling factors alpha1 alpha2 and beta . The op to use is indicated by the descriptor opTensorDesc . Currently - supported ops are listed by the cudnnOpTensorOp_t enum .
op_desc
OpTensorDescriptor
Handle to a previously initialized op tensor descriptor.
Handle to a previously initialized op tensor descriptor .
alpha1
float
Pointer to the scaling factor(in host memory) used to blend the source value with prior
value in the destination tensor as indicated by the above op equation.
Pointer to the scaling factor ( in host memory ) used to blend the source value with prior value in the destination tensor as indicated by the above op equation .
a_desc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
a
CudaDeviceVariable<float>
Pointer to data of the tensor described by the a_desc.
Pointer to data of the tensor described by the a_desc .
alpha2
float
Pointer to the scaling factor(in host memory) used to blend the source value with prior
value in the destination tensor as indicated by the above op equation.
Pointer to the scaling factor ( in host memory ) used to blend the source value with prior value in the destination tensor as indicated by the above op equation .
b_desc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
b
CudaDeviceVariable<float>
Pointer to data of the tensor described by the b_desc.
Pointer to data of the tensor described by the b_desc .
beta
float
Pointer to the scaling factor(in host memory) used to blend the source value with prior
value in the destination tensor as indicated by the above op equation.
Pointer to the scaling factor ( in host memory ) used to blend the source value with prior value in the destination tensor as indicated by the above op equation .
c_desc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
c
CudaDeviceVariable<float>
Output pointer to data of the tensor described by the c_desc.
Output pointer to data of the tensor described by the c_desc .