File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
#include <OnnxMlirRuntime.h>
2
2
#include <stdio.h>
3
+ #include <assert.h>
3
4
4
5
OMTensorList * run_main_graph (OMTensorList * );
5
6
@@ -11,9 +12,16 @@ OMTensorList *create_input_list() {
11
12
12
13
// Construct float arrays filled with 1s or 2s.
13
14
float * x1Data = (float * )malloc (sizeof (float ) * num_elements );
15
+ // Check if memory is allocated for generating the data.
16
+ if (!x1Data ) return NULL ;
14
17
for (int i = 0 ; i < num_elements ; i ++ )
15
18
x1Data [i ] = 1.0 ;
16
19
float * x2Data = (float * )malloc (sizeof (float ) * num_elements );
20
+ // Check if memory is allocated for generating the data.
21
+ if (!x2Data ){
22
+ free (x1Data );
23
+ return NULL ;
24
+ }
17
25
for (int i = 0 ; i < num_elements ; i ++ )
18
26
x2Data [i ] = 2.0 ;
19
27
@@ -32,7 +40,10 @@ OMTensorList *create_input_list() {
32
40
int main () {
33
41
// Generate input TensorList
34
42
OMTensorList * input_list = create_input_list ();
35
-
43
+ if (!input_list ){
44
+ // Return 2 for failure to create inputs.
45
+ return 2 ;
46
+ }
36
47
// Call the compiled onnx model function.
37
48
OMTensorList * output_list = run_main_graph (input_list );
38
49
if (!output_list ) {
You can’t perform that action at this time.
0 commit comments