NVIDIA NvNeural SDK  2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
LayerDescHostContainer.h
Go to the documentation of this file.
1 /*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: MIT
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23 
25 #ifndef NVNEURAL_LAYERDESCHOSTCONTAINER_H
26 #define NVNEURAL_LAYERDESCHOSTCONTAINER_H
27 
28 #include <nvneural/CoreTypes.h>
29 #include <nvneural/CoreHelpers.h>
30 #include <vector>
31 
32 namespace nvneural {
39  {
40  private:
41  bool m_validLayerDesc;
42  LayerDesc m_layerDesc;
43  std::vector<ParamDesc> m_params;
44  std::vector<LayerInputDesc> m_inputs;
45 
46  void LayerDescWarning(const std::string& warningText) const;
47  bool SanityCheckLayerDesc() const;
48  bool ValidateAndLoadLayerDesc(const LayerDesc* pInputLayerDesc);
49 
50  bool ValidateAndLoadLayerParamDesc(const ParamDesc* pInputParamDesc);
51 
52  bool SanityCheckLayerInputDesc(const LayerInputDesc& layerInputDesc) const;
53  bool ValidateAndLoadLayerInputDesc(const LayerInputDesc* pInputLayerInputDesc);
54 
55  public:
56  LayerDescHostContainer() = delete;
57 
61  explicit LayerDescHostContainer(const LayerDesc* pInputLayerDesc);
62 
63  ~LayerDescHostContainer() = default;
64 
66  bool isValid() const
67  {
68  return m_validLayerDesc;
69  }
70 
72  const LayerDesc& get() const
73  {
74  return m_layerDesc;
75  }
76 
78  void linkVectors()
79  {
80  m_layerDesc.pInputs = m_inputs.data();
81  m_layerDesc.pParameters = m_params.data();
82  }
83  };
84 }
85 
86 #endif // NVNEURAL_LAYERDESCHOSTCONTAINER_H
Common helper classes and template function implementations.
Fundamental NvNeural data types are declared here.
"Host-native" container for LayerDesc structures from other modules.
Definition: LayerDescHostContainer.h:39
bool isValid() const
Returns true if the imported descriptor was valid.
Definition: LayerDescHostContainer.h:66
void linkVectors()
Once all sub-descriptors have been converted, call this to reconnect the parameter/input lists.
Definition: LayerDescHostContainer.h:78
const LayerDesc & get() const
Returns a reference to the converted/upgraded descriptor.
Definition: LayerDescHostContainer.h:72
This structure describes an ILayer for tools and network builders.
Definition: CoreTypes.h:1554
const ParamDesc * pParameters
This is the pointer to the array of ParamDesc structs.
Definition: CoreTypes.h:1626
const LayerInputDesc * pInputs
This is a pointer to the array of LayerInputDesc structs which define the inputs to this layer.
Definition: CoreTypes.h:1611
Describes a single input terminal for a layer. LayerDesc objects contain arrays of this structure.
Definition: CoreTypes.h:1527
ParamDesc describes a parameter for the plugin, giving it a name, default value, type,...
Definition: CoreTypes.h:1449