ARM-software / ComputeLibrary

The Compute Library is a set of computer vision and machine learning functions optimised for both Arm CPUs and GPUs using SIMD technologies.
2.87k stars 782 forks source link

Problem with graph_alexnet.cpp #1094

Closed sdavejones closed 3 months ago

sdavejones commented 9 months ago

I tried running this example in version 24.01: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/running-alexnet-on-raspberry-pi-with-compute-library

./graph_alexnet --data=$PATH_ASSETS --image=$PATH_ASSETS/go_kart.ppm --labels=$PATH_ASSETS/labels.txt

./graph_alexnet

Threads : 1 Target : Neon Data type : F32 Data layout : NHWC Tuner enabled? : false Cache enabled? : false Tuner mode : Normal Tuner file : MLGO file : Fast math enabled? : false Data path : /root/assets_alexnet Image file : /root/assets_alexnet/go_kart.ppm Labels file : /root/assets_alexnet/labels.txt

---------- Top 5 predictions ----------

0.3899 - [id = 496], n03026506 Christmas stocking 0.0862 - [id = 658], n03775071 mitten 0.0749 - [id = 806], n04254777 sock 0.0225 - [id = 474], n02963159 cardigan 0.0221 - [id = 893], n04548362 wallet, billfold, notecase, pocketbook

Test passed

Looks like the output isn't quite correct...

morgolock commented 9 months ago

Hi @sdavejones

Could you please let us know what's in the folder Data path : /root/assets_alexnet ?

If you don't specify the folder to the model's correct weights the example will initialize the weights with random values and the results won't be correct.

We don't distribute the weights files npy files along with the graph examples so this is not going to work out of the box.

Hope this helps

sdavejones commented 9 months ago

Hi @morgolock

As mentioned, I followed that example. There's a paragraph in the content of that web page that says: "Please download the required files to your host machine (Debian based) or to your Raspberry Pi"

I downloaded the file from here: https://developer.arm.com/-/media/43359E999DEF433BAF63523C529D21AD.ashx?revision=c1a232fa-f328-451f-9bd6-250b83511e01

Thanks.

sdavejones commented 9 months ago

Tested same example in v23.11:

./graph_alexnet --data=$PATH_ASSETS --image=$PATH_ASSETS/go_kart.ppm --labels=$PATH_ASSETS/labels.txt

./graph_alexnet

Threads : 1 Target : Neon Data type : F32 Data layout : NHWC Tuner enabled? : false Cache enabled? : false Tuner mode : Normal Tuner file : MLGO file : Fast math enabled? : false Data path : /root/assets_alexnet Image file : /root/assets_alexnet/go_kart.ppm Labels file : /root/assets_alexnet/labels.txt

---------- Top 5 predictions ----------

0.9736 - [id = 573], n03444034 go-kart 0.0118 - [id = 518], n03127747 crash helmet 0.0108 - [id = 751], n04037443 racer, race car, racing car 0.0022 - [id = 817], n04285008 sports car, sport car 0.0006 - [id = 670], n03791053 motor scooter, scooter

Test passed

You can see that the result matches the example....

noahbreit commented 7 months ago

Hi @morgolock I have the same issue as @sdavejones. Note I am implementing this on a RPi-4B and using pre-built RPi-4 ACL binary, and I have a hunch that this is the source of the problem as it differs from the tutorial mentioned here https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/running-alexnet-on-raspberry-pi-with-compute-library. It was originally for "Raspberry Pi 2 or 3 with Ubuntu Mate 16.04.02"

Thoughts? Note I have attempted ACL-neon and ACL-neon-cl, both give the same result with go-kart.ppm input giving the christmas-stocking label output

also: $ strings arm_compute_version-23.11-bin-linux-arm64-v8a-neon/lib/arm64-v8a-neon-asserts/libarm_compute.so | grep arm_compute_version arm_compute_version=v23.11 Build options: {'arch': 'arm64-v8a', 'neon': '1', 'opencl': '0', 'os': 'linux', 'build_dir': 'arm-v8a-neon-asserts', 'asserts': '1', 'Werror': '1', 'embed_kernels': '1'}

noahbreit commented 7 months ago

Update! I changed to ACL ver22.11 and it worked. I got the expected output for all of the provided ppm images from the tutorial.

for ref: $ strings lib/arm64-v8a-neon/libarm_compute.so | grep arm_compute_version arm_compute_version=v22.11 Build options: {'embed_kernels': '1', 'os': 'linux', 'opencl': '0', 'neon': '1', 'build_dir': 'arm64-v8a-neon', 'asserts': '0', 'arch': 'arm64-v8a', 'Werror': '1'}

morgolock commented 4 months ago

Thanks for reporting this, we have reproduced the problem and we are looking into it.

morgolock commented 3 months ago

Hi @noahbreit

This patch fixes the problem and will be included in v24.08.

Hope this helps.