ONE - On-device Neural Engine
Loading...
Searching...
No Matches
exo::MaxPool2DConverter Class Reference

Convert loco::MaxPool2D to locoex::TFLMaxPool2D. More...

#include <MaxPool2DConverter.h>

Collaboration diagram for exo::MaxPool2DConverter:

Public Member Functions

const char * name (void) const final
 
bool convert (loco::MaxPool2D *origin) final
 Converts loco::MaxPool2D to locoex::TFLMaxPool2D.
 
- Public Member Functions inherited from exo::CanonicalNodeConverter< loco::MaxPool2D >
bool run (loco::Graph *graph)
 Run the pass.
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Additional Inherited Members

Detailed Description

Convert loco::MaxPool2D to locoex::TFLMaxPool2D.

Definition at line 30 of file MaxPool2DConverter.h.

Member Function Documentation

◆ convert()

bool exo::MaxPool2DConverter::convert ( loco::MaxPool2D origin)
finalvirtual

Converts loco::MaxPool2D to locoex::TFLMaxPool2D.

Note
This works similar to AvgPool2DConverter. Please refer to the comment in AvgPool2DConverter.

Implements exo::CanonicalNodeConverter< loco::MaxPool2D >.

Definition at line 33 of file MaxPool2DConverter.cpp.

34{
35 auto *graph = origin->graph();
36
38 auto tfl_max = graph->nodes()->create<locoex::TFLMaxPool2D>();
39 {
40 tfl_max->value(dec);
41
42 // set attributes
43 tfl_max->stride()->w(origin->stride()->horizontal());
44 tfl_max->stride()->h(origin->stride()->vertical());
45
46 tfl_max->filter()->w(origin->window()->horizontal());
47 tfl_max->filter()->h(origin->window()->vertical());
48
49 auto pad = origin->pad();
50 if (pad->bottom() == 0 && pad->top() == 0 && pad->left() == 0 && pad->right() == 0)
51 tfl_max->padding(locoex::Padding::VALID);
52 else
53 // TODO This is necessary, but not sufficient condition. More rigorous check required
54 tfl_max->padding(locoex::Padding::SAME);
55
56 tfl_max->fusedActivationFunction(locoex::FusedActFunc::NONE);
57 }
58
60
61 loco::replace(origin).with(enc);
62 origin->ifm(nullptr);
63
64 return true;
65}
const Padding2D * pad(void) const
Definition Nodes.h:311
const Stride< 2 > * stride(void) const
Definition Nodes.h:319
const Window< 2 > * window(void) const
Definition Nodes.h:315
Node * ifm(void) const
Definition Nodes.h:307
Graph * graph(void)
Definition Node.h:70
uint32_t horizontal(void) const
Definition Stride.h:40
uint32_t vertical(void) const
Definition Stride.h:36
void with(Node *into) const
Definition Node.cpp:66
uint32_t horizontal(void) const
Definition Window.h:42
uint32_t vertical(void) const
Definition Window.h:38
MAX_POOL_2D in TensorFlow Lite.
Definition TFLNodes.h:328
loco::Node * value(void) const
Definition TFLNodes.h:335
template loco::FeatureDecode * make_feature_decode< FeatureLayout::NHWC >(loco::Node *input_for_encode)
template loco::FeatureEncode * make_feature_encode< FeatureLayout::NHWC >(loco::Node *input_for_encode)
Subst< SubstQualifier::Default > replace(Node *node)
Definition Node.cpp:82

References loco::Node::graph(), loco::Stride< 2 >::horizontal(), loco::Window< 2 >::horizontal(), loco::MaxPool2D::ifm(), exo::make_feature_decode< FeatureLayout::NHWC >(), exo::make_feature_encode< FeatureLayout::NHWC >(), locoex::NONE, loco::MaxPool2D::pad(), loco::replace(), locoex::SAME, loco::MaxPool2D::stride(), locoex::VALID, locoex::TFLMaxPool2D::value(), loco::Stride< 2 >::vertical(), loco::Window< 2 >::vertical(), loco::MaxPool2D::window(), and loco::Subst< SubstQualifier::Default >::with().

◆ name()

const char * exo::MaxPool2DConverter::name ( void  ) const
inlinefinalvirtual

Reimplemented from exo::CanonicalNodeConverter< loco::MaxPool2D >.

Definition at line 33 of file MaxPool2DConverter.h.

33{ return "exo::MaxPool2DConverter"; }

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