NVIDIA DeepStream SDK API Reference

9.1 Release
sources/libs/nvdsinferserver/infer_ibackend.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
28 #ifndef __NVDSINFERSERVER_IBACKEND_H__
29 #define __NVDSINFERSERVER_IBACKEND_H__
30 
31 #include "infer_common.h"
32 #include "infer_datatypes.h"
33 
34 namespace nvdsinferserver {
35 
52  int bindingIndex = 0;
56  bool isInput = 0;
60  std::string name;
61 };
62 
63 using LayerDescriptionList = std::vector<LayerDescription>;
64 
65 class IBackend {
66 public:
70  using InferenceDone =
71  std::function<void(NvDsInferStatus, SharedBatchArray)>;
75  using InputsConsumed = std::function<void(SharedBatchArray)>;
76 
82  using LayersTuple = std::tuple<const LayerDescription*, int>;
83 
88  using InputShapeTuple = std::tuple<std::string, InferBatchDims>;
89  using InputShapes = std::vector<InputShapeTuple>;
90 
94  IBackend() = default;
95 
99  virtual ~IBackend() = default;
100 
105  virtual NvDsInferStatus initialize() = 0;
106 
112  virtual NvDsInferStatus specifyInputDims(const InputShapes& shapes) = 0;
113 
117  virtual bool isFirstDimBatch() const = 0;
118 
122  virtual InferTensorOrder getInputTensorOrder() const = 0;
123 
127  virtual int32_t maxBatchSize() const = 0;
128 
132  virtual uint32_t getLayerSize() const = 0;
133 
137  virtual uint32_t getInputLayerSize() const = 0;
138 
142  virtual const LayerDescription* getLayerInfo(
143  const std::string& bindingName) const = 0;
144 
148  virtual LayersTuple getInputLayers() const = 0;
149 
153  virtual LayersTuple getOutputLayers() const = 0;
154 
170  virtual NvDsInferStatus enqueue(
171  SharedBatchArray inputs, SharedCuStream stream,
172  InputsConsumed bufConsumed, InferenceDone inferenceDone) = 0;
173 
174 private:
175  DISABLE_CLASS_COPY(IBackend);
176 };
177 
178 } // namespace nvdsinferserver
179 
180 #endif
nvdsinferserver
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
Definition: sources/gst-plugins/gst-nvinferserver/gstnvinferserver_impl.h:69
nvdsinferserver::InferDataType
InferDataType
Datatype of the tensor buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:88
nvdsinferserver::IBackend::InputShapes
std::vector< InputShapeTuple > InputShapes
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:89
nvdsinferserver::IBackend::~IBackend
virtual ~IBackend()=default
Destructor, default.
nvdsinferserver::IBackend::InputShapeTuple
std::tuple< std::string, InferBatchDims > InputShapeTuple
Tuple of layer name and dimensions including batch size.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:88
nvdsinferserver::IBackend::InputsConsumed
std::function< void(SharedBatchArray)> InputsConsumed
Function wrapper called after the input buffer is consumed.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:75
nvdsinferserver::IBackend
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:65
nvdsinferserver::InferTensorOrder
InferTensorOrder
The type of tensor order.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:46
nvdsinferserver::LayerDescription
Stores the information of a layer in the inference model.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:39
nvdsinferserver::IBackend::LayersTuple
std::tuple< const LayerDescription *, int > LayersTuple
Tuple containing pointer to layer descriptions and the number of layers.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:82
nvdsinferserver::LayerDescription::isInput
bool isInput
True if the layer is an input layer.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:56
nvdsinferserver::LayerDescription::name
std::string name
Name of the model layer.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:60
nvdsinferserver::SharedBatchArray
std::shared_ptr< BaseBatchArray > SharedBatchArray
Definition: sources/libs/nvdsinferserver/infer_common.h:80
nvdsinferserver::IBackend::maxBatchSize
virtual int32_t maxBatchSize() const =0
Get the configured maximum batch size for this backend.
nvdsinferserver::IBackend::IBackend
IBackend()=default
Constructor, default.
nvdsinferserver::IBackend::getInputLayers
virtual LayersTuple getInputLayers() const =0
Get the LayersTuple for input layers.
nvdsinferserver::IBackend::enqueue
virtual NvDsInferStatus enqueue(SharedBatchArray inputs, SharedCuStream stream, InputsConsumed bufConsumed, InferenceDone inferenceDone)=0
Enqueue an array of input batches for inference.
nvdsinferserver::IBackend::specifyInputDims
virtual NvDsInferStatus specifyInputDims(const InputShapes &shapes)=0
Specify the input layers for the backend.
infer_common.h
Header file of the common declarations for the nvinferserver library.
nvdsinferserver::IBackend::getOutputLayers
virtual LayersTuple getOutputLayers() const =0
Get the LayersTuple for output layers.
nvdsinferserver::IBackend::InferenceDone
std::function< void(NvDsInferStatus, SharedBatchArray)> InferenceDone
Function wrapper for post inference processing.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:71
nvdsinferserver::SharedCuStream
std::shared_ptr< CudaStream > SharedCuStream
Cuda based pointers.
Definition: sources/libs/nvdsinferserver/infer_common.h:89
nvdsinferserver::IBackend::getLayerSize
virtual uint32_t getLayerSize() const =0
Get the number of layers (input and output) for the model.
nvdsinferserver::IBackend::kLTpLayerDesc
@ kLTpLayerDesc
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:77
nvdsinferserver::InferDataType::kFp32
@ kFp32
nvdsinferserver::IBackend::getInputLayerSize
virtual uint32_t getInputLayerSize() const =0
Get the number of input layers.
nvdsinferserver::LayerDescriptionList
std::vector< LayerDescription > LayerDescriptionList
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:63
nvdsinferserver::LayerDescription::inferDims
InferDims inferDims
Dimensions of the layer.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:47
nvdsinferserver::IBackend::kInShapeName
@ kInShapeName
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:84
nvdsinferserver::InferDims
Holds the information about the dimensions of a neural network layer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:151
nvdsinferserver::IBackend::initialize
virtual NvDsInferStatus initialize()=0
Initialize the backend for processing.
nvdsinferserver::LayerDescription::bindingIndex
int bindingIndex
Index of the layer as per sequence in which the layer is added to the list of layers.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:52
nvdsinferserver::IBackend::getInputTensorOrder
virtual InferTensorOrder getInputTensorOrder() const =0
Get the tensor order set for the input.
nvdsinferserver::IBackend::isFirstDimBatch
virtual bool isFirstDimBatch() const =0
Check if the flag for first dimension being batch is set.
nvdsinferserver::IBackend::kInShapeDims
@ kInShapeDims
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:84
nvdsinferserver::LayerDescription::dataType
InferDataType dataType
Data type of the layer.
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:43
nvdsinferserver::IBackend::getLayerInfo
virtual const LayerDescription * getLayerInfo(const std::string &bindingName) const =0
Get the layer description from the layer name.
nvdsinferserver::IBackend::kTpLayerNum
@ kTpLayerNum
Definition: sources/libs/nvdsinferserver/infer_ibackend.h:77
NvDsInferStatus
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: sources/includes/nvdsinfer.h:231