Skip to content

Bool input tensor #771

@bywmm

Description

@bywmm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions