-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
261 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
utensor_cgen/backend/snippets/templates/snippets/fused_conv2d_maxpool_op.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
{% if ref_count %} | ||
ctx.add(new RamTensor<{{out_dtype}}>(), "{{output}}", {{ref_count}}); | ||
{% else %} | ||
ctx.add(new RamTensor<{{out_dtype}}>(), "{{output}}"); | ||
{% endif %} | ||
ctx.push(new FusedConvMaxpoolOp<{{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}}), | ||
{ {% for tname in inputs[:-1]%}"{{tname}}", {%endfor%}"{{inputs[-1]}}" }, | ||
{ "{{output}}"}); | ||
{% if to_eval %} | ||
ctx.eval(); | ||
{% endif %} | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
utensor_cgen/backend/snippets/templates/snippets/gather_op.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% if create_sptr %} | ||
S_TENSOR {{sptr_name}}; | ||
{% endif %} | ||
{ | ||
{% if ref_count %} | ||
ctx.add(new RamTensor<{{out_dtype}}>(), "{{output}}", {{ref_count}}); | ||
{% else %} | ||
ctx.add(new RamTensor<{{out_dtype}}>(), "{{output}}"); | ||
{% endif %} | ||
ctx.push(new GatherOp<{{in_dtype}}, {{out_dtype}}>(), | ||
{ {% for tname in inputs[:-1]%}"{{tname}}", {%endfor%}"{{inputs[-1]}}" }, | ||
{ "{{output}}" }); | ||
{% if to_eval %} | ||
ctx.eval(); | ||
{% endif %} | ||
} |
23 changes: 23 additions & 0 deletions
23
utensor_cgen/backend/snippets/templates/snippets/qmul_op.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% if create_sptr %} | ||
S_TENSOR {%for sptr_name in sptr_names[:-1]%}{{sptr_name}}, {%endfor%} {{sptr_names[-1]}}; | ||
{% endif %} | ||
{ | ||
{% if ref_counts %} | ||
ctx.add(new RamTensor<{{out_dtype}}>(), "{{outputs[0]}}", {{ref_counts[0]}}); | ||
ctx.add(new RamTensor<float>({1}), "{{outputs[1]}}", {{ref_counts[1]}}); | ||
ctx.add(new RamTensor<float>({1}), "{{outputs[2]}}", {{ref_counts[2]}}); | ||
{% else %} | ||
ctx.add(new RamTensor<{{out_dtype}}>(), "{{outputs[0]}}"); | ||
ctx.add(new RamTensor<float>({1}), "{{outputs[1]}}"); | ||
ctx.add(new RamTensor<float>({1}), "{{outputs[2]}}"); | ||
{% endif %} | ||
ctx.push(new QuantizedMulOp<{{x_dtype}}, {{w_dtype}}, {{out_dtype}}>(), | ||
{ {%for tname in inputs[:-1] %}"{{tname}}", {% endfor %} "{{inputs[-1]}}" }, | ||
{ {%for tname in outputs[:-1] %}"{{tname}}", {% endfor %} "{{outputs[-1]}}" }); | ||
{% for sptr_name, output in zip(sptr_names, outputs) %} | ||
{{sptr_name}} = ctx.get("{{output}}"); | ||
{% endfor %} | ||
{% if to_eval %} | ||
ctx.eval(); | ||
{% endif %} | ||
} |
18 changes: 18 additions & 0 deletions
18
utensor_cgen/backend/snippets/templates/snippets/quantized_fused_conv2d_maxpool_op.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
{% if ref_counts %} | ||
ctx.add(new RamTensor<{{out_dtypes[0]}}>(), "{{outputs[0]}}", {{ref_counts[0]}}); | ||
ctx.add(new RamTensor<{{out_dtypes[1]}}>({1}), "{{outputs[1]}}", {{ref_counts[1]}}); | ||
ctx.add(new RamTensor<{{out_dtypes[2]}}>({1}), "{{outputs[2]}}", {{ref_counts[2]}}); | ||
{% else %} | ||
ctx.add(new RamTensor<{{out_dtypes[0]}}>(), "{{outputs[0]}}"); | ||
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}}), | ||
{ {% for tname in inputs[:-1]%}"{{tname}}", {%endfor%}"{{inputs[-1]}}" }, | ||
{ {% for tname in outputs[:-1]%}"{{tname}}", {%endfor%}"{{outputs[-1]}}" }); | ||
{% if to_eval %} | ||
ctx.eval(); | ||
{% endif %} | ||
} | ||
|
Oops, something went wrong.