Skip to content

Commit 7f04132

Browse files
committed
MP_ERROR_TEXT
1 parent 8b3f4ac commit 7f04132

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

NOTES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
Using ESP IDF v5.3.3 or v5.2.2 do not work with MicroPython
4+
Using v5.4.0 or later works fine.
5+
6+
7+
Wrapped the raising errors with MP_ERROR_TEXT

src/base.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ target_compile_options(microlite INTERFACE
275275
-Wno-error=pointer-arith
276276
-Wno-error=unused-const-variable
277277
-Wno-error=sign-compare
278-
-fno-rtti
279-
-fno-exceptions
278+
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
279+
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
280280
-O3
281281
-Wno-error=maybe-uninitialized
282282
)

src/microlite/tensorflow-microlite.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static mp_obj_t tensor_get_value(mp_obj_t self_in, mp_obj_t index_obj) {
5656
}
5757
// Otherwise, raise an error
5858
else {
59-
mp_raise_TypeError("Unsupported Tensor Type");
59+
mp_raise_TypeError(MP_ERROR_TEXT("Unsupported Tensor Type"));
6060
}
6161

6262
// Return none
@@ -91,7 +91,7 @@ static mp_obj_t tensor_set_value (mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t
9191
}
9292
// Otherwise, raise an error
9393
else {
94-
mp_raise_TypeError("Unsupported Tensor Type");
94+
mp_raise_TypeError(MP_ERROR_TEXT("Unsupported Tensor Type"));
9595
}
9696

9797
// Return our tensor object
@@ -120,7 +120,7 @@ static mp_obj_t tensor_quantize_float_to_int8(mp_obj_t self_in, mp_obj_t float_o
120120
// Check that the object received is a float
121121
if (!mp_obj_is_float(float_obj)) {
122122
// Raise an error
123-
mp_raise_TypeError("Expecting Parameter of float type");
123+
mp_raise_TypeError(MP_ERROR_TEXT("Expecting Parameter of float type"));
124124
}
125125

126126
// Get our tensor object
@@ -148,7 +148,7 @@ static mp_obj_t tensor_quantize_int8_to_float (mp_obj_t self_in, mp_obj_t int_ob
148148

149149
// Check that the object received is an int
150150
if (!mp_obj_is_integer(int_obj)) {
151-
mp_raise_TypeError("Expecting Parameter of float type");
151+
mp_raise_TypeError(MP_ERROR_TEXT("Expecting Parameter of float type"));
152152
}
153153

154154
// Get our tensor object
@@ -157,7 +157,7 @@ static mp_obj_t tensor_quantize_int8_to_float (mp_obj_t self_in, mp_obj_t int_ob
157157

158158
// Check that the tensor is of type int8
159159
if (tensor->type != kTfLiteInt8) {
160-
mp_raise_TypeError("Expected Tensor to be of type ktfLiteInt8.");
160+
mp_raise_TypeError(MP_ERROR_TEXT("Expected Tensor to be of type ktfLiteInt8."));
161161
}
162162

163163
// Get the int8 value from the object

0 commit comments

Comments
 (0)