Poplar and PopLibs
ConvUtil.hpp
Go to the documentation of this file.
1// Copyright (c) 2016 Graphcore Ltd. All rights reserved.
10#ifndef poplin_ConvUtil_hpp
11#define poplin_ConvUtil_hpp
13#include <tuple>
14#include <vector>
15
16namespace poplin {
17
20unsigned getDilatedSize(unsigned size, unsigned dilation);
21
25unsigned getInputIndex(unsigned dim, unsigned outputIndex, unsigned kernelIndex,
26 const ConvParams &params);
27
31unsigned getKernelIndex(unsigned dim, unsigned outputIndex, unsigned inputIndex,
32 const ConvParams &params);
33
36std::pair<unsigned, unsigned>
38 std::pair<unsigned, unsigned> outputRange,
39 unsigned kernelIndex, const ConvParams &params);
40
43std::pair<unsigned, unsigned>
45 std::pair<unsigned, unsigned> outputRange,
46 unsigned inputIndex, const ConvParams &params);
47
50std::pair<unsigned, unsigned> getOutputRangeForKernelRange(
51 unsigned dim, std::pair<unsigned, unsigned> outputRange,
52 std::pair<unsigned, unsigned> kernelIndexRange, const ConvParams &params);
53
56std::pair<unsigned, unsigned> getOutputRangeForInputRange(
57 unsigned dim, std::pair<unsigned, unsigned> outputRange,
58 std::pair<unsigned, unsigned> inputRange, const ConvParams &params);
59
62std::pair<unsigned, unsigned>
63getInputRange(unsigned dim, std::pair<unsigned, unsigned> outputRange,
64 unsigned kernelIndex, const ConvParams &params);
65
68std::pair<unsigned, unsigned>
69getKernelRange(unsigned dim, std::pair<unsigned, unsigned> outputRange,
70 unsigned inputIndex, const ConvParams &params);
71
74std::pair<unsigned, unsigned>
75getInputRange(unsigned dim, std::pair<unsigned, unsigned> outputRange,
76 std::pair<unsigned, unsigned> kernelIndexRange,
77 const ConvParams &params);
78
81std::pair<unsigned, unsigned>
82getKernelRange(unsigned dim, std::pair<unsigned, unsigned> outputRange,
83 std::pair<unsigned, unsigned> inputRange,
84 const ConvParams &params);
85
86inline std::pair<unsigned, unsigned>
87getInputRange(unsigned dim, unsigned outputIndex,
88 std::pair<unsigned, unsigned> kernelIndexRange,
89 const ConvParams &params) {
90 return getInputRange(dim, {outputIndex, outputIndex + 1}, kernelIndexRange,
91 params);
92}
93
94inline std::pair<unsigned, unsigned>
95getInputRange(unsigned dim, unsigned outputIndex, const ConvParams &params) {
96 return getInputRange(dim, outputIndex, {0, params.kernelShape[dim]}, params);
97}
98
99inline std::pair<unsigned, unsigned>
100getInputRange(unsigned dim, std::pair<unsigned, unsigned> outputRange,
101 const ConvParams &params) {
102 return getInputRange(dim, outputRange, {0, params.kernelShape[dim]}, params);
103}
104
109ConvParams getGradientParams(const ConvParams &params);
110
114ConvParams getWeightUpdateParams(const ConvParams &fwdParams);
115
116} // namespace poplin
117#endif // poplin_ConvUtil_hpp
Functions and data types to support performing convolutions.
Linear algebra functions.
Definition: Cholesky.hpp:14
ConvParams getGradientParams(const ConvParams &params)
Given a set of parameters, return the set of params that represent the convolution to be applied to t...
std::pair< unsigned, unsigned > getOutputRangeForKernelRange(unsigned dim, std::pair< unsigned, unsigned > outputRange, std::pair< unsigned, unsigned > kernelIndexRange, const ConvParams &params)
Given an output range, return the subset whose calculation involves the specified range of kernel ind...
unsigned getKernelIndex(unsigned dim, unsigned outputIndex, unsigned inputIndex, const ConvParams &params)
Return the index of the kernel element that is multiplied by the specified input index to produce the...
std::pair< unsigned, unsigned > getOutputRangeForInputRange(unsigned dim, std::pair< unsigned, unsigned > outputRange, std::pair< unsigned, unsigned > inputRange, const ConvParams &params)
Given an output range, return the subset whose calculation involves the specified range of input indi...
std::pair< unsigned, unsigned > getInputRange(unsigned dim, std::pair< unsigned, unsigned > outputRange, unsigned kernelIndex, const ConvParams &params)
Return the input range that is associated with the specified kernel index when calculating the specif...
std::pair< unsigned, unsigned > getOutputRangeForInputIndex(unsigned dim, std::pair< unsigned, unsigned > outputRange, unsigned inputIndex, const ConvParams &params)
Given an output range, return the subset whose calculation involves the specified input.
std::pair< unsigned, unsigned > getKernelRange(unsigned dim, std::pair< unsigned, unsigned > outputRange, unsigned inputIndex, const ConvParams &params)
Return the kernel range that is associated with the specified input index when calculating the specif...
unsigned getInputIndex(unsigned dim, unsigned outputIndex, unsigned kernelIndex, const ConvParams &params)
Return the index of the input element that is multiplied by the specified kernel index to produce the...
ConvParams getWeightUpdateParams(const ConvParams &fwdParams)
Given a set of convolution parameters, return the set of params that represent the convolution to be ...
std::pair< unsigned, unsigned > getOutputRangeForKernelIndex(unsigned dim, std::pair< unsigned, unsigned > outputRange, unsigned kernelIndex, const ConvParams &params)
Given an output range, return the subset whose calculation involves the specified kernel index.
unsigned getDilatedSize(unsigned size, unsigned dilation)
Return the output size when the specified dilation is applied to an input of the specified size.