Skip to content

Commit 8ac3209

Browse files
committed
fix std:: math
1 parent af8a2fe commit 8ac3209

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

examples/SineExample/SineExample.ino

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
// in future projects you may need to tweek this value: it's a trial and error process
88
#define TENSOR_ARENA_SIZE 2*1024
99

10-
Eloquent::TinyML::TinyML<
11-
NUMBER_OF_INPUTS,
12-
NUMBER_OF_OUTPUTS,
13-
TENSOR_ARENA_SIZE> ml(sine_model);
10+
Eloquent::TinyML::TinyML<NUMBER_OF_INPUTS, NUMBER_OF_OUTPUTS, TENSOR_ARENA_SIZE> ml(sine_model);
1411

1512

1613
void setup() {

examples/SineExample/sine_model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
unsigned char sine_model_quantized_tflite[] = {
3+
unsigned char sine_model[] = {
44
0x18, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x00, 0x00, 0x0e, 0x00,
55
0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00,
66
0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0x00,
@@ -222,4 +222,4 @@ unsigned char sine_model_quantized_tflite[] = {
222222
0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00,
223223
0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x03, 0x00, 0x00, 0x00
224224
};
225-
unsigned int sine_model_quantized_tflite_len = 2640;
225+
unsigned int sine_model_len = 2640;

src/tensorflow/lite/kernels/internal/reference/concatenation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ inline void ConcatenationWithScaling(const ConcatenationParams& params,
122122
const float bias = -input_zeropoint[i] * scale;
123123
for (int j = 0; j < copy_size; ++j) {
124124
const int32_t value =
125-
static_cast<int32_t>(std::round(input_ptr[j] * scale + bias)) +
125+
static_cast<int32_t>(round(input_ptr[j] * scale + bias)) +
126126
output_zeropoint;
127127
output_ptr[j] = static_cast<uint8_t>(
128128
std::max<int32_t>(std::min<int32_t>(255, value), 0));

src/tensorflow/lite/micro/kernels/activation_utils.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ limitations under the License.
2020

2121
#include "tensorflow/lite/c/builtin_op_data.h"
2222

23+
#ifndef _max
24+
#define _max(a, b) ((a) > (b) ? (a) : (b))
25+
#endif
26+
#ifndef _min
27+
#define _min(a, b) ((a) > (b) ? (b) : (a))
28+
#endif
29+
2330
namespace tflite {
2431
namespace ops {
2532
namespace micro {
@@ -30,17 +37,18 @@ inline float ActivationValFloat(TfLiteFusedActivation act, float a) {
3037
case kTfLiteActNone:
3138
return a;
3239
case kTfLiteActRelu:
33-
return std::fmax(0.0f, a);
40+
return _max(0.0f, a);
3441
case kTfLiteActRelu1:
35-
return std::fmax(-1.0f, std::fmin(a, 1.0f));
42+
return _max(-1.0f, _min(a, 1.0f));
3643
case kTfLiteActRelu6:
37-
return std::fmax(0.0f, std::fmin(a, 6.0f));
44+
return _max(0.0f, _min(a, 6.0f));
3845
case kTfLiteActTanh:
39-
return std::tanh(a);
46+
return tanh(a);
4047
case kTfLiteActSignBit:
41-
return std::signbit(a);
48+
//return signbit(a);
49+
return a > 0 ? 1 : 0;
4250
case kTfLiteActSigmoid:
43-
return 1.0f / (1.0f + std::exp(-a));
51+
return 1.0f / (1.0f + exp(-a));
4452
}
4553
}
4654

0 commit comments

Comments
 (0)