9
9
def simple_tflm_graph ():
10
10
ugraph = uTensorGraph ()
11
11
12
- weight_op = OperationInfo (
13
- name = "weight_const " ,
12
+ mock_input_op0 = OperationInfo (
13
+ name = "mock_input_const0 " ,
14
14
op_type = "Const" ,
15
15
backend = "tensorflow" ,
16
16
ugraph = ugraph ,
17
17
op_attr = dict (),
18
18
input_tensors = [],
19
19
output_tensors = []
20
20
)
21
- #weight_op.op_attr["value"] = np.array([1,2,3,4], dtype=np.int8)
22
- weight_op .op_attr ["value" ] = np .array ([10 ,20 ,30 ,40 ], dtype = np .float32 )
23
- weight_op .op_attr ["shape" ] = [1 ,4 ]
24
-
25
- weight = TensorInfo (
26
- name = "weight" ,
27
- op_name = "weight_const" ,
28
- dtype = np .dtype ("float32" ),
29
- shape = weight_op .op_attr ["shape" ],
21
+ mock_input_op0 .op_attr ["value" ] = np .array ([[2 ],[4 ],[6 ],[8 ]], dtype = np .float32 )
22
+ mock_input_op0 .op_attr ["shape" ] = [4 ,1 ]
23
+
24
+ input0 = TensorInfo (
25
+ name = "input0" ,
26
+ op_name = "mock_input_const0" ,
27
+ dtype = mock_input_op0 .op_attr ["value" ].dtype ,
28
+ shape = mock_input_op0 .op_attr ["shape" ],
30
29
ugraph = ugraph
31
30
)
32
- weight_op .output_tensors = [weight ]
33
31
34
- mock_input_op = OperationInfo (
35
- name = "mock_input_const" ,
32
+ mock_input_op0 .output_tensors = [input0 ]
33
+
34
+ mock_input1_op = OperationInfo (
35
+ name = "mock_input_const1" ,
36
36
op_type = "Const" ,
37
37
backend = "tensorflow" ,
38
38
ugraph = ugraph ,
39
39
op_attr = dict (),
40
40
input_tensors = [],
41
41
output_tensors = []
42
42
)
43
- mock_input_op .op_attr ["value" ] = np .array ([[2 ],[4 ],[6 ],[8 ]], dtype = np .float32 )
44
- mock_input_op .op_attr ["shape" ] = [4 ,1 ]
43
+ mock_input1_op .op_attr ["value" ] = np .array ([[2 ],[4 ],[6 ],[8 ]], dtype = np .float32 )
44
+ mock_input1_op .op_attr ["shape" ] = [4 ,1 ]
45
45
46
46
input1 = TensorInfo (
47
47
name = "input1" ,
48
- op_name = "mock_input_const" ,
49
- dtype = mock_input_op .op_attr ["value" ].dtype ,
50
- shape = mock_input_op .op_attr ["shape" ],
48
+ op_name = "mock_input_const1" ,
49
+ dtype = mock_input1_op .op_attr ["value" ].dtype ,
50
+ shape = mock_input1_op .op_attr ["shape" ],
51
+ ugraph = ugraph
52
+ )
53
+
54
+ mock_input1_op .output_tensors = [input1 ]
55
+
56
+ add_output = TensorInfo (
57
+ name = "add_out" ,
58
+ op_name = "add0" ,
59
+ dtype = mock_input_op0 .op_attr ["value" ].dtype ,
60
+ shape = mock_input_op0 .op_attr ["shape" ],
51
61
ugraph = ugraph
52
62
)
53
63
54
- mock_input_op .output_tensors = [input1 ]
64
+ add_op = OperationInfo (
65
+ name = "add0" ,
66
+ op_type = "ADD" ,
67
+ backend = "tensorflow" ,
68
+ ugraph = ugraph ,
69
+ op_attr = dict (),
70
+ input_tensors = [input0 , input1 ],
71
+ output_tensors = [add_output ]
72
+ )
73
+
74
+ ugraph .ops_info ["ADD0" ] = add_op
75
+
76
+ weight_op = OperationInfo (
77
+ name = "weight_const" ,
78
+ op_type = "Const" ,
79
+ backend = "tensorflow" ,
80
+ ugraph = ugraph ,
81
+ op_attr = dict (),
82
+ input_tensors = [],
83
+ output_tensors = []
84
+ )
85
+ #weight_op.op_attr["value"] = np.array([1,2,3,4], dtype=np.int8)
86
+ weight_op .op_attr ["value" ] = np .array ([10 ,20 ,30 ,40 ], dtype = np .float32 )
87
+ weight_op .op_attr ["shape" ] = [1 ,4 ]
88
+
89
+ weight = TensorInfo (
90
+ name = "weight" ,
91
+ op_name = "weight_const" ,
92
+ dtype = np .dtype ("float32" ),
93
+ shape = weight_op .op_attr ["shape" ],
94
+ ugraph = ugraph
95
+ )
96
+ weight_op .output_tensors = [weight ]
55
97
56
98
bias_op = OperationInfo (
57
99
name = "bias_const" ,
@@ -94,7 +136,7 @@ def simple_tflm_graph():
94
136
ugraph = ugraph
95
137
)
96
138
97
- fc1_op .input_tensors = [input1 , weight , bias ]
139
+ fc1_op .input_tensors = [add_output , weight , bias ]
98
140
fc1_op .output_tensors = [output ]
99
141
100
142
ugraph .ops_info ["FC1" ] = fc1_op
@@ -105,4 +147,4 @@ def simple_tflm_graph():
105
147
#ugraph = prune_graph(ugraph)
106
148
107
149
#return: ugraph, input tensors, output tensors
108
- return [ugraph , [], [ "input1" , "weight" , "bias" , "output" ]]
150
+ return [ugraph , ["input0" , "input1" ], [ "weight" , "bias" , "output" ]]
0 commit comments