diff --git a/utensor_cgen/backend/operators.py b/utensor_cgen/backend/operators.py index a26ca3e3..fd934b23 100644 --- a/utensor_cgen/backend/operators.py +++ b/utensor_cgen/backend/operators.py @@ -494,6 +494,7 @@ class _QuantizedFusedConv2DMaxpoolOperator(_Operator): def __init__(self, op_info, **kwargs): _Operator.__init__(self) + # import pdb; pdb.set_trace() inputs = [tensor_info.name for tensor_info in op_info.input_tensors] outputs = [tensor_info.name for tensor_info in op_info.output_tensors] in_dtype, filter_dtype = (op_info.input_tensors[0].dtype, @@ -504,12 +505,12 @@ def __init__(self, op_info, **kwargs): padding = op_info.op_attr['_utensor_conv']["padding"].value.decode('utf8') parser = NamescopedKWArgsParser(RefCntOptimizer.KWARGS_NAMESCOPE, op_info.op_attr) - ref_count = parser.get('ref_counts', [0])[0] + ref_counts = parser.get('ref_counts', None) to_eval = parser.get('to_eval', False) self._snippet = QuantizedFusedConv2DMaxpoolOpSnippet( inputs, outputs, strides, ksize, padding, in_dtype=in_dtype, filter_dtype=filter_dtype, out_dtypes=out_dtypes, - ref_count=ref_count, to_eval=to_eval + ref_counts=ref_counts, to_eval=to_eval ) diff --git a/utensor_cgen/backend/snippets/_snippets.py b/utensor_cgen/backend/snippets/_snippets.py index 049248a9..92e7b09a 100644 --- a/utensor_cgen/backend/snippets/_snippets.py +++ b/utensor_cgen/backend/snippets/_snippets.py @@ -671,18 +671,19 @@ class QuantizedFusedConv2DMaxpoolOpSnippet(Snippet): def __init__(self, inputs, outputs, strides, ksize, padding, in_dtype, filter_dtype, out_dtypes, - ref_count=0, + ref_counts=None, to_eval=False): + # import pdb; pdb.set_trace() Snippet.__init__(self) - if ref_count: - self.template_vars["ref_count"] = ref_count + if ref_counts: + self.template_vars["ref_counts"] = ref_counts self.template_vars["inputs"] = inputs self.template_vars["outputs"] = outputs self.template_vars["in_dtype"] = NP_TYPES_MAP[in_dtype].tensor_type_str self.template_vars["filter_dtype"] = NP_TYPES_MAP[filter_dtype].tensor_type_str self.template_vars["out_dtypes"] = [ - NP_TYPES_MAP[out_dtype].tensor_type_str - for out_dtype in out_dtypes + NP_TYPES_MAP[dtype].tensor_type_str + for dtype in out_dtypes ] self.template_vars["strides"] = strides self.template_vars["ksize"] = ksize diff --git a/utensor_cgen/backend/snippets/templates/snippets/quantized_fused_conv2d_maxpool_op.cpp b/utensor_cgen/backend/snippets/templates/snippets/quantized_fused_conv2d_maxpool_op.cpp index 7aa4f07a..1161e3df 100644 --- a/utensor_cgen/backend/snippets/templates/snippets/quantized_fused_conv2d_maxpool_op.cpp +++ b/utensor_cgen/backend/snippets/templates/snippets/quantized_fused_conv2d_maxpool_op.cpp @@ -8,7 +8,7 @@ ctx.add(new RamTensor<{{out_dtypes[1]}}>({1}), "{{outputs[1]}}"); ctx.add(new RamTensor<{{out_dtypes[2]}}>({1}), "{{outputs[2]}}"); {% endif %} - ctx.push(new QuantizedFusedConvMaxpoolOp<{{in_dtype}}, {{filter_dtype}}, {{out_dtype}}>({ {% for s in strides[:-1]%}{{s}}, {%endfor%}{{strides[-1]}} }, { {% for s in ksize[:-1]%}{{s}}, {%endfor%}{{ksize[-1]}} },{{padding}}), + ctx.push(new QuantizedFusedConvMaxpoolOp<{{in_dtype}}, {{filter_dtype}}, {{out_dtypes[0]}}>({ {% for s in strides[:-1]%}{{s}}, {%endfor%}{{strides[-1]}} }, { {% for s in ksize[:-1]%}{{s}}, {%endfor%}{{ksize[-1]}} },{{padding}}), { {% for tname in inputs[:-1]%}"{{tname}}", {%endfor%}"{{inputs[-1]}}" }, { {% for tname in outputs[:-1]%}"{{tname}}", {%endfor%}"{{outputs[-1]}}" }); {% if to_eval %}