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.
MIT License
2.83k stars 775 forks source link

How to use GPU to run the program? #152

Closed ppplinday closed 7 years ago

ppplinday commented 7 years ago

I coded vgg16 by arm compute library and NEON which means I use CPU to run the program. If I want to use GPU to run the program, how can I do? Do I need to code vgg16 again with CL?

ppplinday commented 7 years ago

And I want to know why I cannot build with CLConvoutionlayer::configure?

examples/main.cpp:483:94: error: no matching function for call to 'arm_compute::CLConvolutionLayer::configure(arm_compute::Tensor, arm_compute::Tensor, arm_compute::Tensor, arm_compute::Tensor, arm_compute::PadStrideInfo)' conv_1_1.configure(&input, &weights_1_1, &biases_1_1, &out_1_1, PadStrideInfo(1, 1, 1, 1)); ^ examples/main.cpp:483:94: note: candidate is: In file included from ./arm_compute/runtime/CL/CLFunctions.h:43:0, from examples/main.cpp:2: ./arm_compute/runtime/CL/functions/CLConvolutionLayer.h:70:10: note: void arm_compute::CLConvolutionLayer::configure(const arm_compute::ICLTensor, const arm_compute::ICLTensor, const arm_compute::ICLTensor, arm_compute::ICLTensor, const arm_compute::PadStrideInfo&) void configure(const ICLTensor input, const ICLTensor weights, const ICLTensor biases, ICLTensor output, const PadStrideInfo &conv_info); ^ ./arm_compute/runtime/CL/functions/CLConvolutionLayer.h:70:10: note: no known conversion for argument 1 from 'arm_compute::Tensor' to 'const arm_compute::ICLTensor' examples/main.cpp:486:110: error: no matching function for call to 'arm_compute::CLActivationLayer::configure(arm_compute::Tensor, arm_compute::Tensor, arm_compute::ActivationLayerInfo)' Nact_1_1.configure(&out_1_1, &act_1_1, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); ^ examples/main.cpp:486:110: note: candidate is: In file included from ./arm_compute/runtime/CL/CLFunctions.h:30:0, from examples/main.cpp:2: ./arm_compute/runtime/CL/functions/CLActivationLayer.h:48:10: note: void arm_compute::CLActivationLayer::configure(const arm_compute::ICLTensor, arm_compute::ICLTensor, arm_compute::ActivationLayerInfo) void configure(const ICLTensor input, ICLTensor output, ActivationLayerInfo act_info); ^ ./arm_compute/runtime/CL/functions/CLActivationLayer.h:48:10: note: no known conversion for argument 1 from 'arm_compute::Tensor' to 'const arm_compute::ICLTensor' examples/main.cpp:489:96: error: no matching function for call to 'arm_compute::CLConvolutionLayer::configure(arm_compute::Tensor, arm_compute::Tensor, arm_compute::Tensor, arm_compute::Tensor, arm_compute::PadStrideInfo)' conv_1_2.configure(&act_1_1, &weights_1_2, &biases_1_2, &out_1_2, PadStrideInfo(1, 1, 1, 1));

I think everything is fine and I built the library with: scons Werror=1 -j8 debug=0 asserts=1 neon=0 opencl=1 embed_kernels=1 os=android arch=arm64-v8a and run this: aarch64-linux-android-g++ examples/main.cpp test_helpers/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L/home/zhoupeilin/download/t4/build/arm_compute -L. -o main -static-libstdc++ -pie -lOpenCL

Any helps or hints are appreciate!!!

AnthonyBarbier commented 7 years ago

Yes, you need to use the CL functions and types instead of the NE ones. However, the number and order of parameters between the two APIs match, therefore you should be able to simply template the types.

In your case, you're getting errors because you're using CPU types (Tensor) instead of CL types (CLTensor)