nnlib
GPU-accelerated, C/C++ neural network library.
Functions
tensor_operations_on_device.cuh File Reference

Header file declaring tensor operations that happen on device. More...

#include <tensor.h>

Functions

void sumTensorOnDevice (const Tensor &tensor, Tensor &destination)
 
void fillTensorOnDevice (Tensor &tensor, float value)
 Fill a tensor with a constant value. More...
 
void fillTensorOnDevice (Tensor &tensor, const Tensor &value)
 
void addTensorsOnDevice (const Tensor &a, const Tensor &b, Tensor &destination)
 Element-wise add two tensors. More...
 
void subtractTensorsOnDevice (const Tensor &a, const Tensor &b, Tensor &destination)
 Subtract one tensor from another. More...
 
void hadamardTensorsOnDevice (const Tensor &a, const Tensor &b, Tensor &destination)
 Perform hadamard product (element-wise multiplication) between two tensors. More...
 
void divideTensorsOnDevice (const Tensor &a, const Tensor &b, Tensor &destination)
 Divide one tensor by another. More...
 
void logTensorOnDevice (const Tensor &a, Tensor &destination)
 Apply natural logarithm to each element of the tensor. More...
 
void addBroadcastOnDevice (const Tensor &matrix, const Tensor &vector, Tensor &destination)
 Perform the broadcast-add operation. More...
 
void multiplyTensorOnDevice (const Tensor &tensor, float constant, Tensor &destination)
 Multiply a tensor with a constant. More...
 
void multiplyMatrixVectorOnDevice (const Tensor &matrix, const Tensor &vector, Tensor &destination)
 Multiply a matrix with a vector. More...
 
void multiplyMatrixMatrixOnDevice (const Tensor &m1, const Tensor &m2, Tensor &destination)
 Multiply a matrix with a matrix. More...
 
void transposeMatrixOnDevice (const Tensor &matrix, Tensor &destination)
 Transpose a matrix. More...
 
void reluTensorOnDevice (const Tensor &tensor, Tensor &destination)
 
void reluDerivativeTensorOnDevice (const Tensor &tensor, Tensor &destination)
 
void sigmoidTensorOnDevice (const Tensor &tensor, Tensor &destination)
 

Detailed Description

Header file declaring tensor operations that happen on device.

The methods declared in this file are only called when all operands are located on the GPU.

These methods do not perform any checking with regards to the size or location of the operands. This is already done in the corresponding methods in tensor.cpp.

Author
Jan Warchocki
Date
29 August 2022

Function Documentation

◆ addBroadcastOnDevice()

void addBroadcastOnDevice ( const Tensor matrix,
const Tensor vector,
Tensor destination 
)

Perform the broadcast-add operation.

Parameters
matrixThe matrix tensor.
vectorThe vector tensor.
destinationWhere the result of the addition should be stored.

◆ addTensorsOnDevice()

void addTensorsOnDevice ( const Tensor a,
const Tensor b,
Tensor destination 
)

Element-wise add two tensors.

Parameters
aThe first tensor.
bThe second tensor.
destinationWhere the result of the addition should be stored.

◆ divideTensorsOnDevice()

void divideTensorsOnDevice ( const Tensor a,
const Tensor b,
Tensor destination 
)

Divide one tensor by another.

Parameters
aThe tensor to divide.
bThe tensor to divide by.
destinationWhere the result of the operation should be stored.

◆ fillTensorOnDevice()

void fillTensorOnDevice ( Tensor tensor,
float  value 
)

Fill a tensor with a constant value.

Parameters
tensorThe tensor to fill.
valueThe value to fill the tensor with.

◆ hadamardTensorsOnDevice()

void hadamardTensorsOnDevice ( const Tensor a,
const Tensor b,
Tensor destination 
)

Perform hadamard product (element-wise multiplication) between two tensors.

Parameters
aThe first tensor.
bThe second tensor.
destinationWhere the result of the operation should be stored.

◆ logTensorOnDevice()

void logTensorOnDevice ( const Tensor a,
Tensor destination 
)

Apply natural logarithm to each element of the tensor.

Parameters
aThe tensor to apply natural logarithm to.
destinationWhere the result of the operation should be stored.

◆ multiplyMatrixMatrixOnDevice()

void multiplyMatrixMatrixOnDevice ( const Tensor m1,
const Tensor m2,
Tensor destination 
)

Multiply a matrix with a matrix.

Parameters
m1The first matrix tensor.
m2The second matrix tensor.
destinationWhere the result of the multiplication should be stored.

◆ multiplyMatrixVectorOnDevice()

void multiplyMatrixVectorOnDevice ( const Tensor matrix,
const Tensor vector,
Tensor destination 
)

Multiply a matrix with a vector.

Parameters
matrixThe matrix tensor.
vectorThe vector tensor.
destinationWhere the result of the multiplication should be stored.

◆ multiplyTensorOnDevice()

void multiplyTensorOnDevice ( const Tensor tensor,
float  constant,
Tensor destination 
)

Multiply a tensor with a constant.

Parameters
tensorThe tensor to multiply.
constantThe constant to multiply with.
destinationWhere the result of the multiplication should be stored.

◆ subtractTensorsOnDevice()

void subtractTensorsOnDevice ( const Tensor a,
const Tensor b,
Tensor destination 
)

Subtract one tensor from another.

Parameters
aThe tensor to subtract from.
bThe tensor to be subtracted.
destinationWhere the result of the subtraction should be stored.

◆ transposeMatrixOnDevice()

void transposeMatrixOnDevice ( const Tensor matrix,
Tensor destination 
)

Transpose a matrix.

Parameters
matrixThe matrix vector to transpose.
destinationWhere the result of the transpose operation should be stored.