Poplar and PopLibs
MatMul.hpp File Reference

Functions and data types for performing matrix multiplies on the IPU. More...

#include "poplin/Convolution.hpp"
#include <iosfwd>
#include <map>
#include <poplar/Graph.hpp>
#include <poplar/OptionFlags.hpp>
#include <poplar/Program.hpp>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Classes

struct  poplin::MatMulParams
 Parameters to define a Matrix multiplication. More...
 
class  poplin::matmul::PlanningCache
 

Namespaces

namespace  poplin
 Linear algebra functions.
 

Typedefs

using poplin::MatMulPlanParams = std::tuple< const poplar::Target *, const MatMulParams, const poplar::OptionFlags * >
 A tuple containing the required parameters to preplan a matmul: More...
 
using poplin::MatMulToConvOptions = std::unordered_map< const poplar::OptionFlags *, poplar::OptionFlags >
 Mapping of pointers to matrix multiplication option flags to the corresponding convolution option flags.
 

Functions

poplar::Tensor poplin::matMul (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::Type &outputType, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Multiply two matrices. More...
 
poplar::Tensor poplin::matMul (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Matrix multiply where output type is the same as input A.
 
void poplin::matMulWithOutput (poplar::Graph &graph, const poplar::Tensor &A_, const poplar::Tensor &B_, poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options_={}, PlanningCache *cache=nullptr)
 Matrix multiply with explicitly defined output.
 
void poplin::matMulReportPlan (std::ostream &out, const poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Report the convolution plan corresponding to the parameters and options provided. More...
 
poplar::Tensor poplin::matMulGrouped (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::Type &outputType, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Multiply two grouped matrices. More...
 
void poplin::matMulGroupedWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options_={}, PlanningCache *cache=nullptr)
 Grouped matmul with explicit output argument.
 
void poplin::matMulGroupedReportPlan (std::ostream &out, const poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Report the convolution plan corresponding to the params and options provided. More...
 
void poplin::matMulAcc (poplar::Graph &graph, const poplar::Tensor &C, float k, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Multiply two matrices and add to a third (with a scaling factor). More...
 
void poplin::matMulAcc (poplar::Graph &graph, const poplar::Tensor &C, const poplar::Tensor &k, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Matrix multiply and accumulate with a single-element scaling factor.
 
void poplin::matMulGroupedAcc (poplar::Graph &graph, const poplar::Tensor &C, float k, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Grouped matrix multiply and accumulate. More...
 
void poplin::matMulGroupedAcc (poplar::Graph &graph, const poplar::Tensor &C, const poplar::Tensor &k, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Grouped matrix multiply and accumulate with a single-element scaling factor.
 
poplar::Tensor poplin::createMatMulInputLHS (poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the left operand of matrix multiplication. More...
 
poplar::Tensor poplin::createMatMulInputLHS (poplar::Graph &graph, const poplar::Type &dataType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the left operand of matrix multiplication. More...
 
poplar::Tensor poplin::createMatMulGroupedInputLHS (poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the left operand of a grouped matrix multiplication. More...
 
poplar::Tensor poplin::createMatMulInputRHS (poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the right operand of matrix multiplication. More...
 
poplar::Tensor poplin::createMatMulInputRHS (poplar::Graph &graph, const poplar::Type &dataType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Overloaded function for when inputType == outputType (represented by the dataType parameter).
 
poplar::Tensor poplin::createMatMulOutput (poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the output operand of matrix multiplication. More...
 
poplar::Tensor poplin::createMatMulOutput (poplar::Graph &graph, const poplar::Type &dataType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Overloaded function for when inputType == outputType (represented by the dataType parameter).
 
poplar::Tensor poplin::createMatMulGroupedInputRHS (poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the right operand of grouped matrix multiplication. More...
 
poplar::Tensor poplin::createMatMulGroupedOutput (poplar::Graph &graph, const poplar::Type &inputType, const poplar::Type &outputType, const std::vector< std::size_t > &aShape, const std::vector< std::size_t > &bShape, const poplar::DebugContext &debugContext, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Create a tensor that is used as the output operand of grouped matrix multiplication (with output). More...
 
poplar::Tensor poplin::preArrangeMatMulInputRHS (poplar::Graph &graph, const std::vector< std::size_t > &aShape, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::Type &outputType, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Pre-arrange right-hand side input. More...
 
poplar::Tensor poplin::preArrangeMatMulInputRHS (poplar::Graph &graph, const std::vector< std::size_t > &aShape, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Pre-arrange input where the output type is the same as B.
 
poplar::Tensor poplin::preArrangeMatMulGroupedInputRHS (poplar::Graph &graph, const std::vector< std::size_t > &aShape, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::Type &outputType, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
 Pre-arrange grouped input with explicitly defined output type.
 
poplar::Tensor poplin::transposeGroupedMatrix (const poplar::Tensor &A)
 Transposes a grouped matrix tensor. More...
 
std::set< ConvPlanParams > poplin::matMulGetConvPlanParams (const std::set< MatMulPlanParams > &matmuls, MatMulToConvOptions &matmulToConvOpts)
 Obtain the set of convolution parameters corresponding to the user supplied set of parameters for matrix multiplication. More...
 
void poplin::preplanMatMuls (const std::set< MatMulPlanParams > &matmuls, matmul::PlanningCache &cache)
 
void poplin::matmulValidateOptions (const poplar::OptionFlags &options)
 Provides an interface to validate the matmul options. More...
 

Detailed Description

Functions and data types for performing matrix multiplies on the IPU.