Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MaixPy-v1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
MaixPy-v1
Commits
59c658e4
Commit
59c658e4
authored
Apr 25, 2019
by
Neucrack
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of sipeed_ai/MaixPy
parents
2382795c
31603f50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
ports/k210-freertos/mpy_support/Maix/Maix_kpu.c
ports/k210-freertos/mpy_support/Maix/Maix_kpu.c
+21
-10
No files found.
ports/k210-freertos/mpy_support/Maix/Maix_kpu.c
View file @
59c658e4
...
...
@@ -294,7 +294,9 @@ int model_deinit(kpu_task_t *task)
STATIC
mp_obj_t
py_kpu_class_load
(
uint
n_args
,
const
mp_obj_t
*
pos_args
,
mp_map_t
*
kw_args
)
{
int
err
=
0
;
// int err = 0;
char
*
err
=
NULL
;
py_kpu_net_obj_t
*
o
=
m_new_obj
(
py_kpu_net_obj_t
);
uint8_t
*
model_data
=
NULL
;
...
...
@@ -304,7 +306,8 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
kpu_task
=
(
uint8_t
*
)
malloc
(
sizeof
(
kpu_model_context_t
));
if
(
kpu_task
==
NULL
)
{
err
=
-
1
;
//malloc error
// err = -1;//malloc error
err
=
"malloc error 0"
;
goto
error
;
}
...
...
@@ -326,7 +329,8 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
if
(
model_size
<
0
)
{
err
=
-
2
;
//read error
// err = -2;//read error
err
=
"read model size error 1"
;
goto
error
;
}
mp_printf
(
&
mp_plat_print
,
"model_size=%d
\r\n
"
,
model_size
);
...
...
@@ -334,20 +338,23 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
model_data
=
(
uint8_t
*
)
malloc
(
model_size
*
sizeof
(
uint8_t
));
if
(
model_data
==
NULL
)
{
err
=
-
1
;
//malloc error
// err = -1;//malloc error
err
=
"malloc error 1"
;
goto
error
;
}
status
=
w25qxx_read_data_dma
(
model_addr
,
model_data
,
model_size
,
W25QXX_QUAD_FAST
);
if
(
status
!=
W25QXX_OK
)
{
err
=
-
2
;
//read error
// err = -2;//read error
err
=
"read model data error 1"
;
goto
error
;
}
int
ret
=
kpu_load_kmodel
(
kpu_task
,
model_data
);
if
(
ret
!=
0
)
{
err
=
-
3
;
//load error
// err = -3; //load error
err
=
"load model data error 1"
;
goto
error
;
}
}
...
...
@@ -364,6 +371,7 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
if
(
err
!=
0
)
{
model_deinit
(
kpu_task
);
err
=
"model init error 2"
;
goto
error
;
}
...
...
@@ -382,7 +390,8 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
if
(
model_size
<=
0
)
{
err
=
-
2
;
//read error
// err = -2;//read error
err
=
"read model size error 2"
;
vfs_internal_close
(
file
,
&
ferr
);
goto
error
;
}
...
...
@@ -390,7 +399,8 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
model_data
=
(
uint8_t
*
)
malloc
(
model_size
*
sizeof
(
uint8_t
));
if
(
model_data
==
NULL
)
{
err
=
-
1
;
//malloc error
// err = -1;//malloc error
err
=
"malloc error 2"
;
goto
error
;
}
...
...
@@ -409,7 +419,8 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
int
ret
=
kpu_load_kmodel
(
kpu_task
,
model_data
);
if
(
ret
!=
0
)
{
err
=
-
3
;
//load error
// err = -3; //load error
err
=
"load model data error 2"
;
goto
error
;
}
...
...
@@ -450,7 +461,7 @@ error:
m_del
(
py_kpu_net_obj_t
,
o
,
sizeof
(
py_kpu_net_obj_t
));
char
msg
[
50
];
sprintf
(
msg
,
"[MAIXPY]
kpu: load error %d
"
,
err
);
sprintf
(
msg
,
"[MAIXPY]
:kpu load error: %s
"
,
err
);
mp_raise_ValueError
(
msg
);
return
mp_const_false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment