Skip to content

Commit 747ec66

Browse files
authored
Merge pull request #46 from foss-for-synopsys-dwc-arc-processors/elemtype
set el_type of output before relu function uses it
2 parents 662c182 + 8d1b76e commit 747ec66

14 files changed

+257
-477
lines changed

lib/gen/func.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,24 @@ def get_types(self):
164164
if self.datatype == "fx16":
165165
d_type = "int16_t"
166166
w_type = "int16_t"
167-
return (d_type, w_type)
167+
d_enum = "MLI_EL_FX_16"
168+
return (d_type, w_type, d_enum)
168169
if self.datatype == "fx8":
169170
d_type = "int8_t"
170171
w_type = "int8_t"
171-
return (d_type, w_type)
172+
d_enum = "MLI_EL_FX_8"
173+
return (d_type, w_type, d_enum)
172174
if self.datatype == "fx8w16d":
173175
d_type = "int16_t"
174176
w_type = "int8_t"
175-
return (d_type, w_type)
177+
d_enum = "MLI_EL_FX_16"
178+
return (d_type, w_type, d_enum)
176179
print "ERROR: unsopported type: " + self.datatype
177180

178181
def print_body(self, template_file):
179182
f = open(template_file, "r")
180183
s = Template(f.read())
181-
d_type, w_type = self.get_types()
184+
d_type, w_type, d_enum = self.get_types()
182185
# we use 'SAME' padding scheme from the TensorFlow
183186
#the bottom and right sides may have the one additional padded pixel in some cases.
184187
#for example, an even size of a kernel and a stride equal to 1
@@ -253,6 +256,7 @@ def print_body(self, template_file):
253256
datatype = self.datatype,
254257
d_type = d_type,
255258
w_type = w_type,
259+
d_enum_type = d_enum,
256260
kernelpadding = k_pad,
257261
padding_top = pad_top,
258262
padding_bot = pad_bot,

lib/gen/mli_krn_conv2d_func_body.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
mli_minmax_t val_limit;
4040
// fill output tensor el_type parameter
41-
out->el_type = in->el_type;
41+
out->el_type = $d_enum_type;
4242
// Define output val limits - we need it in case built-in RELU
4343
val_limit = mli_prv_get_relu_min_max(&cfg->relu, out);
4444

@@ -82,7 +82,6 @@
8282
$kernelpadding, 0);
8383

8484
// fill output tensor parameters
85-
out->el_type = in->el_type;
8685
out->rank = in->rank;
8786
out->shape[FMAP_C_DIM_CHW] = out_ch;
8887
out->shape[FMAP_H_DIM_CHW] = out_height;

lib/gen/mli_krn_depthwise_conv2d_func_body.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
mli_minmax_t val_limit;
4040
// fill output tensor el_type parameter
41-
out->el_type = in->el_type;
41+
out->el_type = $d_enum_type;
4242
// Define output val limits - we need it in case built-in RELU
4343
val_limit = mli_prv_get_relu_min_max(&cfg->relu, out);
4444

@@ -80,7 +80,6 @@
8080
1, 1);
8181

8282
// fill output tensor parameters
83-
out->el_type = in->el_type;
8483
out->rank = in->rank;
8584
out->shape[FMAP_C_DIM_CHW] = channels;
8685
out->shape[FMAP_H_DIM_CHW] = out_height;

0 commit comments

Comments
 (0)