8#ifndef poplin_MatMul_hpp
9#define poplin_MatMul_hpp
13#include <poplar/Graph.hpp>
14#include <poplar/OptionFlags.hpp>
15#include <poplar/Program.hpp>
18#include <unordered_map>
115 PlanningCache *cache =
nullptr);
122 PlanningCache *cache =
nullptr);
130 PlanningCache *cache =
nullptr);
148 const std::vector<std::size_t> &aShape,
149 const std::vector<std::size_t> &bShape,
151 PlanningCache *cache =
nullptr);
187 PlanningCache *cache =
nullptr);
195 PlanningCache *cache =
nullptr);
213 const std::vector<std::size_t> &aShape,
214 const std::vector<std::size_t> &bShape,
216 PlanningCache *cache =
nullptr);
247 PlanningCache *cache =
nullptr);
255 PlanningCache *cache =
nullptr);
292 PlanningCache *cache =
nullptr);
301 PlanningCache *cache =
nullptr);
327 const std::vector<std::size_t> &aShape,
328 const std::vector<std::size_t> &bShape,
331 PlanningCache *cache =
nullptr);
355 const std::vector<std::size_t> &aShape,
356 const std::vector<std::size_t> &bShape,
359 PlanningCache *cache =
nullptr);
387 const poplar::Type &outputType,
const std::vector<std::size_t> &aShape,
388 const std::vector<std::size_t> &bShape,
416 const std::vector<std::size_t> &aShape,
417 const std::vector<std::size_t> &bShape,
420 PlanningCache *cache =
nullptr);
428 const std::vector<std::size_t> &aShape,
429 const std::vector<std::size_t> &bShape,
432 PlanningCache *cache =
nullptr);
459 const std::vector<std::size_t> &aShape,
460 const std::vector<std::size_t> &bShape,
463 PlanningCache *cache =
nullptr);
471 const std::vector<std::size_t> &aShape,
472 const std::vector<std::size_t> &bShape,
475 PlanningCache *cache =
nullptr);
503 const poplar::Type &outputType,
const std::vector<std::size_t> &aShape,
504 const std::vector<std::size_t> &bShape,
535 const poplar::Type &outputType,
const std::vector<std::size_t> &aShape,
536 const std::vector<std::size_t> &bShape,
571 poplar::Graph &graph,
const std::vector<std::size_t> &aShape,
579 poplar::Graph &graph,
const std::vector<std::size_t> &aShape,
586 poplar::Graph &graph,
const std::vector<std::size_t> &aShape,
636 std::unordered_map<const poplar::OptionFlags *, poplar::OptionFlags>;
648std::set<ConvPlanParams>
674 poplin::PlanningCache &getImpl();
Functions and data types to support performing convolutions.
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 set of option/value string flags to be used in various APIs.
Definition: OptionFlags.hpp:24
A target representation.
Definition: Target.hpp:69
A reference to a subset of tensor elements.
Definition: Tensor.hpp:38
Class representing device data types.
Definition: Type.hpp:42
Program that executes a sequence of programs.
Definition: Program.hpp:77
Definition: MatMul.hpp:672
Linear algebra functions.
Definition: Cholesky.hpp:14
std::unordered_map< const poplar::OptionFlags *, poplar::OptionFlags > MatMulToConvOptions
Mapping of pointers to matrix multiplication option flags to the corresponding convolution option fla...
Definition: MatMul.hpp:636
std::set< ConvPlanParams > matMulGetConvPlanParams(const std::set< MatMulPlanParams > &matmuls, MatMulToConvOptions &matmulToConvOpts)
Obtain the set of convolution parameters corresponding to the user supplied set of parameters for mat...
void 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.
void 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.
poplar::Tensor transposeGroupedMatrix(const poplar::Tensor &A)
Transposes a grouped matrix tensor.
void 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.
poplar::Tensor 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.
poplar::Tensor 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.
poplar::Tensor 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.
void 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.
poplar::Tensor 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.
poplar::Tensor 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 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.
void preplanMatMuls(const std::set< MatMulPlanParams > &matmuls, matmul::PlanningCache &cache)
poplar::Tensor 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).
std::tuple< const poplar::Target *, const MatMulParams, const poplar::OptionFlags * > MatMulPlanParams
A tuple containing the required parameters to preplan a matmul:
Definition: MatMul.hpp:629
poplar::Tensor 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.
void 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.
poplar::Tensor 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.
void matmulValidateOptions(const poplar::OptionFlags &options)
Provides an interface to validate the matmul options.
void 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).
poplar::Tensor 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.
Parameters to define a Matrix multiplication.
Definition: MatMul.hpp:606
std::vector< std::size_t > bShape
Shape of the rhs input matrix (B)
Definition: MatMul.hpp:615
poplar::Type outputType
Output type (of C)
Definition: MatMul.hpp:610
poplar::Type inputType
Input type (of A & B)
Definition: MatMul.hpp:608
std::vector< std::size_t > aShape
Shape of the lhs input matrix (A)
Definition: MatMul.hpp:613