Tengine icon indicating copy to clipboard operation
Tengine copied to clipboard

DataLayout check fails when running NHWC model on acl_opencl

Open wangg opened this issue 6 years ago • 7 comments

A model with NHWC input cannot be run on acl_opencl because the data layout assertion fails. When running on CPU only, everything works.

Tengine Version: master branch of this repo

Model: sequeezenet_tf.tmfile from Tengine model zoo squeezenet_tf.zip

Error message: Tengine/tools/plugin/driver/acl_opencl/acl_graph.hpp:577: bool Tengine::CLGraph::AddConvolutionLayer(Tengine::Node*): Assertion 'TENGINE_LAYOUT_NCHW == TengineDataLayOut' failed

wangg avatar Apr 16 '20 03:04 wangg

I can`t reproduce this issue . I had used the squeenet model of tensorflow,and the model of tengine,All of them can run on RK3399 with GPU . Can you tell me your hardware and tengine version?

LEMON-LM avatar Apr 22 '20 08:04 LEMON-LM

I am also using RK3399, Tengine is compiled from the master branch of this repo.

I have attached the inference code and model I used. Could you please check if it runs as expected on your side? Please also kindly let me know if I made some newbie mistake in the code, which led to the problem.

code_and_model.zip

wangg avatar Apr 22 '20 09:04 wangg

You need use set_graph_device after prerun_graph. Because in prerun_graph we will set the layout for the model and all op. You can see infershape fuction in each op,it will be call in prerun.

LEMON-LM avatar Apr 22 '20 10:04 LEMON-LM

If I use set_graph_device after prerun_graph, the model can run. However, it is running on CPU instead of GPU even though "ACL Graph Initialized" is printed out. (2 big cores of RK3399 are fully loaded and the GPU load stays at 0) The code I used is attached. Could you let me know if I did something wrong?

set_device_after.zip

wangg avatar Apr 22 '20 11:04 wangg

@wangg Have you tried to set the environment “ACL_NHWC=1” there is an environment variable “ACL_NHWC” used in file tools/plugin/driver/acl_opencl/acl_graph_device.cpp line 443

danielzhao91 avatar Apr 29 '20 14:04 danielzhao91

@ddzhao91 Yes, I have tried it. If I call set_graph_device after prerun_graph, it is running on CPU no matter what the value of ACL_NHWC is. If I call set_graph_device before prerun_graph, the layout check fails. I also checked with one OAID FAE through the QQ group, and NHWC models are actually not tested on GPU, so no guarantee for anything. Did you successfully run NHWC model on GPU without modifying Tengine? If so, I will really appreciate it if you can tell me how you made it.

Here is one screen capture showing it's running on CPU after I set ACL_NHWC=1. image

wangg avatar Apr 30 '20 17:04 wangg

We have updated the implement of ACL #540, please try is again, thanks.

BUG1989 avatar Feb 04 '21 04:02 BUG1989