3 This directory includes some tools related with BCQ.
9 `preserve_bcq_info` is for preserving constant nodes which include BCQ information.
10 When `.pb` file is converted to `.tflite` file by TFlite converter, constant nodes whose values are exactly same are removed and then linked to only one representative node.
11 This makes us impossible to know what constant node should be linked to a node which we want to apply BCQ.
12 One of the solutions is making all the same constant nodes different by inserting unique values and ignore the newly generated unique values when BCQ fusing is applied.
13 `preserve_bcq_info` will generate and insert unique dummy values to the constant nodes whose values are same not to be removed by Tensorflow Lite converter.
14 As a result, BCQ information will be preserved.
20 --input_path /path/to/original_model.pb \
21 --output_path /path/to/preserved_model.pb
26 If we add unique dummy value at the end of each constant nodes, all the constant nodes would be different. Following is an example.
29 [Original Constant Nodes]
30 const(value=[1, 2, 3], name='const1')
31 const(value=[1, 2, 3], name='const2')
32 const(value=[1, 2, 3], name='const3')
34 [After BCQ information preserved]
35 const(value=[1, 2, 3, -1], name='const1')
36 const(value=[1, 2, 3, -2], name='const2')
37 const(value=[1, 2, 3, -3], name='const3')
40 For dummy values, negative values are used instead of positive values.
41 This is because positive valus may be confused with original constant node values.
42 For your information, unique dummy value starts from -1 and moves to -2, -3, ..., -N, where N is the number of preserved constant nodes.
46 - Newly generated dummy values should be ignored when the constant nodes are used.
48 ## generate_bcq_output_arrays
52 To apply BCQ, BCQ information nodes should be designated as model output so that they are alive even after TFLite conversion is finished.
53 However, there are so many nodes to designate and sometimes we cannot copy and paste all of them because the string size is too big.
54 `generate_bcq_output_arrays` is for generating output_arrays, which include BCQ information nodes.
59 generate_bcq_output_arrays \
60 --input_path /path/to/original_model.pb \
61 --output_path /path/to/output_arrays.txt
67 [Original BCQ information nodes]
68 const(value=[1, 2, 3, -1], name='const1')
69 const(value=[1, 2, 3, -2], name='const2')
70 const(value=[1, 2, 3, -3], name='const3')
72 [Generated output_arrays]
78 - Generated output_arrays will be start with comma.