Poplar and PopLibs
Pad.hpp File Reference

Functions for padding a tensor. More...

#include <poplar/Graph.hpp>
#include <poplar/Program.hpp>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  popops
 Common functions, such as elementwise and reductions.
 

Enumerations

enum class  popops::padding::Type { EDGE , REFLECT }
 Padding types as per numpy.pad. More...
 
enum class  popops::padding::MappingMethod { NONE , ZERO , EDGE }
 Methods to map added padding elements to tiles. More...
 

Functions

poplar::Tensor popops::pad (const poplar::Tensor &t, const std::vector< std::ptrdiff_t > &paddingLower, const std::vector< std::ptrdiff_t > &paddingUpper, padding::Type type)
 Return a tensor with numpy-style padding added. More...
 
poplar::Tensor popops::pad (const poplar::Tensor &t, std::ptrdiff_t paddingLower, std::ptrdiff_t paddingUpper, unsigned dim, padding::Type type)
 Return a tensor with numpy-style padding added to one dimension. More...
 
poplar::Tensor popops::pad (poplar::Graph &graph, const poplar::Tensor &t, const std::vector< std::ptrdiff_t > &paddingLower, const std::vector< std::ptrdiff_t > &paddingUpper, float val=0.0f, padding::MappingMethod mappingMethod=padding::MappingMethod::ZERO)
 Return a tensor with constant padding added. More...
 
poplar::Tensor popops::pad (poplar::Graph &graph, const poplar::Tensor &t, std::ptrdiff_t paddingLower, std::ptrdiff_t paddingUpper, unsigned dim, float val=0.0f, padding::MappingMethod mappingMethod=padding::MappingMethod::ZERO)
 Return a tensor with constant padding added to one dimension. More...
 

Detailed Description

Functions for padding a tensor.

Enumeration Type Documentation

◆ MappingMethod

enum class popops::padding::MappingMethod
strong

Methods to map added padding elements to tiles.

Enumerator
NONE 

Padding won't be mapped.

ZERO 

Set tile mapping of padding element to tile 0 for the graph.

EDGE 

Set tile mapping of padding elements to match the nearest-neighbour element which lies on the edge of the tensor prior to padding.

Requires a non-empty tensor to be padded with a complete tile mapping.

◆ Type

enum class popops::padding::Type
strong

Padding types as per numpy.pad.

Enumerator
EDGE 

Also known as nearest-neighbour padding, each new pad element has its value set to that of the pre-padded element nearest to it.

Any such nearest neighbour lies on the edge of the pre-padded tensor, hence the name.

REFLECT 

The tensor is reflected outwards.

Specifically, a new pad element has its value set to that of the element which is an equal distance to the pad element's nearest neighbour as the pad element, but in the opposite direction.