JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
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
26namespace 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
Wrapper around a DNN neural network running on Amlogic A311D NPU accelerator (Verisilicon)
Definition NetworkNPU.H:36
virtual std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
Definition NetworkNPU.C:78
virtual std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
Definition NetworkNPU.C:84
virtual ~NetworkNPU()
Destructor.
Definition NetworkNPU.C:118
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:206
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
Definition NetworkNPU.C:126
void load() override
Load from disk.
Definition NetworkNPU.C:137
Abstract class to represent a neural network.
Definition Network.H:162
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2