diff --git a/aidge_export_cpp/static/utils.hpp b/aidge_export_cpp/static/utils.hpp index 8316e5ee172cdc64aaa2b158fa73db912d3d83f1..e3776a37adaae1f87675f61f07e24af0cb30a0b2 100644 --- a/aidge_export_cpp/static/utils.hpp +++ b/aidge_export_cpp/static/utils.hpp @@ -144,7 +144,8 @@ inline void saveOutputs( #if AIDGE_CMP template<int NB_OUTPUTS, int OUT_WIDTH, int OUT_HEIGHT, typename AidgeOutput_T, typename DevOutput_T> -void aidge_cmp(std::string layer_name, AidgeOutput_T* aidge_output, DevOutput_T* dev_output) { +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) { printf("[AIDGE COMPARE] - %s\n", layer_name.c_str()); @@ -154,7 +155,30 @@ void aidge_cmp(std::string layer_name, AidgeOutput_T* aidge_output, DevOutput_T* 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] - First error detected at %dx%dx%d (out x h x w) : aidge_out = %d vs dev_out = %d\n", + 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]); printf("Abort program.\n"); exit(1);