32{
33
34 assert(node->
opcode() != luci::CircleOpcode::CIRCLEOUTPUT);
35
36
37 assert(node->
opcode() != luci::CircleOpcode::IF);
38 assert(node->
opcode() != luci::CircleOpcode::SPLIT);
39 assert(node->
opcode() != luci::CircleOpcode::SPLIT_V);
40 assert(node->
opcode() != luci::CircleOpcode::TOPK_V2);
41 assert(node->
opcode() != luci::CircleOpcode::UNPACK);
42 assert(node->
opcode() != luci::CircleOpcode::WHILE);
43
44 if (node->
opcode() == luci::CircleOpcode::CIRCLECONST)
45 {
46
47 return;
48 }
49
50 if (node->dtype() == DataType::BOOL)
51 {
52
53 return;
54 }
55 if (node->dtype() == DataType::S32)
56 {
57
58 return;
59 }
60 if (node->dtype() == DataType::S64)
61 {
62
63 return;
64 }
65
66
67 if (
tensor->element_type() != DataType::FLOAT32)
68 {
69
71 {
72 case luci::CircleOpcode::CAST:
73
74
75 case luci::CircleOpcode::RESHAPE:
76
77 return;
78 default:
79 throw std::runtime_error(
"Tensor's data type is not float. " + node->
name());
80 }
81 }
82
85
86 std::vector<float>
buf(data, data + num_elements);
87
88 float max = std::numeric_limits<float>::lowest();
89 float min = std::numeric_limits<float>::max();
90
91 bool all_nan = true;
92 for (
auto number :
buf)
93 {
94 if (isnan(number))
95 continue;
96
97
98 if (number == std::numeric_limits<float>::lowest())
99 continue;
100
101 all_nan = false;
102
103 if (number > max)
105
106 if (number < min)
108 }
109
110 if (all_nan)
111 throw std::runtime_error("All values are NaN(Not a Number)");
112
114}
void recordMinMax(const luci::CircleNode *node, float min, float max)
uint32_t num_elements(const Shape &shape)
The number of elements of a feature map of a given shape.
NodeName name(void) const
virtual CircleOpcode opcode(void) const =0