Poplar and PopLibs
FullyConnected.hpp
Go to the documentation of this file.
1// Copyright (c) 2020 Graphcore Ltd. All rights reserved.
6#ifndef popsparse_FullyConnected_hpp
7#define popsparse_FullyConnected_hpp
8
9#include <poplar/Graph.hpp>
10#include <poplar/OptionFlags.hpp>
11#include <poplar/Program.hpp>
15
16namespace popsparse {
18namespace dynamic {
19
65SparseTensor
67 const FullyConnectedParams &params,
68 const poplar::DebugContext &debugContext = {},
69 const poplar::OptionFlags &options = {},
70 PlanningCache *cache = nullptr);
71
87 const FullyConnectedParams &params,
88 const poplar::DebugContext &debugContext = {},
89 const poplar::OptionFlags &options = {},
90 PlanningCache *cache = nullptr);
91
121 const SparseTensor &weights,
122 const poplar::Tensor &activations,
123 const FullyConnectedParams &fcParams,
125 const poplar::DebugContext &debugContext = {},
126 const poplar::OptionFlags &options = {},
127 PlanningCache *cache = nullptr);
128
161 poplar::Graph &graph, const SparseTensor &weights,
162 const poplar::Tensor &gradients, const FullyConnectedParams &fcParams,
164 const poplar::DebugContext &debugContext = {},
165 const poplar::OptionFlags &options = {}, PlanningCache *cache = nullptr);
166
197 poplar::Graph &graph, const poplar::Tensor sparsityMetaInfo,
198 const poplar::Tensor &gradA, const poplar::Tensor &activations,
199 const FullyConnectedParams &fcParams, poplar::program::Sequence &prog,
200 const poplar::DebugContext &debugContext = {},
201 const poplar::OptionFlags &options = {}, PlanningCache *cache = nullptr);
202
217std::tuple<unsigned, unsigned, unsigned> fullyConnectedDenseGradWSerialSplits(
218 const poplar::Graph &graph, const poplar::Type &inputType,
219 const FullyConnectedParams &fcParams,
220 const poplar::OptionFlags &options_ = {}, PlanningCache *cache = nullptr);
221
222} // namespace dynamic
223} // namespace popsparse
224
225#endif // popsparse_FullyConnected_hpp
Parameters used for fully-connected layers using sparse tensors.
Caching of plans for dynamically sparse operations.
Basic representation of a sparse tensor.
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 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
Representation of a sparse tensor.
Definition: SparseTensor.hpp:16
std::tuple< unsigned, unsigned, unsigned > fullyConnectedDenseGradWSerialSplits(const poplar::Graph &graph, const poplar::Type &inputType, const FullyConnectedParams &fcParams, const poplar::OptionFlags &options_={}, PlanningCache *cache=nullptr)
Report the serial splitting of a dense gradW output given the memory proportion limit given in option...
poplar::Tensor createFullyConnectedInput(poplar::Graph &graph, const poplar::Type &inputType, const FullyConnectedParams &params, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
Create a dense tensor that is used as the input activations for a fully connected layer.
poplar::Tensor fullyConnectedSparseGradW(poplar::Graph &graph, const poplar::Tensor sparsityMetaInfo, const poplar::Tensor &gradA, const poplar::Tensor &activations, const FullyConnectedParams &fcParams, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
Run a fully connected GradW pass to compute sparse gradients.
SparseTensor createFullyConnectedWeights(poplar::Graph &graph, const poplar::Type &inputType, const FullyConnectedParams &params, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
Create a sparse tensor that is used as the weights W for a fully connected layer.
poplar::Tensor fullyConnectedFwd(poplar::Graph &graph, const SparseTensor &weights, const poplar::Tensor &activations, const FullyConnectedParams &fcParams, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
Run a fully connected forward (or inference) pass.
poplar::Tensor fullyConnectedGradA(poplar::Graph &graph, const SparseTensor &weights, const poplar::Tensor &gradients, const FullyConnectedParams &fcParams, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, PlanningCache *cache=nullptr)
Run a fully connected GradA pass.
Support for sparse matrices.
Definition: codelets.hpp:8