ONE - On-device Neural Engine
Loading...
Searching...
No Matches
loco::MaxPool2D Class Referencefinal

2D Max Pooling More...

#include <Nodes.h>

Collaboration diagram for loco::MaxPool2D:

Public Member Functions

Nodeifm (void) const
 
void ifm (Node *node)
 
const Padding2Dpad (void) const
 
Padding2Dpad (void)
 
const Window< 2 > * window (void) const
 
Window< 2 > * window (void)
 
const Stride< 2 > * stride (void) const
 
Stride< 2 > * stride (void)
 
- Public Member Functions inherited from loco::CanonicalNodeDef< CanonicalOpcode::MaxPool2D, FixedArity< 1 >::Mixin >
virtual ~CanonicalNodeDef ()=default
 
uint32_t opnum (void) const final
 
CanonicalOpcode opcode (void) const final
 
- Public Member Functions inherited from loco::CanonicalNode
virtual ~CanonicalNode ()=default
 
const Dialectdialect (void) const final
 Return "Dialect" identifier that this node belongs to.
 
template<typename T >
accept (CanonicalNodeVisitorBase< T > *) const
 
template<typename T >
accept (CanonicalNodeMutableVisitorBase< T > *)
 
- Public Member Functions inherited from loco::Node
 Node ()=default
 
 Node (const Node &)=delete
 
 Node (Node &&)=delete
 
virtual ~Node ()
 
Graphgraph (void)
 
const Graphgraph (void) const
 
virtual uint32_t arity (void) const =0
 Return the number of arguments.
 
virtual Nodearg (uint32_t N) const =0
 Access N-th argument node.
 
virtual void drop (void)=0
 Drop all the reference of arguments.
 
- Public Member Functions inherited from loco::AnnotatedItem< NodeAnnotation >
 AnnotatedItem ()=default
 
virtual ~AnnotatedItem ()=default
 
const T * annot (void) const
 Retrieve a stored annotation of type T.
 
void annot (std::unique_ptr< T > &&p)
 Attach or remove a new annotation of type T.
 

Detailed Description

2D Max Pooling

MaxPool2D takes as input a feature map, and produces another feature map


Any valid MaxPool2D nodes SHOULD satisfy the following conditions.

Let us define several helper functions that takes a MaxPool2D nodes first:

  • IFM_DOMAIN returns the domain of its input
  • IFM_H returns the height of its input.
  • IFM_W returns the width of its input.
  • PAD_T returns the top padding required over its input
  • PAD_B returns the bottom padding required over its input
  • PAD_L returns the left padding required over its input
  • PAD_R returns the right padding required over its input
  • WIN_H returns the height of its receptive field.
  • WIN_W returns the width of its receptive field.
  • STRIDE_H returns the vertical(= on height) stride.
  • STRIDE_W returns the horizontal(= on width) stride.

Condition 1 Statement

A valid MaxPool2D node M SHOULD satisfy the following condition:

  • IFM_DOMAIN(M) == Feature

Motivation

There are many possible ways to encode a feature map as a tensor.

  • e.g. NCHW/NHWC/...

In order to give some freedom on memory layout to backend, loco requires a feature map value to be explicitly encoded via FeatureEncode.

Condition 2: Statement

A valid MaxPool2D node M SHOULD satisfy the following conditions:

  • (IFM_H(M) + PAD_T(M) + PAD_B(M) - WIN_H(M)) % STRIDE_H(M) == 0
  • (IFM_W(M) + PAD_L(M) + PAD_R(M) - WIN_W(M)) % STRIDE_W(M) == 0

Motivation

The output shape may differ for each NN framework when these conditions do not hold.

In order to mitigate such a difference among NN frameworks, loco requires these conditions for MaxPool2D nodes.

This means that each frontend implementation SHOULD insert appropriate padding/trimming node

before/after MaxPool2D node according to the semantics of the corresponding NN framework.

Definition at line 304 of file Nodes.h.

Member Function Documentation

◆ ifm() [1/2]

void loco::MaxPool2D::ifm ( Node node)
inline

Definition at line 308 of file Nodes.h.

308{ at(0)->node(node); }

◆ ifm() [2/2]

Node * loco::MaxPool2D::ifm ( void  ) const
inline

◆ pad() [1/2]

Padding2D * loco::MaxPool2D::pad ( void  )
inline

Definition at line 312 of file Nodes.h.

312{ return &_pad; }

◆ pad() [2/2]

const Padding2D * loco::MaxPool2D::pad ( void  ) const
inline

Definition at line 311 of file Nodes.h.

311{ return &_pad; }

Referenced by exo::MaxPool2DConverter::convert().

◆ stride() [1/2]

Stride< 2 > * loco::MaxPool2D::stride ( void  )
inline

Definition at line 320 of file Nodes.h.

320{ return &_stride; }

◆ stride() [2/2]

const Stride< 2 > * loco::MaxPool2D::stride ( void  ) const
inline

Definition at line 319 of file Nodes.h.

319{ return &_stride; }

Referenced by exo::MaxPool2DConverter::convert().

◆ window() [1/2]

Window< 2 > * loco::MaxPool2D::window ( void  )
inline

Definition at line 316 of file Nodes.h.

316{ return &_window; }

◆ window() [2/2]

const Window< 2 > * loco::MaxPool2D::window ( void  ) const
inline

Definition at line 315 of file Nodes.h.

315{ return &_window; }

Referenced by exo::MaxPool2DConverter::convert().


The documentation for this class was generated from the following file: