Skip to content
Snippets Groups Projects
Commit 9444564e authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Update _def_io template and reflect changes in operator templates.

parent 00f0b586
No related branches found
No related tags found
3 merge requests!27v0.2.0,!22v0.4.0,!15Export refactor
Showing
with 41 additions and 33 deletions
{# NOTE: Suppose input is first #}
#define {{ name|upper }}_NB_CHANNELS {{ in_chan[0] }}
#define {{ name|upper }}_CHANNELS_HEIGHT {{ in_height[0] }}
#define {{ name|upper }}_CHANNELS_WIDTH {{ in_width[0] }}
#define {{ name|upper }}_NB_OUTPUTS {{ out_chan[0] }}
#define {{ name|upper }}_OUTPUTS_HEIGHT {{ out_height[0] }}
#define {{ name|upper }}_OUTPUTS_WIDTH {{ out_width[0] }}
{% for inidx in range(nb_in) -%}
#define {{ in_name[inidx]|upper }}_NB_CHANNELS {{ in_chan[inidx] }}
#define {{ in_name[inidx]|upper }}_IN_HEIGHT {{ in_height[inidx] }}
#define {{ in_name[inidx]|upper }}_IN_WIDTH {{ in_width[inidx] }}
{% endfor %}
{% for outidx in range(nb_out) -%}
#define {{ out_name[outidx]|upper }}_NB_OUTPUTS {{ out_chan[outidx] }}
#define {{ out_name[outidx]|upper }}_OUT_HEIGHT {{ out_height[outidx] }}
#define {{ out_name[outidx]|upper }}_OUT_WIDTH {{ out_width[outidx] }}
{% endfor %}
......@@ -6,6 +6,7 @@
{%- set nb_data = in_chan[0] * in_height[0] * in_width[0] %}
#define {{ name|upper }}_NB_DATA {{ nb_data }}
#define {{ name|upper }}_ACTIVATION {{ activation }}
{% include "./_def_io.jinja" %}
{% include "./_meminfo.jinja" %}
static const {{ rescaling }} {{ name|upper }}_RESCALING = {};
......
......@@ -2,6 +2,7 @@
#ifndef {{ name|upper }}_LAYER_H
#define {{ name|upper }}_LAYER_H
{% include "./_def_io.jinja" %}
{% include "./_meminfo.jinja" %}
{# For layer configuration -#}
#define {{ name|upper }}_NB_ELTS {{ in_dims[0]|join('*') }}
......
......@@ -3,6 +3,7 @@
#define {{ name|upper }}_LAYER_H
{# For layer configuration -#}
{% include "./_def_io.jinja" %}
{% include "./_meminfo.jinja" %}
#define {{ name|upper }}_NB_DATA {{ nb_data }}
#define {{ name|upper }}_ALPHA {{ alpha }}
......
/* COMMENTED FOR THE MOMENT
/*
#ifdef SAVE_OUTPUTS
{% for outidx in range(nb_out) -%}
FILE* {{out_name[outidx]|upper}}_STREAM = fopen("outputs/{{out_name[outidx]}}.txt", "w");
saveOutputs(
saveOutputs<{{out_cdtype[outidx]}}>(
{{out_name[outidx]|upper}}_NB_OUTPUTS,
{{out_name[outidx]|upper}}_OUTPUTS_HEIGHT,
{{out_name[outidx]|upper}}_OUTPUTS_WIDTH,
{{out_name[outidx]|upper}}_OUT_HEIGHT,
{{out_name[outidx]|upper}}_OUT_WIDTH,
{{out_name[outidx]|upper}}_CONT_OFFSET,
{{out_name[outidx]|upper}}_CONT_SIZE,
{{out_name[outidx]|upper}}_WRAP_OFFSET,
{{out_name[outidx]|upper}}_WRAP_SIZE,
{{out_name[outidx]|upper}}_STRIDE,
{{out_name[outidx]}},
{{out_name[outidx]|upper}}_STREAM, Network::Format::CHW);
{{out_name[outidx]|upper}}_STREAM,
Format::{{out_format[outidx]}});
fclose({{out_name[outidx]|upper}}_STREAM);
{% endfor %}
#endif
......
batchnorm_forward<{{name|upper}}_NB_OUTPUTS,
{{name|upper}}_OUTPUTS_HEIGHT,
{{name|upper}}_OUTPUTS_WIDTH,
batchnorm_forward<{{ out_name[0]|upper }}_NB_OUTPUTS,
{{ out_name[0]|upper }}_OUT_HEIGHT,
{{ out_name[0]|upper }}_OUT_WIDTH,
{{name|upper}}_ACTIVATION>
({{input_name}}, {{output_name}}, {{biases_name}}, {{variances_name}}, {{means_name}}, {{scales_name}}, {{name|upper}}_EPSILON);
{% include "./_save_outputs.jinja" %}
{% if not is_output %}
{{out_cdtype[0]}}* {{out_name[0]}} = ({{out_cdtype[0]}}*) mem + {{out_name[0]|upper}}_OFFSET;
{% endif %}
convolution_forward<{{name|upper}}_NB_CHANNELS,
{{name|upper}}_CHANNELS_HEIGHT,
{{name|upper}}_CHANNELS_WIDTH,
{{name|upper}}_NB_OUTPUTS,
{{name|upper}}_OUTPUTS_HEIGHT,
{{name|upper}}_OUTPUTS_WIDTH,
convolution_forward<{{ in_name[0]|upper }}_NB_CHANNELS,
{{ in_name[0]|upper }}_IN_HEIGHT,
{{ in_name[0]|upper }}_IN_WIDTH,
{{ out_name[0]|upper }}_NB_OUTPUTS,
{{ out_name[0]|upper }}_OUT_HEIGHT,
{{ out_name[0]|upper }}_OUT_WIDTH,
{{name|upper}}_PADDING_Y,
{{name|upper}}_PADDING_X,
{{name|upper}}_STRIDE_Y,
......
{% if not is_output %}
{{out_cdtype[0]}}* {{out_name[0]}} = ({{out_cdtype[0]}}*) mem + {{out_name[0]|upper}}_OFFSET;
{% endif %}
fullyconnected_forward<{{name|upper}}_NB_CHANNELS,
{{name|upper}}_CHANNELS_HEIGHT,
{{name|upper}}_CHANNELS_WIDTH,
{{name|upper}}_NB_OUTPUTS,
{{name|upper}}_OUTPUTS_HEIGHT,
{{name|upper}}_OUTPUTS_WIDTH,
fullyconnected_forward<{{ in_name[0]|upper }}_NB_CHANNELS,
{{ in_name[0]|upper }}_IN_HEIGHT,
{{ in_name[0]|upper }}_IN_WIDTH,
{{ out_name[0]|upper }}_NB_OUTPUTS,
{{ out_name[0]|upper }}_OUT_HEIGHT,
{{ out_name[0]|upper }}_OUT_WIDTH,
{{name|upper}}_ACTIVATION>
({{in_name[0]}}, {{out_name[0]}}, {{in_name[1]}}, {{in_name[2]}}, {{name|upper}}_RESCALING);
{% include "./_save_outputs.jinja" %}
{% if not is_output %}
{{out_cdtype[0]}}* {{out_name[0]}} = ({{out_cdtype[0]}}*) mem + {{out_name[0]|upper}}_OFFSET;
{% endif %}
pooling_forward<{{name|upper}}_NB_CHANNELS,
{{name|upper}}_CHANNELS_HEIGHT,
{{name|upper}}_CHANNELS_WIDTH,
{{name|upper}}_NB_OUTPUTS,
{{name|upper}}_OUTPUTS_HEIGHT,
{{name|upper}}_OUTPUTS_WIDTH,
pooling_forward<{{ in_name[0]|upper }}_NB_CHANNELS,
{{ in_name[0]|upper }}_IN_HEIGHT,
{{ in_name[0]|upper }}_IN_WIDTH,
{{ out_name[0]|upper }}_NB_OUTPUTS,
{{ out_name[0]|upper }}_OUT_HEIGHT,
{{ out_name[0]|upper }}_OUT_WIDTH,
{{name|upper}}_PADDING_Y,
{{name|upper}}_PADDING_X,
{{name|upper}}_STRIDE_Y,
......
......@@ -25,7 +25,7 @@ void model_forward({% for inp in inputs %}const {{inp[0]}}* {{inp[1]}}, {% endfo
#ifdef SAVE_OUTPUTS
// Creation of the outputs directory
struct stat st = {0};
struct stat st {};
if (stat("outputs", &st) == -1) {
mkdir("outputs", 0700);
}
......
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