Skip to content
Snippets Groups Projects
Commit 28d60307 authored by Mickael GUIBERT's avatar Mickael GUIBERT
Browse files

[Refactor] Simplify aidge_cmp function to one function for float or interger

parent 0c8a131d
No related branches found
No related tags found
No related merge requests found
Pipeline #69546 failed
......@@ -144,8 +144,7 @@ inline void saveOutputs(
#if AIDGE_CMP
template<int NB_OUTPUTS, int OUT_WIDTH, int OUT_HEIGHT, typename AidgeOutput_T, typename DevOutput_T>
typename std::enable_if<std::is_floating_point<DevOutput_T>::value>::type
aidge_cmp(std::string layer_name, AidgeOutput_T* aidge_output, DevOutput_T* dev_output) {
void aidge_cmp(std::string layer_name, AidgeOutput_T* aidge_output, DevOutput_T* dev_output) {
printf("[AIDGE COMPARE] - %s\n", layer_name.c_str());
......@@ -155,31 +154,13 @@ aidge_cmp(std::string layer_name, AidgeOutput_T* aidge_output, DevOutput_T* dev_
const int aidge_ofst = out * OUT_HEIGHT * OUT_WIDTH + h * OUT_WIDTH + w;
const int dev_ofst = h * OUT_WIDTH * NB_OUTPUTS + w * NB_OUTPUTS + out;
if (aidge_output[aidge_ofst] != dev_output[dev_ofst]) {
printf("[ERROR] - (float) First error detected at %dx%dx%d (out x h x w) : aidge_out = %f vs dev_out = %f\n",
out, h, w, aidge_output[aidge_ofst], dev_output[dev_ofst]);
printf("Abort program.\n");
exit(1);
}
}
}
}
printf("[SUCCESS]\n\n");
}
template<int NB_OUTPUTS, int OUT_WIDTH, int OUT_HEIGHT, typename AidgeOutput_T, typename DevOutput_T>
typename std::enable_if<std::is_integral<DevOutput_T>::value>::type
aidge_cmp(std::string layer_name, AidgeOutput_T* aidge_output, DevOutput_T* dev_output) {
printf("[AIDGE COMPARE] - %s\n", layer_name.c_str());
for (auto out = 0; out < NB_OUTPUTS; ++out) {
for (auto h = 0; h < OUT_HEIGHT; ++h) {
for (auto w = 0; w < OUT_WIDTH; ++w) {
const int aidge_ofst = out * OUT_HEIGHT * OUT_WIDTH + h * OUT_WIDTH + w;
const int dev_ofst = h * OUT_WIDTH * NB_OUTPUTS + w * NB_OUTPUTS + out;
if (aidge_output[aidge_ofst] != dev_output[dev_ofst]) {
printf("[ERROR] - (float) First error detected at %dx%dx%d (out x h x w) : aidge_out = %d vs dev_out = %d\n",
out, h, w, aidge_output[aidge_ofst], dev_output[dev_ofst]);
if (std::is_floating_point<DevOutput_T>::value) {
printf("[ERROR] - (float) First error detected at %dx%dx%d (out x h x w) : aidge_out = %f vs dev_out = %f\n",
out, h, w, static_cast<double>(aidge_output[aidge_ofst]), static_cast<double>(dev_output[dev_ofst]));
} else {
printf("[ERROR] - (float) First error detected at %dx%dx%d (out x h x w) : aidge_out = %d vs dev_out = %d\n",
out, h, w, static_cast<int>(aidge_output[aidge_ofst]), static_cast<int>(dev_output[dev_ofst]));
}
printf("Abort program.\n");
exit(1);
}
......
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