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

#include <FeatureBiasAddConverter.h>

Collaboration diagram for exo::FeatureBiasAddConverter:

Public Member Functions

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

Additional Inherited Members

Detailed Description

Definition at line 27 of file FeatureBiasAddConverter.h.

Member Function Documentation

◆ convert()

bool exo::FeatureBiasAddConverter::convert ( loco::FeatureBiasAdd origin)
finalvirtual

Converts loco::FeatureBiasAdd to locoex::TFLAdd.

Before: Foo —+ | loco::FeatureBiasAdd - FeatureDecode - ... | Bar - BiasEncode –+

After:

         Foo - loco::FeatureDecode --+           loco::FeatureBiasAdd
                                     |(x)
                                     TFLAdd -- loco::FeatureEncode - FeatureDecode - ...
                                     |(y)

Bar - BiasEncode - loco::BiasDecode –+

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

Definition at line 59 of file FeatureBiasAddConverter.cpp.

60{
61 auto *graph = origin->graph();
62
63 auto tfl_add = graph->nodes()->create<locoex::TFLAdd>();
64
65 // handling input x
66 assert(loco::shape_get(origin->value()).domain() == loco::Domain::Feature);
67
68 auto fea_dec = make_feature_decode<FeatureLayout::NHWC>(origin->value());
69 tfl_add->x(fea_dec);
70
71 // handling input y
72 auto bias_dec = graph->nodes()->create<loco::BiasDecode>();
73 assert(bias_dec != nullptr);
74
75 bias_dec->input(origin->bias());
76
77 tfl_add->y(bias_dec);
78
79 // fused activation function
80 init_fused_act_func(tfl_add);
81
82 // handling output
83 auto fea_enc = make_feature_encode<FeatureLayout::NHWC>(tfl_add);
84
85 loco::replace(origin).with(fea_enc);
86 origin->value(nullptr);
87
88 return true;
89}
Node * value(void) const
Definition Nodes.h:822
Node * bias(void) const
Definition Nodes.h:825
Create a "Tensor" from a "Bias".
Definition Nodes.h:743
Graph * graph(void)
Definition Node.h:70
const Domain & domain(void) const
Definition NodeShape.h:48
void with(Node *into) const
Definition Node.cpp:66
ADD in TensorFlow Lite.
Definition TFLNodes.h:116
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)
NodeShape shape_get(const Node *node)
Subst< SubstQualifier::Default > replace(Node *node)
Definition Node.cpp:82

References loco::BiasAdd< Domain::Feature >::bias(), loco::NodeShape::domain(), loco::Feature, loco::Node::graph(), exo::make_feature_decode< FeatureLayout::NHWC >(), exo::make_feature_encode< FeatureLayout::NHWC >(), loco::replace(), loco::shape_get(), loco::BiasAdd< Domain::Feature >::value(), and loco::Subst< SubstQualifier::Default >::with().

◆ name()

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

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

Definition at line 30 of file FeatureBiasAddConverter.h.

30{ return "exo::TFLAddConverter"; }

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