Bool input tensor
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 258
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
Hi all,
I’m using larq to benchmark the real performance of my bnn. It’s very convenient, but I’m having some trouble. I use a toy model as an example.
X_in = Input(shape=(1, 1, 1024,), batch_size=1024)
X_in_quantized = lq.quantizers.SteSign()(X_in)
X = lq.layers.QuantConv2D(64, kernel_size=(1, 1),
kernel_quantizer="ste_sign",
kernel_constraint="weight_clip",
)(X_in_quantized)
out = tf.keras.layers.Reshape((-1,))(X)
toy_model = Model(inputs=X_in, outputs=out)
This model only has a QuantDense Layer. Then, I benchmark it on Raspberry Pi 4B (64bit-OS).
STARTING!
Log parameter values verbosely: [0]
Min num runs: [50]
Num threads: [1]
Graph: [toy1.tflite]
#threads used for CPU inference: [1]
Loaded model toy1.tflite
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
The input model file size (MB): 0.010452
Initialized session in 3.889ms.
Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
count=121 first=4357 curr=2186 min=2143 max=4357 avg=2277.17 std=302
Running benchmark for at least 50 iterations and at least 1 seconds but terminate if exceeding 150 seconds.
count=253 first=2206 curr=2179 min=2141 max=2248 avg=2168.41 std=18
Inference timings in us: Init: 3889, First inference: 4357, Warmup (avg): 2277.17, Inference (avg): 2168.41
Note: as the benchmark tool itself affects memory footprint, the following is only APPROXIMATE to the actual memory footprint of the model at runtime. Take the information at your discretion.
Memory footprint delta from the start of the tool (MB): init=0.0507812 overall=10.5469
I think 10.5469 MB is the used memory size, containing the floating-point input tensor. I am wondering how to use a quantized (binarized) tensor as input for saving memory. It’s actually a bool input tensor. How can I test the memory consumption with the bool input tensor?
# Some like
X_in = Input(shape=(1, 1, 1024,), batch_size=1024, dtype=bool)
# instead of
X_in = Input(shape=(1, 1, 1024,), batch_size=1024)
X_in_quantized = lq.quantizers.SteSign()(X_in)
If you can give me some hints, I would be very grateful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the toy Keras model with the float input and reviewing the generated toy1.tflite benchmark on Raspberry Pi 4B. Investigate whether a boolean or binarized input tensor is supported, and compare memory consumption using the same benchmark; done means the supported input form and its measured memory usage are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, raspberry-pi, tensorflow
- Domain
- embedded-iot, machine-learning, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100