mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #2271 from kwagyeman/kwabena/fix_input_buffer_size
modules/py_ml: Fix the size of the input bytearray.
This commit is contained in:
commit
4aab0f1aa4
@ -37,6 +37,17 @@ static size_t py_ml_tuple_sum(mp_obj_tuple_t *o) {
|
||||
return size;
|
||||
}
|
||||
|
||||
static size_t pl_ml_dtype_size(char dtype) {
|
||||
switch (dtype) {
|
||||
case 'f':
|
||||
return 4;
|
||||
case 'h':
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void py_ml_process_input(py_ml_model_obj_t *model, mp_obj_t arg) {
|
||||
mp_obj_list_t *input_list = MP_OBJ_TO_PTR(arg);
|
||||
|
||||
@ -49,7 +60,7 @@ static void py_ml_process_input(py_ml_model_obj_t *model, mp_obj_t arg) {
|
||||
if (mp_obj_is_callable(input_arg)) {
|
||||
// Input is a callable. Call the object and pass the tensor buffer and dtype.
|
||||
mp_obj_t fargs[3] = {
|
||||
mp_obj_new_bytearray_by_ref(input_size, input_buffer),
|
||||
mp_obj_new_bytearray_by_ref(input_size * pl_ml_dtype_size(model->input_dtype), input_buffer),
|
||||
MP_OBJ_FROM_PTR(input_shape),
|
||||
mp_obj_new_int(model->input_dtype)
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user