Forums - How to get multiple output from any Neural Network in SNPE in C++?

5 posts / 0 new
Last post
How to get multiple output from any Neural Network in SNPE in C++?
simon_lin
Join Date: 23 Mar 22
Posts: 1
Posted: Thu, 2022-03-24 09:01
Hi, guys,
 
I've been trying to get multiple outputs from dlc file, but alwary got "Aborted (core dumped)" error after setting setOutputLayers to any names.
 
I used inception_v3.dlc as an example which is generated from official sample (https://developer.qualcomm.com/sites/default/files/docs/snpe/tutorial_in...).
Here are my code snippet refer to another post (https://developer.qualcomm.com/forum/qdn-forums/software/qualcomm-neural...).
 
SDK : snpe-1.53.2.2811
OS : Ubuntu 20.02
 
=====================================================================
zdl::DlSystem::RuntimeList runtime_list;
zdl::DlSystem::Runtime_t runtime_cpu = zdl::DlSystem::Runtime_t::CPU;
 
std::unique_ptr<zdl::DlContainer::IDlContainer> container =
zdl::DlContainer::IDlContainer::open(zdl::DlSystem::String(dlc));
 
zdl::SNPE::SNPEBuilder snpeBuilder(container.get());
runtime_list.add(runtime_cpu);
 
// zdl::DlSystem::StringList outputList = {};
zdl::DlSystem::StringList outputList(0);
outputList.append("InceptionV3/Predictions/Reshape_1:0"); // output layer name
 
// If there are multiple output layers, pass that instead of empty array.
std::unique_ptr<zdl::SNPE::SNPE> model_handler = snpeBuilder.setOutputLayers(outputList).setRuntimeProcessorOrder(runtime_list).build();
std::unique_ptr<zdl::DlSystem::ITensor> input_tensor = zdl::SNPE::SNPEFactory::getTensorFactory().createTensor(model_handler->getInputDimensions());
zdl::DlSystem::ITensor *tensor_ptr = input_tensor.get();
=====================================================================
 
 
 
 
I got output layer name by typing "snpe-dlc-info -i ./inception_v3.dlc".
And I got the following results from the last couple of outputs, I used InceptionV3/Predictions/Reshape_1:0 as my outupt name.
 
=====================================================================
...
| 215 | InceptionV3/Logits/SpatialSqueeze:0                                 | reshape       | InceptionV3/Logits/Conv2d_1c_1x1/BiasAdd:0                                          | InceptionV3/Predictions/Reshape:0                                                   | 1x1001       | A D G C  |                                     |
| 216 | InceptionV3/Predictions/Softmax                                     | softmax       | InceptionV3/Predictions/Reshape:0                                                   | InceptionV3/Predictions/Reshape_1:0                                                 | 1x1001       | A D G C  |                                     |
=====================================================================
 
It seems the only way to make it work is to set snpeBuilder.setOutputLayers({}), but this surely won't work in multiple output situation.
 
I've wonderd what I've done wrong since I've tried approaches from some posts on the forum
 
Thanks!
 
 
  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Thu, 2022-03-31 01:15

Dear customer,

SNPE supported to multiple output if you specific with the following guide at your input.txt.

#outptut_node1<empty space> output_node2

input.raw

 

BR.
Wei

  • Up0
  • Down0
wuyefeima
Join Date: 21 Feb 22
Posts: 5
Posted: Tue, 2022-08-09 01:18

Hi simon_lin,

I met the save problem .

Have you found the right way to get multi output names from dlc?

Thank you.

  • Up0
  • Down0
wuhongxin
Join Date: 8 Nov 23
Posts: 1
Posted: Wed, 2023-11-08 17:30

Hi, simon_lin
Maybe you can use " InceptionV3/Predictions/Softmax" instead of "InceptionV3/Predictions/Reshape_1:0". Don't use out_node to construct outputList

  • Up0
  • Down0
liwangqiang
Join Date: 22 Jun 20
Posts: 1
Posted: Wed, 2023-11-08 18:07

hi,all, I met the same issue and found a way.

when you use userbuffer, you need to call setOutputLayers, you should pass the layer names instead of node name. let' see

=====================================================================
...
| 215 | InceptionV3/Logits/SpatialSqueeze:0 | reshape | InceptionV3/Logits/Conv2d_1c_1x1/BiasAdd:0 | InceptionV3/Predictions/Reshape:0 | 1x1001 | A D G C | |
| 216 | InceptionV3/Predictions/Softmax | softmax | InceptionV3/Predictions/Reshape:0 | InceptionV3/Predictions/Reshape_1:0 | 1x1001 | A D G C | |
=====================================================================

the last two layers name are InceptionV3/Logits/SpatialSqueeze:0 and InceptionV3/Predictions/Softmax, which are behind of layer numbers.

  • 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.