NVIDIA NvNeural SDK  2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
CodeGenTypes.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 
26 #ifndef NVNEURAL_CODEGENTYPES_H
27 #define NVNEURAL_CODEGENTYPES_H
28 
29 #include <nvneural/CoreTypes.h>
30 
31 namespace nvneural {
32 
35 {
36 public:
41  using ResourceId = std::uint32_t;
42 
44  static const IRefObject::TypeId typeID = 0xf8aa3818beae88d2ul;
45 
53  virtual NeuralResult getResource(ResourceId resourceId, const void** ppBufferOut, std::size_t* pBufferSizeOut) const noexcept = 0;
54 };
55 
62 {
63 public:
66 
74  virtual NeuralResult addResource(ResourceId* pResourceIdOut, const void* pBuffer, std::uint32_t bufferBytes) noexcept = 0;
75 
77  virtual NeuralResult finalize() noexcept = 0;
78 
80  virtual std::size_t resourceIdCount() const noexcept = 0;
81 
85  virtual ResourceId resourceIdByIndex(std::size_t resourceIndex) const noexcept = 0;
86 
90  virtual std::size_t resourceBufferSizeByIndex(std::size_t resourceIndex) const noexcept = 0;
91 
95  virtual const void* resourceBufferByIndex(std::size_t resourceIndex) const noexcept = 0;
96 };
97 
130 {
131 public:
133  static const IRefObject::TypeId typeID = 0x1025680db910cfebul;
134 
137 
141  virtual bool deploymentMode() const noexcept = 0;
142 
146  virtual const IStringList* targetGpuArchitectures() const noexcept = 0;
147 
150  virtual const char* networkVariableName() const noexcept = 0;
151 
154  virtual const char* layerVariableName() const noexcept = 0;
155 
158  virtual const char* resourceDictionaryVariableName() const noexcept = 0;
159 
164  virtual const char* inputArgumentExpression() const noexcept = 0;
165 
167 
170 
174  virtual NeuralResult setObjectClass(const char* pObjectClass) noexcept = 0;
175 
178  virtual NeuralResult addInclude(const char* pInclude) noexcept = 0;
179 
181  virtual NeuralResult addSourceFragment(const char* pCppCode) noexcept = 0;
182 
184  virtual NeuralResult addHeaderFragment(const char* pCppCode) noexcept = 0;
185 
188  virtual NeuralResult setInitializationFragment(const char* pCppCode) noexcept = 0;
189 
195  virtual NeuralResult addResource(IResourceDictionary::ResourceId* pResourceIdOut, const void* pBuffer, std::uint32_t bufferBytes) noexcept = 0;
196 
205  virtual NeuralResult setInputFragment(const char* pCppCode) noexcept = 0;
206 
208 };
209 
215 {
216 public:
218  static const IRefObject::TypeId typeID = 0xbf8778dfca10c9d5ul;
219 
225 
233  virtual NeuralResult networkGenerationComplete() noexcept = 0;
234 };
235 
236 } // namespace nvneural
237 
238 #endif // NVNEURAL_CODEGENTYPES_H
Fundamental NvNeural data types are declared here.
NeuralResult
NeuralResult is a generic success/failure result type similar to COM HRESULT.
Definition: CoreTypes.h:275
Tool-supplied interface for C++ code generation.
Definition: CodeGenTypes.h:130
virtual bool deploymentMode() const noexcept=0
Returns true if the generator is in "deployment mode." When generating for deployment mode,...
Optional layer interface for C++ code generation.
Definition: CodeGenTypes.h:215
virtual NeuralResult networkGenerationComplete() noexcept=0
Indicates the entire network has been generated.
virtual NeuralResult generateLayerCpp(ICppCodeGenerationLayerHost *pHost) noexcept=0
Generates C++ code to configure the layer.
Base class for all objects, similar to COM's IUnknown.
Definition: CoreTypes.h:343
static const TypeId typeID
Interface TypeId for InterfaceOf purposes.
Definition: CoreTypes.h:352
std::uint64_t TypeId
Every interface must define a unique TypeId. This should be randomized.
Definition: CoreTypes.h:349
Key-value store for creating IResourceDictionary objects.
Definition: CodeGenTypes.h:62
virtual const void * resourceBufferByIndex(std::size_t resourceIndex) const noexcept=0
Returns a pointer to the Nth finalized resource buffer in the object.
virtual std::size_t resourceIdCount() const noexcept=0
Returns the number of finalized resources in the object.
IResourceDictionary::ResourceId ResourceId
Unique identifier for a resource.
Definition: CodeGenTypes.h:65
virtual NeuralResult addResource(ResourceId *pResourceIdOut, const void *pBuffer, std::uint32_t bufferBytes) noexcept=0
Adds a resource to the dictionary, avoiding duplicates.
virtual NeuralResult finalize() noexcept=0
Finalizes the resource collection, allowing for compression and serialization to take place.
virtual std::size_t resourceBufferSizeByIndex(std::size_t resourceIndex) const noexcept=0
Returns the byte count associated with the Nth finalized resource buffer in the object.
virtual ResourceId resourceIdByIndex(std::size_t resourceIndex) const noexcept=0
Returns the Nth resource ID in the object.
Key-value store for binary data such as precompiled kernels.
Definition: CodeGenTypes.h:35
std::uint32_t ResourceId
Unique identifier for a resource.
Definition: CodeGenTypes.h:41
virtual NeuralResult getResource(ResourceId resourceId, const void **ppBufferOut, std::size_t *pBufferSizeOut) const noexcept=0
Retrieves a buffer that was stored in this dictionary.
static const IRefObject::TypeId typeID
Interface TypeId for InterfaceOf purposes.
Definition: CodeGenTypes.h:44
IStringList represents an immutable collection of strings.
Definition: CoreTypes.h:1079