ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Shape.cpp File Reference
#include "Shape.h"
#include <cstddef>

Go to the source code of this file.

Functions

bool SameShape (const Shape &in1, const Shape &in2)
 
bool SetShape (const Shape &in, Shape *out)
 
uint32_t getNumberOfElements (const Shape &shape)
 
uint32_t getNumberOfDimensions (const Shape &shape)
 
uint32_t getSizeOfDimension (const Shape &shape, uint32_t dimensionIdx)
 

Function Documentation

◆ getNumberOfDimensions()

◆ getNumberOfElements()

uint32_t getNumberOfElements ( const Shape shape)

Definition at line 48 of file Shape.cpp.

49{
50 uint32_t count = 1;
51 for (size_t i = 0; i < shape.dimensions.size(); i++)
52 {
53 count *= shape.dimensions[i];
54 }
55 return count;
56}

References Shape::dimensions, and getNumberOfElements().

Referenced by fullyConnectedPrepare(), onert::backend::cpu::ops::getNumberOfElements(), getNumberOfElements(), relu6Float32(), reluFloat32(), reshapePrepare(), onert::backend::cpu::ops::SoftMaxLayer::softmaxFloat32(), and softmaxFloat32().

◆ getSizeOfDimension()

uint32_t getSizeOfDimension ( const Shape shape,
uint32_t  dimensionIdx 
)

◆ SameShape()

bool SameShape ( const Shape in1,
const Shape in2 
)

Definition at line 22 of file Shape.cpp.

23{
24 if (in1.type != in2.type || in1.dimensions.size() != in2.dimensions.size())
25 {
26 return false;
27 }
28 for (size_t i = 0; i < in1.dimensions.size(); i++)
29 {
30 if (in1.dimensions[i] != in2.dimensions[i])
31 {
32 return false;
33 }
34 }
35 return true;
36}
OperandType type
Definition Shape.h:29

References Shape::dimensions, and Shape::type.

Referenced by addFloat32(), addPrepare(), divFloat32(), divPrepare(), mulFloat32(), mulPrepare(), subFloat32(), and subPrepare().

◆ SetShape()

bool SetShape ( const Shape in,
Shape out 
)

Definition at line 38 of file Shape.cpp.

39{
40 if (in.type != out->type || in.dimensions.size() != out->dimensions.size())
41 {
42 return false;
43 }
44 out->dimensions = in.dimensions;
45 return true;
46}

References Shape::dimensions, and Shape::type.

Referenced by addPrepare(), divPrepare(), genericActivationPrepare(), mulPrepare(), and subPrepare().