JeVois  1.18
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
NetworkNPU.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2021 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #pragma once
19 
20 #ifdef JEVOIS_PLATFORM_PRO
21 
22 #include <jevois/DNN/Network.H>
23 #include <vsi_nn_pub.h>
24 #include <vsi_nn_graph.h>
25 
26 namespace jevois
27 {
28  namespace dnn
29  {
30  //! Wrapper around a DNN neural network running on Amlogic A311D NPU accelerator (Verisilicon)
31  /*! \ingroup dnn */
33  public jevois::Parameter<network::intensors, network::outtensors, network::dataroot,
34  network::model, network::dequant, network::verifygraph,
35  network::ovxver>
36  {
37  public:
38  //! Inherited constructor ok
39  using jevois::dnn::Network::Network;
40 
41  //! Destructor
42  virtual ~NetworkNPU();
43 
44  //! Freeze/unfreeze parameters that users should not change while running
45  void freeze(bool doit) override;
46 
47  //! Get shapes of all input tensors
48  virtual std::vector<vsi_nn_tensor_attr_t> inputShapes() override;
49 
50  //! Get shapes of all output tensors
51  virtual std::vector<vsi_nn_tensor_attr_t> outputShapes() override;
52 
53  protected:
54  //! Load from disk
55  void load() override;
56 
57  //! Process input blobs and obtain output blobs
58  std::vector<cv::Mat> doprocess(std::vector<cv::Mat> const & blobs,
59  std::vector<std::string> & info) override;
60 
61  private:
62  void create_tensors(std::vector<vsi_nn_tensor_attr_t> & attrs, vsi_nn_node_t * node, bool isin);
63 
64  vsi_nn_context_t itsCtx = 0;
65  vsi_nn_graph_t * itsGraph = nullptr;
66  };
67 
68  } // namespace dnn
69 } // namespace jevois
70 
71 #endif // JEVOIS_PLATFORM_PRO
jevois::dnn::NetworkNPU
Wrapper around a DNN neural network running on Amlogic A311D NPU accelerator (Verisilicon)
Definition: NetworkNPU.H:32
jevois::dnn::NetworkNPU::~NetworkNPU
virtual ~NetworkNPU()
Destructor.
Definition: NetworkNPU.C:117
Network.H
jevois::dnn::NetworkNPU::inputShapes
virtual std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
Definition: NetworkNPU.C:77
jevois
Definition: Concepts.dox:1
jevois::dnn::NetworkNPU::freeze
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
Definition: NetworkNPU.C:125
jevois::dnn::NetworkNPU::outputShapes
virtual std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
Definition: NetworkNPU.C:83
jevois::dnn::NetworkNPU::doprocess
std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info) override
Process input blobs and obtain output blobs.
Definition: NetworkNPU.C:199
jevois::dnn::NetworkNPU::load
void load() override
Load from disk.
Definition: NetworkNPU.C:135
jevois::dnn::Network
Abstract class to represent a neural network.
Definition: Network.H:153