ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::PlaneInference Class Reference

#include <TFShapeInferenceHelper.h>

Data Structures

struct  Parameters
 

Public Member Functions

PlaneShape operator() (const PlaneShape &in)
 
void padding (const TFPadding &value)
 
void window (const loco::Window< 2 > value)
 
void stride (const loco::Stride< 2 > value)
 

Protected Member Functions

void fill (Parameters &p, const PlaneShape &in)
 
PlaneShape infer (const Parameters &p, const PlaneShape &)
 

Detailed Description

Definition at line 100 of file TFShapeInferenceHelper.h.

Member Function Documentation

◆ fill()

void moco::PlaneInference::fill ( Parameters p,
const PlaneShape in 
)
inlineprotected

Definition at line 113 of file TFShapeInferenceHelper.h.

114 {
115 p.input.height = in.height;
116 p.input.width = in.width;
117
118 p.stride.height = _stride.vertical();
119 p.stride.width = _stride.horizontal();
120
121 p.window.height = _window.vertical();
122 p.window.width = _window.horizontal();
123
124 // TODO support dilation
125 p.dilation.height = 1;
126 p.dilation.width = 1;
127
128 p.effective_window.height = p.dilation.height.value() * (p.window.height.value() - 1) + 1;
129 p.effective_window.width = p.dilation.width.value() * (p.window.width.value() - 1) + 1;
130 }
uint32_t horizontal(void) const
Definition Stride.h:40
uint32_t vertical(void) const
Definition Stride.h:36
uint32_t horizontal(void) const
Definition Window.h:42
uint32_t vertical(void) const
Definition Window.h:38

References moco::PlaneInference::Parameters::dilation, moco::PlaneInference::Parameters::effective_window, moco::PlaneShape::height, loco::Stride< 2 >::horizontal(), loco::Window< 2 >::horizontal(), moco::PlaneInference::Parameters::input, moco::PlaneInference::Parameters::stride, loco::Dimension::value(), loco::Stride< 2 >::vertical(), loco::Window< 2 >::vertical(), moco::PlaneShape::width, and moco::PlaneInference::Parameters::window.

Referenced by operator()(), and moco::Padding2DInference::operator()().

◆ infer()

PlaneShape moco::PlaneInference::infer ( const Parameters p,
const PlaneShape  
)
inlineprotected

Definition at line 132 of file TFShapeInferenceHelper.h.

133 {
134 PlaneShape res;
135
136 if (_padding == "VALID")
137 {
138 res.height =
139 (p.input.height.value() + p.stride.height.value() - p.effective_window.height.value()) /
140 p.stride.height.value();
141 res.width =
142 (p.input.width.value() + p.stride.width.value() - p.effective_window.width.value()) /
143 p.stride.width.value();
144 }
145 else if (_padding == "SAME")
146 {
147 res.height = (p.input.height.value() + p.stride.height.value() - 1) / p.stride.height.value();
148 res.width = (p.input.width.value() + p.stride.width.value() - 1) / p.stride.width.value();
149 }
150 else
151 assert(false);
152
153 return res;
154 }

References moco::PlaneInference::Parameters::effective_window, moco::PlaneShape::height, moco::PlaneInference::Parameters::input, moco::PlaneInference::Parameters::stride, loco::Dimension::value(), and moco::PlaneShape::width.

◆ operator()()

PlaneShape moco::PlaneInference::operator() ( const PlaneShape in)
inline

Definition at line 157 of file TFShapeInferenceHelper.h.

158 {
159 Parameters p;
160
161 fill(p, in);
162
163 return infer(p, in);
164 }
void fill(Parameters &p, const PlaneShape &in)
Definition infer.py:1

References fill().

◆ padding()

void moco::PlaneInference::padding ( const TFPadding value)
inline

Definition at line 167 of file TFShapeInferenceHelper.h.

167{ _padding = value; }

◆ stride()

void moco::PlaneInference::stride ( const loco::Stride< 2 >  value)
inline

Definition at line 169 of file TFShapeInferenceHelper.h.

169{ _stride = value; }

◆ window()

void moco::PlaneInference::window ( const loco::Window< 2 >  value)
inline

Definition at line 168 of file TFShapeInferenceHelper.h.

168{ _window = value; }

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