JeVois  1.22
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 class DynamicLoader;
29
30 namespace dnn
31 {
32 //! Wrapper around a DNN neural network running on Amlogic A311D NPU accelerator (Verisilicon)
33 /*! \ingroup dnn */
35 public jevois::Parameter<network::intensors, network::outtensors, network::dataroot,
36 network::model, network::library, network::dequant, network::verifygraph,
37 network::ovxver>
38 {
39 public:
40 //! Inherited constructor ok
41 using jevois::dnn::Network::Network;
42
43 //! Destructor
44 virtual ~NetworkNPU();
45
46 //! Freeze/unfreeze parameters that users should not change while running
47 void freeze(bool doit) override;
48
49 //! Get shapes of all input tensors
50 virtual std::vector<vsi_nn_tensor_attr_t> inputShapes() override;
51
52 //! Get shapes of all output tensors
53 virtual std::vector<vsi_nn_tensor_attr_t> outputShapes() override;
54
55 protected:
56 //! Load from disk
57 void load() override;
58
59 //! Process input blobs and obtain output blobs
60 std::vector<cv::Mat> doprocess(std::vector<cv::Mat> const & blobs,
61 std::vector<std::string> & info) override;
62
63 private:
64 void create_tensors(std::vector<vsi_nn_tensor_attr_t> & attrs, vsi_nn_node_t * node, bool isin);
65
66 vsi_nn_context_t itsCtx = 0;
67 vsi_nn_graph_t * itsGraph = nullptr;
68 std::shared_ptr<jevois::DynamicLoader> itsLibLoader;
69 };
70
71 } // namespace dnn
72} // namespace jevois
73
74#endif // JEVOIS_PLATFORM_PRO
Wrapper around a DNN neural network running on Amlogic A311D NPU accelerator (Verisilicon)
Definition NetworkNPU.H:38
virtual std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
Definition NetworkNPU.C:99
virtual std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
Definition NetworkNPU.C:135
virtual ~NetworkNPU()
Destructor.
Definition NetworkNPU.C:180
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:338
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
Definition NetworkNPU.C:190
void load() override
Load from disk.
Definition NetworkNPU.C:202
Abstract class to represent a neural network.
Definition Network.H:212
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2