ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::compute Namespace Reference

Data Structures

class  DepthwiseConv2D
 
struct  DepthwiseParams
 
class  FullyConnected
 
struct  FullyConnectedParams
 
struct  PaddingValues
 

Enumerations

enum class  PaddingType : uint8_t { kNone , kSame , kValid }
 
enum class  FullyConnectedWeightsFormat : uint8_t { kDefault , kShuffled4x16Int8 }
 
enum class  FusedActFunc {
  UNDEFINED , NONE , RELU , RELU_N1_TO_1 ,
  RELU6 , TANH , SIGN_BIT
}
 

Functions

tflite::RuntimeShape tflite_shape (const loco::TensorShape &shape)
 
tflite::PaddingType tflite_padding (const PaddingType type)
 
tflite::FullyConnectedWeightsFormat tflite_weights_format (const FullyConnectedWeightsFormat type)
 
void get_act_minmax (const FusedActFunc act, float &act_min, float &act_max)
 

Enumeration Type Documentation

◆ FullyConnectedWeightsFormat

enum class luci::compute::FullyConnectedWeightsFormat : uint8_t
strong
Enumerator
kDefault 
kShuffled4x16Int8 

Definition at line 80 of file Types.h.

◆ FusedActFunc

enum class luci::compute::FusedActFunc
strong
Enumerator
UNDEFINED 
NONE 
RELU 
RELU_N1_TO_1 
RELU6 
TANH 
SIGN_BIT 

Definition at line 109 of file Types.h.

110{
111 UNDEFINED, // This is not defined by TFLite or Circle. This was added to
112 // prevent programming error.
113 NONE,
114 RELU,
116 RELU6,
117 TANH,
119};

◆ PaddingType

enum class luci::compute::PaddingType : uint8_t
strong
Enumerator
kNone 
kSame 
kValid 

Definition at line 32 of file Types.h.

33{
34 kNone,
35 kSame,
36 kValid
37};

Function Documentation

◆ get_act_minmax()

void luci::compute::get_act_minmax ( const FusedActFunc  act,
float &  act_min,
float &  act_max 
)

Definition at line 26 of file ConvertValues.cpp.

27{
28 switch (act)
29 {
30 case FusedActFunc::NONE:
31 case FusedActFunc::TANH:
32 act_min = std::numeric_limits<float>::lowest();
33 act_max = std::numeric_limits<float>::max();
34 break;
35 case FusedActFunc::RELU:
36 act_min = 0;
37 act_max = std::numeric_limits<float>::max();
38 break;
39 case FusedActFunc::RELU_N1_TO_1:
40 act_min = -1;
41 act_max = 1;
42 break;
43 case FusedActFunc::RELU6:
44 act_min = 0;
45 act_max = 6;
46 break;
47 default:
48 throw std::runtime_error("luci-comp get_act_minmax unsupported type.");
49 }
50}

References NONE, RELU, RELU6, RELU_N1_TO_1, and TANH.

Referenced by luci::compute::DepthwiseConv2D::prepare(), and luci::compute::FullyConnected::prepare().

◆ tflite_padding()

tflite::PaddingType luci::compute::tflite_padding ( const PaddingType  type)

Definition at line 38 of file ConvertTypes.cpp.

39{
40 switch (type)
41 {
42 case PaddingType::kSame:
43 return tflite::PaddingType::kSame;
44 case PaddingType::kValid:
45 return tflite::PaddingType::kValid;
46 default:
47 break;
48 }
49 throw std::runtime_error("luci-comp tflite_padding unsupported type.");
50}

References kSame, and kValid.

Referenced by luci::compute::DepthwiseConv2D::compute().

◆ tflite_shape()

tflite::RuntimeShape luci::compute::tflite_shape ( const loco::TensorShape shape)

Definition at line 26 of file ConvertTypes.cpp.

27{
28 tflite::RuntimeShape runtime_shape(shape.rank());
29 for (uint32_t i = 0; i < shape.rank(); ++i)
30 {
31 if (not shape.dim(i).known())
32 throw std::runtime_error("luci-comp tflite_shape shape unknown.");
33 runtime_shape.SetDim(i, shape.dim(i).value());
34 }
35 return runtime_shape;
36}
uint32_t value(void) const
Return the value.
Definition Dimension.h:51
bool known(void) const
Return whether the value is known (or not)
Definition Dimension.h:47
const Dimension & dim(uint32_t axis) const
Definition TensorShape.h:38
uint32_t rank(void) const
Definition TensorShape.h:35

References loco::TensorShape::dim(), loco::Dimension::known(), loco::TensorShape::rank(), and loco::Dimension::value().

Referenced by luci::compute::DepthwiseConv2D::compute(), and luci::compute::FullyConnected::compute().

◆ tflite_weights_format()

tflite::FullyConnectedWeightsFormat luci::compute::tflite_weights_format ( const FullyConnectedWeightsFormat  type)

Definition at line 52 of file ConvertTypes.cpp.

53{
54 switch (type)
55 {
56 case FullyConnectedWeightsFormat::kDefault:
57 return tflite::FullyConnectedWeightsFormat::kDefault;
58 case FullyConnectedWeightsFormat::kShuffled4x16Int8:
59 return tflite::FullyConnectedWeightsFormat::kShuffled4x16Int8;
60 default:
61 break;
62 }
63 throw std::runtime_error("luci-comp tflite_weights_format unsupported type.");
64}

References kDefault, and kShuffled4x16Int8.

Referenced by luci::compute::FullyConnected::compute().