mace icon indicating copy to clipboard operation
mace copied to clipboard

for quantized model fullyconnected op, input shape does not match weight shape

Open jiexuim opened this issue 5 years ago • 1 comments


System information

  • Linux Ubuntu 16.04 docker
  • NDK version r16b:
  • GCC version: 5.4.0:
  • MACE version: v0.10.0-103-g8c33468
  • Python version: 2.7:
  • Bazel version: 0.13.1:

Model deploy file (*.yml)

library_name: caffeToMace
target_abis: [host]
model_graph_format: file
model_data_format: file
models:
  caffeToMace:
    platform: caffe
    model_file_path: /data/caffeToMace.proto
    weight_file_path: /data/caffeToMace.caffemodel
    model_sha256_checksum: 593fd43f38236693911d10c3dea6e09b3596cf8b9bef0b05d150a66eca531e7b
    weight_sha256_checksum: fee73fdaaed9a2ed38f402fdbfdab022d10d9b4c4c53d2de06ab975494005b35
    subgraphs:
      - input_tensors:
          - images
        input_shapes:
          - 1,14,14,1
        output_tensors:
          - FC3
        output_shapes:
          - 1,1,1,1
    runtime: cpu
    limit_opencl_kernel_time: 0
    nnlib_graph_mode: 0
    obfuscate: 0
    winograd: 0
    quantize: 1
    quantize_range_file: /data/caffeToMace.txt
......

Describe the problem

My model works fine if not enable quantize. If I use post-quantize, the model is converted without error. But when I run the model in host. I get error: F mace/ops/fully_connected.cc:142] Check failed: input->dim(1) == weight->dim(1) && input->dim(2) == weight->dim(2) && input->dim(3) == weight->dim(3) The shape of Input: [1, 2, 2, 28]The shape of Weight: [20, 28, 2, 2] don't match.

To Reproduce

Steps to reproduce the problem:

1. cd /path/to/mace
2. python tools/converter.py convert --config_file=/data/caffeToMaceHost.yml
3. python tools/converter.py run  --config_file=/data/caffeToMaceHost.yml --round=10

Error information / logs

Please include the full log and/or traceback here.

* Build //mace/tools/validation:mace_run_static with ABI host
v0.10.0-103-g8c33468-20190222
INFO: Analysed target //mace/tools/validation:mace_run_static (23 packages loaded).
INFO: Found 1 target...
Target //mace/tools/validation:mace_run_static up-to-date:
  bazel-bin/mace/tools/validation/mace_run_static
INFO: Elapsed time: 225.163s, Critical Path: 14.82s
INFO: 269 processes, local.
INFO: Build completed successfully, 274 total actions
Build done!

*************************************************
          Run model caffeToMace on host
*************************************************

Generate input file:  builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_input_images
Generate input file done.
* Run 'caffeToMace' with round=10, restart_round=1, tuning=False, out_of_range_check=False, omp_num_threads=(-1,), cpu_affinity_policy=(1,), gpu_perf_hint=(3,), gpu_priority_hint=(3,)
I mace/tools/validation/mace_run.cc:465] model name: caffeToMace
I mace/tools/validation/mace_run.cc:466] mace version: v0.10.0-103-g8c33468-20190222
I mace/tools/validation/mace_run.cc:467] input node: images
I mace/tools/validation/mace_run.cc:468] input shape: 1,14,14,1
I mace/tools/validation/mace_run.cc:469] output node: FC3
I mace/tools/validation/mace_run.cc:470] output shape: 1,1,1,1
I mace/tools/validation/mace_run.cc:471] input_file: builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_input
I mace/tools/validation/mace_run.cc:472] output_file: builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_out
I mace/tools/validation/mace_run.cc:473] model_data_file: builds/caffeToMace/model/caffeToMace.data
I mace/tools/validation/mace_run.cc:474] model_file: builds/caffeToMace/model/caffeToMace.pb
I mace/tools/validation/mace_run.cc:475] device: CPU
I mace/tools/validation/mace_run.cc:476] round: 10
I mace/tools/validation/mace_run.cc:477] restart_round: 1
I mace/tools/validation/mace_run.cc:478] gpu_perf_hint: 3
I mace/tools/validation/mace_run.cc:479] gpu_priority_hint: 3
I mace/tools/validation/mace_run.cc:480] omp_num_threads: -1
I mace/tools/validation/mace_run.cc:481] cpu_affinity_policy: 1
I mace/tools/validation/mace_run.cc:504] restart round 0
I mace/libmace/mace.cc:769] Create MaceEngine from model graph proto and weights data
I mace/libmace/mace.cc:408] Creating MaceEngine, MACE version: v0.10.0-103-g8c33468-20190222
E mace/core/runtime/cpu/cpu_runtime.cc:83] failed to open /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
I mace/libmace/mace.cc:440] Initializing MaceEngine
E mace/core/runtime/cpu/cpu_runtime.cc:83] failed to open /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
I mace/tools/validation/mace_run.cc:296] Create Mace Engine latency: 0.739 ms
I mace/tools/validation/mace_run.cc:303] Total init latency: 12.004 ms
I mace/tools/validation/mace_run.cc:340] Warm up run
F mace/ops/fully_connected.cc:142] Check failed: input->dim(1) == weight->dim(1) && input->dim(2) == weight->dim(2) && input->dim(3) == weight->dim(3) The shape of Input: [1, 2, 2, 28]The shape of Weight: [20, 28, 2, 2] don't match.

Running finished!

Additional context

And the log for non-quantized model

* Build //mace/tools/validation:mace_run_static with ABI host
INFO: Analysed target //mace/tools/validation:mace_run_static (21 packages loaded).
INFO: Found 1 target...
Target //mace/tools/validation:mace_run_static up-to-date:
  bazel-bin/mace/tools/validation/mace_run_static
INFO: Elapsed time: 80.800s, Critical Path: 6.28s
INFO: 87 processes, local.
INFO: Build completed successfully, 89 total actions
Build done!

*************************************************
          Run model caffeToMace on host
*************************************************

Generate input file:  builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_input_images
Generate input file done.
* Run 'caffeToMace' with round=10, restart_round=1, tuning=False, out_of_range_check=False, omp_num_threads=(-1,), cpu_affinity_policy=(1,), gpu_perf_hint=(3,), gpu_priority_hint=(3,)
I mace/tools/validation/mace_run.cc:465] model name: caffeToMace
I mace/tools/validation/mace_run.cc:466] mace version: v0.10.0-103-g8c33468-20190222
I mace/tools/validation/mace_run.cc:467] input node: images
I mace/tools/validation/mace_run.cc:468] input shape: 1,14,14,1
I mace/tools/validation/mace_run.cc:469] output node: FC3
I mace/tools/validation/mace_run.cc:470] output shape: 1,1,1,1
I mace/tools/validation/mace_run.cc:471] input_file: builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_input
I mace/tools/validation/mace_run.cc:472] output_file: builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_out
I mace/tools/validation/mace_run.cc:473] model_data_file: builds/caffeToMace/model/caffeToMace.data
I mace/tools/validation/mace_run.cc:474] model_file: builds/caffeToMace/model/caffeToMace.pb
I mace/tools/validation/mace_run.cc:475] device: CPU
I mace/tools/validation/mace_run.cc:476] round: 10
I mace/tools/validation/mace_run.cc:477] restart_round: 1
I mace/tools/validation/mace_run.cc:478] gpu_perf_hint: 3
I mace/tools/validation/mace_run.cc:479] gpu_priority_hint: 3
I mace/tools/validation/mace_run.cc:480] omp_num_threads: -1
I mace/tools/validation/mace_run.cc:481] cpu_affinity_policy: 1
I mace/libmace/mace.cc:769] Create MaceEngine from model graph proto and weights data
I mace/libmace/mace.cc:408] Creating MaceEngine, MACE version: v0.10.0-103-g8c33468-20190222
E mace/core/runtime/cpu/cpu_runtime.cc:83] failed to open /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
I mace/libmace/mace.cc:440] Initializing MaceEngine
E mace/core/runtime/cpu/cpu_runtime.cc:83] failed to open /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
I mace/tools/validation/mace_run.cc:296] Create Mace Engine latency: 0.66 ms
I mace/tools/validation/mace_run.cc:303] Total init latency: 3.65 ms
I mace/tools/validation/mace_run.cc:340] Warm up run
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/tools/validation/mace_run.cc:373] 1st warm up run latency: 1.032 ms
I mace/tools/validation/mace_run.cc:380] Run model
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 28, 2, 2] The shape of Weight: [20, 28, 2, 2]
I mace/ops/fully_connected.cc:78] The shape of Input: [1, 20, 1, 1] The shape of Weight: [1, 20, 1, 1]
I mace/tools/validation/mace_run.cc:425] Average latency: 0.3482 ms
I mace/tools/validation/mace_run.cc:448] Write output file builds/caffeToMace/_tmp/caffeToMace/1489029415d63f20513e7b9eb49c4bcb/host/model_out_FC3 with size 1 done.
I mace/libmace/mace.cc:541] Destroying MaceEngine
========================================
            init      warmup     run_avg
========================================
time       3.650       1.032       0.348

Running finished!

jiexuim avatar Feb 22 '19 21:02 jiexuim

Can you share your model and quantize_range_file so that we can test it?

lee-bin avatar Feb 25 '19 07:02 lee-bin