shoco icon indicating copy to clipboard operation
shoco copied to clipboard

Model generator generates non-C compliant code

Open arkhipenko opened this issue 4 years ago • 0 comments

Hi guys,

Thank you for the library. I am using it to compress the underlying data in the Dictionary library on ESP32 and ESP8266 microcontrollers (you can reference those platforms as "works on" from now on).

While playing with specific training data set I noticed that generate_compressor_model.py produced this kind of strings:

static const int8_t successor_ids_by_chr_id_and_chr_id[32][32] = {
  {-1, 13, 6, 9, -1, 7, -1, 15, 1, 11, 3, 4, 2, 10, -1, -1, -1, 0, 12, 5, 8, -1, 14, -1, -1, -1, -1, -1, None, None, None, None},
  {0, 6, 2, 5, -1, 1, 3, -1, 8, 7, 15, 4, 12, -1, -1, 9, 11, -1, 10, -1, 14, -1, -1, -1, -1, -1, -1, 13, None, None, None, None},
  {15, -1, -1, 3, 12, 0, 1, -1, 9, 2, 5, 7, 6, -1, 14, -1, 10, -1, 11, 4, -1, -1, 13, 8, -1, -1, -1, -1, None, None, None, None},

Note all the "None"'s in the code. Obviously C compiler didn't know what to do with this. I replaced the None's with 0's manually and it compiled and worked (compressed) the strings, so I assume those are meant to be zeros but I am not sure. The training dataset is attached (it's a test data set for random key-value creation. Also attached is the resulting model generated with None's.

Hope you can fix this. dictionary-test.txt dictioanry-test.h.txt

arkhipenko avatar Jun 02 '20 20:06 arkhipenko