Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
aidge_core
Merge requests
!265
Add unit test export
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add unit test export
AddUnitTestExport
into
dev
Overview
0
Commits
2
Pipelines
3
Changes
4
Merged
Cyril Moineau
requested to merge
AddUnitTestExport
into
dev
5 months ago
Overview
0
Commits
2
Pipelines
3
Changes
4
Expand
Fix
#204 (closed)
1
0
Merge request reports
Compare
dev
version 1
72557bf3
5 months ago
dev (base)
and
latest version
latest version
b5472812
2 commits,
5 months ago
version 1
72557bf3
2 commits,
5 months ago
4 files
+
145
−
15
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
aidge_core/export_utils/templates/main_compare.jinja
0 → 100644
+
59
−
0
Options
{% set printf_formats = {
"double": "%lf",
"float": "%f",
"int8_t": "%hhd",
"int16_t": "%hd",
"int32_t": "%d",
"int64_t": "%lld",
"uint8_t": "%hhu",
"uint16_t": "%hu",
"uint32_t": "%u",
"uint64_t": "%llu"
} %}
#include <cstdio> // printf
#include <cmath> // std::abs
#include "forward.hpp" // Exported forward
// Inputs
{% for name in inputs_name %}
#include "{{ name }}.h"
{% endfor %}
// Outputs
{% for name in outputs_name %}
#include "{{ name }}_expected.h"
{% endfor %}
int main()
{
// Initialize the output arrays
{%- for o in range(outputs_name | length) %}
{{ outputs_dtype[o] }}* {{ outputs_name[o] }} = nullptr;
{% endfor %}
const float abs_err = 0.001f;
const float rel_err = 0.0001f;
// Call the forward function
{{ func_name }}({{ inputs_name|join(", ") }}{% if inputs_name %}, {% endif %}&{{ outputs_name|join(", &") }});
int nb_identical;
int nb_out;
// Print the results of each output
{%- for o in range(outputs_name | length) %}
nb_identical = 0;
nb_out = 0;
printf("{{ outputs_name[o] }}:\n");
for (int o = 0; o < {{ outputs_size[o] }}; ++o) {
printf("Expected {{ printf_formats[outputs_dtype[o]] }} <-> Predicted {{ printf_formats[outputs_dtype[o]] }}\n", {{ outputs_name[o] }}_expected[o], {{ outputs_name[o] }}[o]);
if (std::abs({{ outputs_name[o] }}_expected[o] - {{ outputs_name[o] }}[o]) <= abs_err + rel_err * std::abs({{ outputs_name[o] }}_expected[o]))
nb_identical++;
nb_out++;
}
printf("\nNumber of equal outputs: %d / %d\n", nb_identical, nb_out);
{% endfor %}
return 0;
}
Loading