Forums - Run nnlib in Hexagon SDK

11 posts / 0 new
Last post
Run nnlib in Hexagon SDK
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Wed, 2018-08-08 03:44

I've downloaded the nnlib into my Linux workstation and following the README.HOW_TO_BUILD to build it.

When I try the 3rd step make tree VERBOSE=1 V=android_Release I got the error:

Quote:

Hexagon_SDK/3.3.3/incs/stddef -I/home/jshen/Qualcomm/Hexagon_SDK/3.3.3/libs/common/rpcmem/android_Release/ship -Iandroid_Release  -oandroid_Release/graphmain.o test/graphmain.c
test/graphmain.c:436:22: fatal error: pmu_adsp.h: No such file or directory
 #include "pmu_adsp.h"
                      ^
compilation terminated.
/home/jshen/Qualcomm/Hexagon_SDK/3.3.3/build/make.d/rules.min:602: recipe for target 'android_Release/graphmain.o' failed
make[1]: *** [android_Release/graphmain.o] Error 1
make[1]: Leaving directory '/home/jshen/dev/nnlib'
glue/android.mak:7: recipe for target 'tree' failed
make: *** [tree] Error 2
 

Is there any fix on this? 

I also tried integrated nnlib in my one project in SDK3.3.3.   Is it correct to include hexagon_nn.h and use api listed in intro.txt ?

 

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Mon, 2018-08-13 07:07

By looking at the update log of graphmain.c in the example, we believe that the missing head file is just the replacement of the deleted text which defines the array of cstring const char *event_names[] with conditions.

Thus we generate a pmu_adsp.h file from the above understanding and save it in the test derectory.  

 

It compiles now!

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Mon, 2018-08-13 07:08

By looking at the update log of graphmain.c in the example, we believe that the missing head file is just the replacement of the deleted text which defines the array of cstring const char *event_names[] with conditions.

Thus we generate a pmu_adsp.h file from the above understanding and save it in the test derectory.  

 

It compiles now!

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Thu, 2018-08-23 07:15

By doing the following 3 things not included in the HOW_TO_BUILD guide, I finally executed the example graph_app:

1.  Generated the missing headfile.

2. Run the scripts to generate keyboard_299.dat file from the jpg file.

3. Use --elementsize 1 instead of --elementsize 4 in the guilde.

*  Or, elementsize 4 can be reseved, but the python script need to be updated:  comment line 52 and uncomment line 53:

51 for (r,g,b) in data:
52       #outf.write(struct.pack('BBB',r,g,b))
53        outf.write(struct.pack('fff',float(r)/128-1,float(g)/128-1,float(b)/128-1))
54
55 outf.close()
 
 
The result of the execution is  attached at the bottom.  Obviously, the hexagon_nn_execute
 didn't run correclty.
 
There is no further document about this, anyone has some advice?
 
 
 
*******     The execution result ************************
 
return value from dspCV_initQ6() : 0 
const node 1000b success
const node 1000c success
const node 1000d success
const node 1000e success
const node 1000f success
const node 10010 success
const node 10011 success
const node 10012 success
const node 10250 success
Init graph done.
Prepare d870b7a0 success!
nn @ d870b7a0: id=0x0 debug_level=0
node @ d870bef0: id=0x1000b type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d870c370: id=0x1000c type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d870c4a0: id=0x1000d type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87aeb20: id=0x10010 type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87aeca0: id=0x10011 type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87aeda0: id=0x10012 type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87aee40: id=0x10250 type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87af020: id=0xfffffffe type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87af0a0: id=0xfffffffd type=0x3(Const) n_inputs=0 n_outputs=1 padding=0(NA)
node @ d87aeee0: id=0x1024a type=0x0(INPUT) n_inputs=0 n_outputs=1 padding=0(NA)
node @ 10606750: id=0x1024e type=0x9a(AutoQuantize) n_inputs=1 n_outputs=3 padding=0(NA)
node @ 106060c0: id=0x10254 type=0xae(InputSupernode_8x8p8to8_outd32) n_inputs=12 n_outputs=3 padding=2(VALID)
node @ d87af540: id=0xfffffffc type=0x90(Convert_from_d32) n_inputs=1 n_outputs=1 padding=0(NA)
node @ 10606140: id=0x10442 type=0x29(Dequantize) n_inputs=3 n_outputs=1 padding=0(NA)
node @ 10606270: id=0x1044d type=0x1(OUTPUT) n_inputs=1 n_outputs=0 padding=0(NA)
15 nodes total.
Using </data/keyboard_299.dat>
filesize=1072812 elementsize=4 height=299 width=299 depth=3
Run!
execute got err: -1
output size=4096
Rank,Softmax,index,string
0,0.000000,1023,OVERFLOW!
1,0.000000,1,kit fox
2,0.000000,2,English setter
3,0.000000,3,Siberian husky
4,0.000000,4,Australian terrier
run failed: -1
 
 
 
 

 

  • Up0
  • Down0
v-jayakumar
Join Date: 4 Feb 18
Posts: 13
Posted: Fri, 2018-08-24 07:28

Hi Jialis

    1) Use command
      lsb_release -a
 
     No LSB modules are available.
     Distributor ID:    Ubuntu
     Description:    Ubuntu 14.04.5 LTS
     Release:    14.04
     Codename:    trusty

    2) Hexagon DSP SDK 3.3.3

    3) nnlib source code

    4) python --version
       Python 2.7.6


Assuming that you have machine with above configuration or above. In case if you have all in place then move to  "nnlib/test" folder use the following command

         Step1: python imagedump.py  keyboard_299x299.jpg r2.dat   
    
Image size: 299x299   
//   this will be shown in command line after you issue the above command

          Step 2: Copy  r2.dat file in to folder /data/r2.dat

Where /data folder in device ( you can use adb shell command to do this work
After you copy  r2.dat then use following .


          Step 3: Copy graph_app file in to  /data/graph_app

Assuming  that above 3 steps went well, then try the following.

          Step 4:

      adb shell /data/graph_app --height 299 --width 299 --depth 3 --elementsize 4 --perfdump 1 /data/r2.dat


Hint:  file size of r2.dat is 268203
         299*299*3 =  268203
        Thus, -depth 3 appears to be correct choice
      
Above should help you.
In case not send error msg
////////////////////////////////////////

jk/BLR

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Fri, 2018-08-24 07:56

Hi JK

 

Thanks for your advice, but I didn't find any different between yours and my procedures, except the filename of .dat file.

 

In my previouse post (step 3), I tried two different datatypes:

convert the jpg into uint8 raw data, and in the command line set --elementsize 1

or 

conver tht ejpg into float raw data, and in the command line set --elementsize 4.

 

Neither of them worked.

 

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Fri, 2018-08-24 07:58

Hi JK

 

Thanks for your advice, but I didn't find any different between yours and my procedures, except the filename of .dat file.

 

In my previouse post (step 3), I tried two different datatypes:

convert the jpg into uint8 raw data, and in the command line set --elementsize 1

or 

conver tht ejpg into float raw data, and in the command line set --elementsize 4.

 

Neither of them worked.

 
  • Up0
  • Down0
v-jayakumar
Join Date: 4 Feb 18
Posts: 13
Posted: Fri, 2018-08-24 09:26

Hi

Jialis did you try

python imagedump.py keyboard_299x299.jpg r2.dat

what is size of r2.dat

Hint:

file size of r2.dat is 268203

299*299*3 = 268203

Thus, -depth 3 appears to be correct choice

if you are getting 268203 as size of r2.dat then things will go well

Regards

jk

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Mon, 2018-08-27 07:58

Yes.

 

As described in my setp2, I did exactly the same and get a dat file which size is 268203

I also update the python script (see step 3.), to generate a float data file, which size is 1072812 = 299*299*3*4(sizeof float)

 

But neither works.

  • Up0
  • Down0
jialis
Join Date: 6 Jul 18
Posts: 12
Posted: Mon, 2018-08-27 07:59

Yes.

 

As described in my setp2, I did exactly the same and get a dat file which size is 268203

I also update the python script (see step 3.), to generate a float data file, which size is 1072812 = 299*299*3*4(sizeof float)

 

But neither works.

  • Up0
  • Down0
amirhossein.ashouri
Join Date: 22 May 17
Posts: 6
Posted: Thu, 2018-09-13 12:18

@v-jayakumar the issue with the testapp in nnlib, except those conversion process needed as you mentoined, is that it is not a complete developed neural net, thus the results are random, the code in the `test/graphinit_small.c`:

 

'73   #define APPEND_CONST_NODE(ID,...) if (hexagon_nn_append_const_node(nn_id,ID,__VA_ARGS__) != 0) \

 74   printf("node %d returned nonzero\n",ID); else printf("const node %d success\n",ID)
 75   #define APPEND_NODE(ID,...) if (hexagon_nn_append_node(nn_id,ID,__VA_ARGS__) != 0) \
 76    printf("node %d returned nonzero\n",ID); else printf("node %d success\n",ID)
 77    void init_graph(int nn_id) {
 78   APPEND_NODE(0x1024a,OP_INPUT,NN_PAD_ANY,inputs_for_1024a,1,outputs_for_1024a,1);
 79   APPEND_NODE(0x10300,OP_Nop,NN_PAD_ANY,inputs_for_10300,1,outputs_for_10300,1);
 80   APPEND_NODE(0x1044d,OP_OUTPUT,NN_PAD_ANY,inputs_for_1044d,1,NULL,0);'
 
You see the defined network is completely NULL, so the ImageNet classification we get by running the code is useless. Can we have a minimum working network that we start from? 
 
Thank you!
-- Amir
 
  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.