Skip to content
Snippets Groups Projects
Commit 9e41dd6b authored by Gallas Gaye's avatar Gallas Gaye
Browse files

feat: Added Concat export op

parent 52d70137
No related branches found
No related tags found
2 merge requests!39Update 0.2.1 -> 0.3.0,!36feat: Add missing operators for AIDGE model benchmarking
#ifndef __AIDGE_EXPORT_CPP_KERNELS_CONCAT__
#define __AIDGE_EXPORT_CPP_KERNELS_CONCAT__
template<typename T, unsigned int NB_INPUTS>
__attribute__((always_inline)) inline static
void concat_forward (
const unsigned int axis,
const T* const * __restrict inputs,
const unsigned int* __restrict sizes,
T* __restrict output)
{
unsigned int offset = 0;
for (unsigned int n = 0; n < NB_INPUTS; ++n) {
for (unsigned int i = 0; i < sizes[n]; ++i) {
output[offset + i] = inputs[n][i];
}
offset += sizes[n];
}
}
#endif // __AIDGE_EXPORT_CPP_KERNELS_CONCAT__
\ No newline at end of file
...@@ -338,3 +338,19 @@ class BatchNorm2DCPP(ExportNodeCpp): ...@@ -338,3 +338,19 @@ class BatchNorm2DCPP(ExportNodeCpp):
str(ROOT / "kernels" / "rescaling.hpp") str(ROOT / "kernels" / "rescaling.hpp")
] ]
@ExportLibCpp.register("Concat", aidge_core.ImplSpec(aidge_core.IOSpec(aidge_core.dtype.float32)))
class Concat(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
print(node.get_operator())
print(dir(node.get_operator()))
self.attributes["nb_in"] = node.get_operator().nb_inputs()
self.attributes["axis"] = node.get_operator().attr.axis
self.config_template = str(ROOT / "templates" / "configuration" / "concat.jinja")
self.forward_template = str(ROOT / "templates" / "forward_call" / "concat.jinja")
self.include_list = []
self.kernels_to_copy = [
str(ROOT / "kernels" / "concat.hpp"),
]
\ No newline at end of file
{#- For name header -#}
#ifndef {{ name|upper }}_LAYER_H
#define {{ name|upper }}_LAYER_H
{% include "./_meminfo.jinja" %}
// Attributes
#define {{ name|upper }}_NB_INPUTS {{ nb_in }}
#define {{ name|upper }}_AXIS {{ axis }}
{%- for i in range(nb_in) %}
#define {{ name|upper }}_INPUT_{{i}}_SIZE {{ in_chan[i] * in_height[i] * in_width[i] }}
{%- endfor %}
#define {{ name|upper }}_OUTPUT_SIZE {{ out_chan[0] * out_height[0] * out_width[0] }}
#endif /* {{ name|upper }}_LAYER_H */
{% filter indent(width=4, first=False) %}
{% include "./_mem_offset.jinja" %}
float* {{ name|upper }}_INPUTS[] = {
{%- for i in range(nb_in) -%}
{{ in_name[i] }}{{ ", " if not loop.last else "" }}
{%- endfor -%}
};
unsigned int {{ name|upper }}_SIZES[] = {
{%- for i in range(nb_in) -%}
{{ name|upper }}_INPUT_{{i}}_SIZE{{ ", " if not loop.last else "" }}
{%- endfor -%}
};
aidge_concat<float, {{ nb_in }}> (
{{name|upper}}_AXIS,
{{ name|upper }}_INPUTS,
{{ name|upper }}_SIZES,
{{ out_name[0] }});
{% endfilter %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment