Skip to content
Snippets Groups Projects
Commit a8cc1e2e authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Squashed commit of the following:

commit 71f8aa09659238e5f6f4fed84522cc5bee21d65e
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 04:51:29 2021 +0000

    Update tensor_ops.rst

commit 5702c75ad714b4ed429199004e5ca5df998569df
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 01:45:12 2021 +0000

    Update tensor_ops.rst

commit 3e3f58cfc484506dae0041f9ad01bd7d9c053ff3
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 01:18:34 2021 +0000

    Update tensor_ops.rst

commit b7cbb40ee39549262c01089372c2bebb787c4c5d
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 01:00:50 2021 +0000

    Update tensor_ops.rst

commit c43c112705c127b138d0b6ea4cf3a2697de283b3
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 00:34:48 2021 +0000

    Update tensor_ops.rst

commit d4a75bf3f9eda6fe414c85061d44c44860a68d83
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 00:32:11 2021 +0000

    Update tensor_ops.rst

commit 0b46e855bfd31887b65171e2d7fa7c3572aae891
Author: akashk4 <akashk4@illinois.edu>
Date:   Thu Apr 1 00:13:12 2021 +0000

    Update tensor_ops.rst

commit 3d47aec1f4c4315ce39a3fdfdc204f01d4cc7ca5
Author: akashk4 <akashk4@illinois.edu>
Date:   Wed Mar 31 23:58:09 2021 +0000

    Update tensor_ops.rst

commit f6eed4389eee89718438574d4242802ec2bb4d27
Author: Yifan Zhao <yifanz16@illinois.edu>
Date:   Wed Mar 31 23:21:06 2021 +0000

    Delete .gitlab-ci.yml for doc branch

commit c44a84afaa8e65a677d9b5755fc9093922960e61
Author: akashk4 <akashk4@illinois.edu>
Date:   Wed Mar 31 23:16:02 2021 +0000

    Update tensor_ops.rst

commit 8cac5fda27c4dc50ec5e5b88b25cfafe574e74bc
Author: akashk4 <akashk4@illinois.edu>
Date:   Wed Mar 31 23:08:13 2021 +0000

    Add documentation for tensor operations
parent c773999d
No related branches found
No related tags found
No related merge requests found
Tensor Operations in HPVM
==========================
Tensor Implementation in HPVM
--------------------------------
Tensors are referred to in HPVM IR with pointers (as opposed to SSA tensor values). The HPVM Tensor Runtime allocates tensors in memory and is responsible for managing them. The runtime assumes that the layout of tensors is NCHW.
Intrinsics for Tensor Operations
--------------------------------
Tensor Add
^^^^^^^^^^^
**Overview**
Add tensor pointed to by input with the tensor pointed to by bias. Axis of size 1 will be broadcast. Rank of input and bias tensors must match. Return a pointer to the resultant tensor of the same size and shape.
``i8* llvm.hpvm.tensor.add(i8* input , i8* bias)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - bias
- Reference to the bias tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Multiplication
^^^^^^^^^^^^^^^^^^^^^
**Overview**
Perform matrix multiplication between the tensor pointed to by input and the tensor pointed to by weight. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.mul(i8* input, i8* weight)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - weight
- Reference to the weight tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - ouput
- Reference to the output tensor
Tensor ReLU
^^^^^^^^^^^^
**Overview**
Perform the element-wise clipped ReLU (Rectified Linear Unit) operation on the tensor pointed to by input. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.relu(i8* input)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Clipped ReLU
^^^^^^^^^^^^^^^^^^^^
**Overview**
Perform the element-wise clipped ReLU (Rectified Linear Unit) operation on the tensor pointed to by input. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.clipped.relu(i8* input)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Tanh
^^^^^^^^^^^^
**Overview**
Perform the element-wise hyperbolic tangent operation on the tensor pointed to by input. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.tanh(i8* input)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Sigmoid
^^^^^^^^^^^^^^^
**Overview**
Perform the element-wise sigmoid function on the tensor pointed to by input. Sigmoid function: output = 1 / (1 + exp(-input). Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.sigmoid(i8* input)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Softmax
^^^^^^^^^^^^^^^
**Overview**
Perform the element-wise softmax operation on the tensor pointed to by input. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.softmax(i8* input)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Convolution
^^^^^^^^^^^^^^^^^^^
**Overview**
Perform convolution operation between the tensor pointed to by input and the tensor pointed to by filter. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.convolution(i8* input, i8* filter, i32 vpad, i32 hpad, i32 vstride, i32 hstride)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - filter
- Reference to the filter tensor
* - vpad
- Vertical pad
* - hpad
- Horizontal pad
* - vstride
- Vertical stride
* - hstride
- Horizontal stride
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Group Convolution
^^^^^^^^^^^^^^^^^^^^^^^^^
**Overview**
Perform depthwise-convolution operation between the tensor pointed to by input and the tensor pointed to by filter. This operation entails performing 2D convolutions separately over each channel of the given input and filter tensors. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.group.convolution(i8* input, i8* filter, i32 vpad, i32 hpad, i32 vstride, i32 hstride)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - filter
- Reference to the filter tensor
* - vpad
- Vertical pad
* - hpad
- Horizontal pad
* - vstride
- Vertical stride
* - hstride
- Horizontal stride
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Batchnorm
^^^^^^^^^^^^^^^^^
**Overview**
Perform batch-normalization operation on the tensor pointed to by input. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.batchnorm(i8* input, i8* gamma, i8* beta, i8* mean, i8* variance, double epsilon)``
Batchnorm is computed using the following formula:
output = beta + gamma * ((input - mean)/sqrt(epsilon + variance))
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - gamma
- Reference to the scale tensor
* - beta
- Reference to the bias tensor
* - mean
- Reference to the mean tensor
* - variance
- Reference to the variance tensor
* - epsilon
- The Epsilon value in the batchnorm formula
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Pool Max
^^^^^^^^^^^^^^^^
**Overview**
Perform reduction maximum function to all elements within the sliding window, and place the maximum value in the output tensor. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.pool.max(i8* input, i8* filter, i32 winWidth, i32 winHeight, i32 vpad, i32 hpad, i32 vstride, i32 hstride)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - filter
- Reference to the filter tensor
* - winWidth
- Width of the sliding window
* - winHeight
- Height of the sliding window
* - vpad
- Vertical pad
* - hpad
- Horizontal pad
* - vstride
- Vertical stride
* - hstride
- Horizontal stride
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Pool Min
^^^^^^^^^^^^^^^^
**Overview**
Perform reduction minimum function to all elements within the sliding window, and place the minimum value in the output tensor. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.pool.min(i8* input, i8* filter, i32 winWidth, i32 winHeight, i32 vpad, i32 hpad, i32 vstride, i32 hstride)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - filter
- Reference to the filter tensor
* - winWidth
- Width of the sliding window
* - winHeight
- Height of the sliding window
* - vpad
- Vertical pad
* - hpad
- Horizontal pad
* - vstride
- Vertical stride
* - hstride
- Horizontal stride
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
Tensor Pool Mean
^^^^^^^^^^^^^^^^^
**Overview**
Perform reduction mean function to all elements within the sliding window, and place the mean value in the output tensor. Return a pointer to the resultant tensor.
``i8* llvm.hpvm.tensor.pool.mean(i8* input, i8* filter, i32 winWidth, i32 winHeight, i32 vpad, i32 hpad, i32 vstride, i32 hstride)``
**Operands**
.. list-table::
:header-rows: 1
* - Operand
- Descrption
* - input
- Reference to the input tensor
* - filter
- Reference to the filter tensor
* - winWidth
- Width of the sliding window
* - winHeight
- Height of the sliding window
* - vpad
- Vertical pad
* - hpad
- Horizontal pad
* - vstride
- Vertical stride
* - hstride
- Horizontal stride
**Result**
.. list-table::
:header-rows: 1
* - Result
- Descrption
* - output
- Reference to the output tensor
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment