@@ -75,9 +75,9 @@ def execute_node(self, context, graph):
7575 str (context [inputs ].dtype ) == "float32"
7676 ), """Input datatype is
7777 not float32 as expected."""
78- expected_inp_shape = self .get_folded_input_shape ()
78+ expected_inp_shape = self .get_folded_input_shape (in_ind )
7979 reshaped_input = context [inputs ].reshape (expected_inp_shape )
80- export_idt = self .get_input_datatype (0 )
80+ export_idt = self .get_input_datatype (in_ind )
8181 # make copy before saving the array
8282 reshaped_input = reshaped_input .copy ()
8383 np .save (
@@ -87,40 +87,38 @@ def execute_node(self, context, graph):
8787 elif in_ind > 1 :
8888 raise Exception ("Unexpected input found for MatrixVectorActivation_rtl" )
8989 in_ind += 1
90- sim = self .get_rtlsim ()
91- nbits = self .get_instream_width (0 )
92- inp = npy_to_rtlsim_input ("{}/input_0.npy" .format (code_gen_dir ), export_idt , nbits )
93- super ().reset_rtlsim (sim )
94- if mem_mode in ["external" , "internal_decoupled" ]:
95- wnbits = self .get_instream_width (1 )
96- export_wdt = self .get_input_datatype (1 )
97- wei = npy_to_rtlsim_input (
98- "{}/weights.npy" .format (code_gen_dir ), export_wdt , wnbits
99- )
100- num_w_reps = np .prod (self .get_nodeattr ("numInputVectors" ))
101- io_dict = {
102- "inputs" : {"in0" : inp , "in1" : wei * num_w_reps },
103- "outputs" : {"out0" : []},
104- }
105- else :
106- io_dict = {
107- "inputs" : {"in0" : inp },
108- "outputs" : {"out0" : []},
109- }
110- self .rtlsim_multi_io (sim , io_dict )
111- super ().close_rtlsim (sim )
112- output = io_dict ["outputs" ]["out0" ]
113- odt = self .get_output_datatype ()
114- target_bits = odt .bitwidth ()
115- packed_bits = self .get_outstream_width ()
116- out_npy_path = "{}/output.npy" .format (code_gen_dir )
117- out_shape = self .get_folded_output_shape ()
118- rtlsim_output_to_npy (output , out_npy_path , odt , out_shape , packed_bits , target_bits )
119- # load and reshape output
120- output = np .load (out_npy_path )
121- oshape = self .get_normal_output_shape ()
122- output = np .asarray ([output ], dtype = np .float32 ).reshape (* oshape )
123- context [node .output [0 ]] = output
90+ sim = self .get_rtlsim ()
91+ nbits = self .get_instream_width (0 )
92+ inp = npy_to_rtlsim_input ("{}/input_0.npy" .format (code_gen_dir ), export_idt , nbits )
93+ super ().reset_rtlsim (sim )
94+ if mem_mode in ["external" , "internal_decoupled" ]:
95+ wnbits = self .get_instream_width (1 )
96+ export_wdt = self .get_input_datatype (1 )
97+ wei = npy_to_rtlsim_input ("{}/weights.npy" .format (code_gen_dir ), export_wdt , wnbits )
98+ num_w_reps = np .prod (self .get_nodeattr ("numInputVectors" ))
99+ io_dict = {
100+ "inputs" : {"in0" : inp , "in1" : wei * num_w_reps },
101+ "outputs" : {"out0" : []},
102+ }
103+ else :
104+ io_dict = {
105+ "inputs" : {"in0" : inp },
106+ "outputs" : {"out0" : []},
107+ }
108+ self .rtlsim_multi_io (sim , io_dict )
109+ super ().close_rtlsim (sim )
110+ output = io_dict ["outputs" ]["out0" ]
111+ odt = self .get_output_datatype ()
112+ target_bits = odt .bitwidth ()
113+ packed_bits = self .get_outstream_width ()
114+ out_npy_path = "{}/output.npy" .format (code_gen_dir )
115+ out_shape = self .get_folded_output_shape ()
116+ rtlsim_output_to_npy (output , out_npy_path , odt , out_shape , packed_bits , target_bits )
117+ # load and reshape output
118+ output = np .load (out_npy_path )
119+ oshape = self .get_normal_output_shape ()
120+ output = np .asarray ([output ], dtype = np .float32 ).reshape (* oshape )
121+ context [node .output [0 ]] = output
124122 else :
125123 raise Exception (
126124 """Invalid value for attribute exec_mode! Is currently set to: {}
0 commit comments