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

#include <NodeShape.h>

Public Member Functions

 NodeShape ()=default
 
 NodeShape (const BiasShape &shape)
 
 NodeShape (const DepthwiseFilterShape &shape)
 
 NodeShape (const FeatureShape &shape)
 
 NodeShape (const FilterShape &shape)
 
 NodeShape (const MatrixShape &shape)
 
 NodeShape (const TensorShape &shape)
 
const Domaindomain (void) const
 
void set (const BiasShape &)
 
void set (const DepthwiseFilterShape &)
 
void set (const FeatureShape &)
 
void set (const FilterShape &)
 
void set (const MatrixShape &)
 
void set (const TensorShape &)
 
template<typename ShapeType >
ShapeType as (void) const
 
template<>
BiasShape as (void) const
 
template<>
DepthwiseFilterShape as (void) const
 
template<>
FeatureShape as (void) const
 
template<>
FilterShape as (void) const
 
template<>
MatrixShape as (void) const
 
template<>
TensorShape as (void) const
 

Detailed Description

Definition at line 34 of file NodeShape.h.

Constructor & Destructor Documentation

◆ NodeShape() [1/7]

loco::NodeShape::NodeShape ( )
default

◆ NodeShape() [2/7]

loco::NodeShape::NodeShape ( const BiasShape shape)
inline

Definition at line 40 of file NodeShape.h.

40{ set(shape); }
void set(const BiasShape &)
Definition NodeShape.cpp:28

References set().

◆ NodeShape() [3/7]

loco::NodeShape::NodeShape ( const DepthwiseFilterShape shape)
inline

Definition at line 41 of file NodeShape.h.

41{ set(shape); }

References set().

◆ NodeShape() [4/7]

loco::NodeShape::NodeShape ( const FeatureShape shape)
inline

Definition at line 42 of file NodeShape.h.

42{ set(shape); }

References set().

◆ NodeShape() [5/7]

loco::NodeShape::NodeShape ( const FilterShape shape)
inline

Definition at line 43 of file NodeShape.h.

43{ set(shape); }

References set().

◆ NodeShape() [6/7]

loco::NodeShape::NodeShape ( const MatrixShape shape)
inline

Definition at line 44 of file NodeShape.h.

44{ set(shape); }

References set().

◆ NodeShape() [7/7]

loco::NodeShape::NodeShape ( const TensorShape shape)
inline

Definition at line 45 of file NodeShape.h.

45{ set(shape); }

References set().

Member Function Documentation

◆ as() [1/7]

◆ as() [2/7]

template<>
BiasShape loco::NodeShape::as ( void  ) const

Definition at line 36 of file NodeShape.cpp.

37{
38 assert(_domain == Domain::Bias);
39
40 BiasShape res;
41
42 res.length() = _dims.at(0);
43
44 return res;
45}

References loco::Bias, and loco::BiasShape::length().

◆ as() [3/7]

template<>
DepthwiseFilterShape loco::NodeShape::as ( void  ) const

Definition at line 66 of file NodeShape.cpp.

67{
68 assert(_domain == Domain::DepthwiseFilter);
69
70 DepthwiseFilterShape res;
71
72 res.multiplier() = _dims.at(0);
73 res.depth() = _dims.at(1);
74 res.height() = _dims.at(2);
75 res.width() = _dims.at(3);
76
77 return res;
78}

References loco::DepthwiseFilterShape::depth(), loco::DepthwiseFilter, loco::DepthwiseFilterShape::height(), loco::DepthwiseFilterShape::multiplier(), and loco::DepthwiseFilterShape::width().

◆ as() [4/7]

template<>
FeatureShape loco::NodeShape::as ( void  ) const

Definition at line 99 of file NodeShape.cpp.

100{
101 assert(_domain == Domain::Feature);
102
103 FeatureShape res;
104
105 res.count() = _dims.at(0);
106 res.depth() = _dims.at(1);
107 res.height() = _dims.at(2);
108 res.width() = _dims.at(3);
109
110 return res;
111}

References loco::FeatureShape::count(), loco::FeatureShape::depth(), loco::Feature, loco::FeatureShape::height(), and loco::FeatureShape::width().

◆ as() [5/7]

template<>
FilterShape loco::NodeShape::as ( void  ) const

Definition at line 132 of file NodeShape.cpp.

133{
134 assert(_domain == Domain::Filter);
135
136 FilterShape res;
137
138 res.count() = _dims.at(0);
139 res.depth() = _dims.at(1);
140 res.height() = _dims.at(2);
141 res.width() = _dims.at(3);
142
143 return res;
144}

References loco::FilterShape::count(), loco::FilterShape::depth(), loco::Filter, loco::FilterShape::height(), and loco::FilterShape::width().

◆ as() [6/7]

template<>
MatrixShape loco::NodeShape::as ( void  ) const

Definition at line 163 of file NodeShape.cpp.

164{
165 assert(_domain == Domain::Matrix);
166
167 MatrixShape res;
168
169 res.height() = _dims.at(0);
170 res.width() = _dims.at(1);
171
172 return res;
173}

References loco::MatrixShape::height(), loco::Matrix, and loco::MatrixShape::width().

◆ as() [7/7]

template<>
TensorShape loco::NodeShape::as ( void  ) const

Definition at line 194 of file NodeShape.cpp.

195{
196 assert(_domain == Domain::Tensor);
197
198 TensorShape res;
199
200 res.rank(_dims.size());
201 for (uint32_t axis = 0; axis < _dims.size(); ++axis)
202 {
203 res.dim(axis) = _dims.at(axis);
204 }
205
206 return res;
207}
uint32_t rank(void) const
Definition Shape.cpp:35
::nncc::core::ADT::tensor::Shape TensorShape
Definition TensorShape.h:25

References loco::TensorShape::dim(), loco::TensorShape::rank(), and loco::Tensor.

◆ domain()

◆ set() [1/6]

void loco::NodeShape::set ( const BiasShape shape)

Definition at line 28 of file NodeShape.cpp.

29{
30 _domain = Domain::Bias;
31
32 _dims.resize(1);
33 _dims.at(0) = shape.length();
34}

References loco::Bias, and loco::BiasShape::length().

Referenced by locoex::COpShapeInferenceRule::infer(), NodeShape(), NodeShape(), NodeShape(), NodeShape(), NodeShape(), and NodeShape().

◆ set() [2/6]

void loco::NodeShape::set ( const DepthwiseFilterShape shape)

Definition at line 55 of file NodeShape.cpp.

56{
58
59 _dims.resize(4);
60 _dims.at(0) = shape.multiplier();
61 _dims.at(1) = shape.depth();
62 _dims.at(2) = shape.height();
63 _dims.at(3) = shape.width();
64}

References loco::DepthwiseFilterShape::depth(), loco::DepthwiseFilter, loco::DepthwiseFilterShape::height(), loco::DepthwiseFilterShape::multiplier(), and loco::DepthwiseFilterShape::width().

◆ set() [3/6]

void loco::NodeShape::set ( const FeatureShape shape)

Definition at line 88 of file NodeShape.cpp.

89{
90 _domain = Domain::Feature;
91
92 _dims.resize(4);
93 _dims.at(0) = shape.count();
94 _dims.at(1) = shape.depth();
95 _dims.at(2) = shape.height();
96 _dims.at(3) = shape.width();
97}

References loco::FeatureShape::count(), loco::FeatureShape::depth(), loco::Feature, loco::FeatureShape::height(), and loco::FeatureShape::width().

◆ set() [4/6]

void loco::NodeShape::set ( const FilterShape shape)

Definition at line 121 of file NodeShape.cpp.

122{
123 _domain = Domain::Filter;
124
125 _dims.resize(4);
126 _dims.at(0) = shape.count();
127 _dims.at(1) = shape.depth();
128 _dims.at(2) = shape.height();
129 _dims.at(3) = shape.width();
130}

References loco::FilterShape::count(), loco::FilterShape::depth(), loco::Filter, loco::FilterShape::height(), and loco::FilterShape::width().

◆ set() [5/6]

void loco::NodeShape::set ( const MatrixShape shape)

Definition at line 154 of file NodeShape.cpp.

155{
156 _domain = Domain::Matrix;
157
158 _dims.resize(2);
159 _dims.at(0) = shape.height();
160 _dims.at(1) = shape.width();
161}

References loco::MatrixShape::height(), loco::Matrix, and loco::MatrixShape::width().

◆ set() [6/6]

void loco::NodeShape::set ( const TensorShape shape)

Definition at line 183 of file NodeShape.cpp.

184{
185 _domain = Domain::Tensor;
186
187 _dims.resize(shape.rank());
188 for (uint32_t axis = 0; axis < shape.rank(); ++axis)
189 {
190 _dims.at(axis) = shape.dim(axis);
191 }
192}

References loco::TensorShape::dim(), loco::TensorShape::rank(), and loco::Tensor.


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