GiorgosXou/NeuralNetworks

Severe macro-coditioning compilation errors due to `enum` implementation of binary constants

GiorgosXou opened this issue Β· 1 comments

Replacing all constant B01... with 0b...-literals should solve the issue for "Arduino Mbed OS Nano Boards" for now. the issue is tracked here: arduino/ArduinoCore-mbed#894 (discord crossref link)

Eg. Compiling the MNIST-example results on every optimization to get enabled:

In file included from /tmp/.arduinoIDE-unsaved2024511-3095-t7tr5u.8y9xh/FeedForward_Individual_MNIST_PROGMEM/FeedForward_Individual_MNIST_PROGMEM.ino:4:0:
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:979:0: warning: ignoring #pragma region NeuralNetwork [-Wunknown-pragmas]
 #pragma region NeuralNetwork.cpp
 
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1647:0: warning: ignoring #pragma endregion NeuralNetwork [-Wunknown-pragmas]
 #pragma endregion NeuralNetwork.cpp
 
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1655:0: warning: ignoring #pragma region Layer [-Wunknown-pragmas]
 #pragma region Layer.cpp
 
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2617:0: warning: ignoring #pragma endregion Layer [-Wunknown-pragmas]
 #pragma endregion Layer.cpp
 
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:699:35: note: #pragma message: 
❀ π–€π–“π–ˆπ–”π–“π–‰π–Žπ–™π–Žπ–”π–“π–†π–‘ π•·π–”π–›π–Š ❀ "VERSION: 2.1.7"
 
βŒ₯β–Œ" [1] B10000000 [⚠] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] Backpropagation is not Allowed with (USE_PROGMEM)." 
βŒ₯β–Œ" [1] B01000000 [⚠] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] Backpropagation is not Allowed with (REDUCE_RAM_DELETE_OUTPUTS)." 
βŒ₯β–Œ" [1] B00010000 [⚠] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] Using (REDUCE_RAM_WEIGHTS_LVL2)." 
βŒ₯β–Œ" [1] B00001000 [β“˜] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] Always Enabled not switchable yet." 
βŒ₯β–Œ" [1] B00000100 [⚠] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] Be careful with multiple NN objects." 
βŒ₯β–Œ" [1] B00000010 [⚠] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] MSE is disabled (DISABLE_MSE) (DEFAULT_LOSS)" 
βŒ₯β–Œ" [1] B00000001 [⚠] [π—₯𝗲𝗺𝗢𝗻𝗱𝗲𝗿] Not all MCUs support 64bit\8byte double (USE_64_BIT_DOUBLE)." 

 π—¨π—¦π—œπ—‘π—š [Ζ’x] |β€£ Sigmoid |βŒ₯|


 #pragma message( STR(INFORMATION) )
                                   ^
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In constructor 'NeuralNetwork::NeuralNetwork(const unsigned int*, const double*, const double*, const unsigned int&, byte*)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1096:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < numberOflayers; i++)
                         ~~^~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'double* NeuralNetwork::FeedForward_Individual(const double&)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1247:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Individual_Input == layers[0]._numberOfInputs)
             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1283:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 1; i < numberOflayers; i++)
                             ~~^~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'double* NeuralNetwork::FeedForward(const double*)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1348:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < numberOflayers; i++)
                         ~~^~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::print()':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1629:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < numberOflayers; i++)
                         ~~^~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::Layer::FdF_Individual_PROGMEM(const double&, const int&)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1900:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < _numberOfOutputs; i++)
                     ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1924:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (j == _numberOfInputs -1){
             ~~^~~~~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1925:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (i = 0; i < _numberOfOutputs; i++)
                         ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::Layer::FeedForward_Individual(const double&, const int&)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1961:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < _numberOfOutputs; i++)
                     ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1985:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (j == _numberOfInputs -1){
             ~~^~~~~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1986:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (i = 0; i < _numberOfOutputs; i++){
                         ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::Layer::FdF_PROGMEM(const double*)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2147:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < _numberOfOutputs; i++)
                         ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2157:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < _numberOfInputs; j++)
                             ~~^~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::Layer::FeedForward(const double*)':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2192:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < _numberOfOutputs; i++)
                         ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2216:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int j = 0; j < _numberOfInputs; j++)
                                 ~~^~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::Layer::print()':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2506:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < _numberOfOutputs; i++)
                         ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2514:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < _numberOfInputs; j++)
                             ~~^~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h: In member function 'void NeuralNetwork::Layer::print_PROGMEM()':
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2549:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < _numberOfOutputs; i++)
                         ~~^~~~~~~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:2557:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < _numberOfInputs; j++)
                             ~~^~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024511-3095-t7tr5u.8y9xh/FeedForward_Individual_MNIST_PROGMEM/FeedForward_Individual_MNIST_PROGMEM.ino: In function 'void setup()':
/tmp/.arduinoIDE-unsaved2024511-3095-t7tr5u.8y9xh/FeedForward_Individual_MNIST_PROGMEM/FeedForward_Individual_MNIST_PROGMEM.ino:102:61: error: no matching function for call to 'NeuralNetwork::NeuralNetwork(const unsigned int [4], const float [5560], const float [3], unsigned int)'
   NeuralNetwork NN(layers, weights, biases, NumberOf(layers)); // Creating a NeuralNetwork with pretrained Weights and Biases
                                                             ^
In file included from /tmp/.arduinoIDE-unsaved2024511-3095-t7tr5u.8y9xh/FeedForward_Individual_MNIST_PROGMEM/FeedForward_Individual_MNIST_PROGMEM.ino:4:0:
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1070:9: note: candidate: NeuralNetwork::NeuralNetwork(const unsigned int*, const double*, const double*, const unsigned int&, byte*)
         NeuralNetwork::NeuralNetwork(const unsigned int *layer_, IS_CONST DFLOAT *default_Weights, IS_CONST DFLOAT *default_Bias, const unsigned int &NumberOflayers, byte *_ActFunctionPerLayer)
         ^~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:1070:9: note:   no known conversion for argument 2 from 'const float [5560]' to 'const double*'
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:980:5: note: candidate: NeuralNetwork::NeuralNetwork()
     NeuralNetwork::NeuralNetwork() {
     ^~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:980:5: note:   candidate expects 0 arguments, 4 provided
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:702:7: note: candidate: constexpr NeuralNetwork::NeuralNetwork(const NeuralNetwork&)
 class NeuralNetwork
       ^~~~~~~~~~~~~
/home/xou/Arduino/libraries/NeuralNetwork/src/NeuralNetwork.h:702:7: note:   candidate expects 1 argument, 4 provided
/tmp/.arduinoIDE-unsaved2024511-3095-t7tr5u.8y9xh/FeedForward_Individual_MNIST_PROGMEM/FeedForward_Individual_MNIST_PROGMEM.ino:110:85: error: cannot convert 'double*' to 'float*' in assignment
       output = NN.FeedForward_Individual(pgm_read_byte(&NumbersInPixels[i][j])/255.0);
                                                                                     ^

exit status 1

Compilation error: no matching function for call to 'NeuralNetwork::NeuralNetwork(const unsigned int [4], const float [5560], const float [3], unsigned int)'

I could test if detecting predifined B00000000 exists at all and then if not, fallback somehow to literal-ones by appending a 0 to the _X_OPTIMIZE value (so it becomes 0B...) and then add conditions for 0B..s too or something....