6#ifndef popnn_Pooling_hpp
7#define popnn_Pooling_hpp
9#include <poplar/Graph.hpp>
10#include <poplar/OptionFlags.hpp>
11#include <poplar/Program.hpp>
25 std::vector<std::size_t> inputFieldShape;
27 std::vector<std::size_t> kernelShape;
29 std::vector<unsigned> stride;
33 std::vector<int> inputTruncationOrPaddingLower;
37 std::vector<int> inputTruncationOrPaddingUpper;
39 std::size_t numChannels;
41 std::size_t batchSize;
45 PoolParams(
PoolingType poolingType, std::vector<std::size_t> inputFieldShape,
46 std::vector<std::size_t> kernelShape, std::vector<unsigned> stride,
47 std::vector<int> inputTruncationOrPaddingLower,
48 std::vector<int> inputTruncationOrPaddingUpper,
49 std::size_t numChannels, std::size_t batchSize,
poplar::Type dType)
50 : poolingType(poolingType), inputFieldShape(std::move(inputFieldShape)),
51 kernelShape(std::move(kernelShape)), stride(std::move(stride)),
52 inputTruncationOrPaddingLower(std::move(inputTruncationOrPaddingLower)),
53 inputTruncationOrPaddingUpper(std::move(inputTruncationOrPaddingUpper)),
54 numChannels(numChannels), batchSize(batchSize), dType(dType) {}
56 std::size_t getNumFieldDims()
const {
return inputFieldShape.size(); }
57 std::vector<std::size_t> getOutputFieldShape()
const;
60std::ostream &operator<<(std::ostream &o,
const PoolParams ¶ms);
64std::vector<std::size_t> getOutputFieldShape(
const PoolParams ¶ms);
66uint64_t getFwdFlops(
const PoolParams ¶ms);
68uint64_t getBwdFlops(
const PoolParams ¶ms);
71 const PoolParams ¶ms);
74 const PoolParams ¶ms);
131 bool useScaledGradient,
154 const unsigned fwdChansPerGroup,
Definitions for pooling operations.
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
poplar::Tensor pool(poplar::Graph &graph, const PoolParams ¶ms, const poplar::Tensor &in, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
Add a pooling operation to the graph.
poplar::Tensor poolInputGradient(poplar::Graph &graph, const PoolParams ¶ms, const poplar::Tensor &in, const poplar::Tensor &pooled, const poplar::Tensor &pooledGradient, bool useScaledGradient, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
Calculate the gradient with respect to the input of a pooling operation given the gradient of the out...
Functions used in neural networks.
Definition: BatchNorm.hpp:14
PoolingType
Pooling types.
Definition: PoolingDef.hpp:12