cpetig / tflite_micro_compiler

generate tflite micro code which bypasses the interpreter (directly calls into kernels)
Apache License 2.0
77 stars 26 forks source link

Reduce code size by replacing linear code with const arrays and for #13

Closed cpetig closed 4 years ago

cpetig commented 4 years ago

The size of the generated code can be further reduced by writing a const array containing node and tensor values and then using a for loop in init and invoke. I believe the more nice variant is to use another structure to collect the values, then fill them one node/tensor per line.

cpetig commented 4 years ago

Current proposal: enum used_operators_e { // implementation for #7 OP_CONV_2D, OP_MAXPOOL, OP_LAST };

struct NodeInfo_t { struct TfLiteIntArray inputs, outputs; void *opdata; used_operators_e optype; }; static const NodeInfo_t prefix_nodes[5] = { { &prefix_inputs0, &prefix_outputs0, &prefix_opdata0, OP_CONV_2D }, { &prefix_inputs1, &prefix_outputs1, &prefix_opdata1, OP_MAXPOOL }, ... };