Poplar and PopLibs
BlockSparse.hpp
Go to the documentation of this file.
1// Copyright (c) 2020 Graphcore Ltd. All rights reserved.
6#ifndef POPSPARSE_BLOCK_SPARSE_H
7#define POPSPARSE_BLOCK_SPARSE_H
8
9#include <array>
10#include <string>
11#include <vector>
12
13#include <poplar/Graph.hpp>
14#include <poplar/Program.hpp>
15#include <poplar/Tensor.hpp>
16#include <poplar/Type.hpp>
17
18namespace popsparse {
19namespace experimental {
20
26enum class SubBlockMask {
28 None,
33};
34
66 const std::array<int, 2> &dim,
67 const std::array<int, 2> &blockSize,
68 const std::vector<unsigned char> &sparsity,
69 SubBlockMask subBlockMaskType, unsigned numGroups,
71 const poplar::DebugContext &debugContext = {});
72
104 const std::array<int, 2> &dim,
105 const std::array<int, 2> &blockSize,
106 const std::vector<unsigned char> &sparsity,
107 SubBlockMask subBlockMaskType, unsigned numGroups,
109 const poplar::DebugContext &debugContext = {});
110
135 poplar::Tensor sparseOutGrad,
136 const std::array<int, 2> &dim,
137 const std::array<int, 2> &blockSize,
138 const std::vector<unsigned char> &sparsity,
140 const poplar::DebugContext &debugContext = {});
141
142} // namespace experimental
143} // namespace popsparse
144
145#endif // POPSPARSE_BLOCK_SPARSE_H
poplar::Tensor bsSoftmax(poplar::Graph &graph, poplar::Tensor sparseTensor, const std::array< int, 2 > &dim, const std::array< int, 2 > &blockSize, const std::vector< unsigned char > &sparsity, SubBlockMask subBlockMaskType, unsigned numGroups, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
This function computes softmax on a sparse tensor.
SubBlockMask
Define the sparsity mask inside a block.
Definition: BlockSparse.hpp:26
@ None
No elements are zeroed out.
@ ZeroLowerTriangle
Elements in the lower triangle, below the diagonal, are zeroed out.
@ ZeroUpperTriangle
Elements in the upper triangle, above the diagonal, are zeroed out.
poplar::Tensor bsSoftmaxGrad(poplar::Graph &graph, poplar::Tensor sparseOut, poplar::Tensor sparseOutGrad, const std::array< int, 2 > &dim, const std::array< int, 2 > &blockSize, const std::vector< unsigned char > &sparsity, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
This function computes softmax gradient on a sparse tensor.
void bsSoftmaxInPlace(poplar::Graph &graph, poplar::Tensor sparseTensor, const std::array< int, 2 > &dim, const std::array< int, 2 > &blockSize, const std::vector< unsigned char > &sparsity, SubBlockMask subBlockMaskType, unsigned numGroups, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
This function computes softmax on a sparse tensor, in place.
DebugContext gathers the common external parameters of the context of an operation.
Definition: DebugContext.hpp:221
This class represents a graph program to be executed on the IPU.
Definition: Graph.hpp:52
A reference to a subset of tensor elements.
Definition: Tensor.hpp:38
Program that executes a sequence of programs.
Definition: Program.hpp:77
Support for sparse matrices.
Definition: codelets.hpp:8