NVIDIA DeepStream SDK API Reference

6.4 Release
infer_ibackend.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
23 #ifndef __NVDSINFERSERVER_IBACKEND_H__
24 #define __NVDSINFERSERVER_IBACKEND_H__
25 
26 #include "infer_common.h"
27 #include "infer_datatypes.h"
28 
29 namespace nvdsinferserver {
30 
47  int bindingIndex = 0;
51  bool isInput = 0;
55  std::string name;
56 };
57 
58 using LayerDescriptionList = std::vector<LayerDescription>;
59 
60 class IBackend {
61 public:
65  using InferenceDone =
66  std::function<void(NvDsInferStatus, SharedBatchArray)>;
70  using InputsConsumed = std::function<void(SharedBatchArray)>;
71 
77  using LayersTuple = std::tuple<const LayerDescription*, int>;
78 
83  using InputShapeTuple = std::tuple<std::string, InferBatchDims>;
84  using InputShapes = std::vector<InputShapeTuple>;
85 
89  IBackend() = default;
90 
94  virtual ~IBackend() = default;
95 
100  virtual NvDsInferStatus initialize() = 0;
101 
107  virtual NvDsInferStatus specifyInputDims(const InputShapes& shapes) = 0;
108 
112  virtual bool isFirstDimBatch() const = 0;
113 
117  virtual InferTensorOrder getInputTensorOrder() const = 0;
118 
122  virtual int32_t maxBatchSize() const = 0;
123 
127  virtual uint32_t getLayerSize() const = 0;
128 
132  virtual uint32_t getInputLayerSize() const = 0;
133 
137  virtual const LayerDescription* getLayerInfo(
138  const std::string& bindingName) const = 0;
139 
143  virtual LayersTuple getInputLayers() const = 0;
144 
148  virtual LayersTuple getOutputLayers() const = 0;
149 
165  virtual NvDsInferStatus enqueue(
166  SharedBatchArray inputs, SharedCuStream stream,
167  InputsConsumed bufConsumed, InferenceDone inferenceDone) = 0;
168 
169 private:
170  DISABLE_CLASS_COPY(IBackend);
171 };
172 
173 } // namespace nvdsinferserver
174 
175 #endif
nvdsinferserver
Copyright (c) 2021, NVIDIA CORPORATION.
Definition: infer_custom_process.h:28
nvdsinferserver::InferDataType
InferDataType
Datatype of the tensor buffer.
Definition: infer_datatypes.h:83
nvdsinferserver::IBackend::InputShapes
std::vector< InputShapeTuple > InputShapes
Definition: infer_ibackend.h:84
nvdsinferserver::IBackend::~IBackend
virtual ~IBackend()=default
Destructor, default.
infer_datatypes.h
Header file for the data types used in the inference processing.
nvdsinferserver::IBackend::InputShapeTuple
std::tuple< std::string, InferBatchDims > InputShapeTuple
Tuple of layer name and dimensions including batch size.
Definition: infer_ibackend.h:83
nvdsinferserver::IBackend::kInShapeName
@ kInShapeName
Definition: infer_ibackend.h:79
nvdsinferserver::IBackend::InputsConsumed
std::function< void(SharedBatchArray)> InputsConsumed
Function wrapper called after the input buffer is consumed.
Definition: infer_ibackend.h:70
nvdsinferserver::IBackend
Definition: infer_ibackend.h:60
nvdsinferserver::InferTensorOrder
InferTensorOrder
The type of tensor order.
Definition: infer_datatypes.h:41
nvdsinferserver::LayerDescription
Stores the information of a layer in the inference model.
Definition: infer_ibackend.h:34
nvdsinferserver::IBackend::LayersTuple
std::tuple< const LayerDescription *, int > LayersTuple
Tuple containing pointer to layer descriptions and the number of layers.
Definition: infer_ibackend.h:77
nvdsinferserver::LayerDescription::isInput
bool isInput
True if the layer is an input layer.
Definition: infer_ibackend.h:51
nvdsinferserver::IBackend::kInShapeDims
@ kInShapeDims
Definition: infer_ibackend.h:79
nvdsinferserver::LayerDescription::name
std::string name
Name of the model layer.
Definition: infer_ibackend.h:55
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::LayerDescriptionList
std::vector< LayerDescription > LayerDescriptionList
Definition: infer_ibackend.h:58
nvdsinferserver::IBackend::enqueue
virtual NvDsInferStatus enqueue(SharedBatchArray inputs, SharedCuStream stream, InputsConsumed bufConsumed, InferenceDone inferenceDone)=0
Enqueue an array of input batches for inference.
infer_common.h
Header file of the common declarations for the nvinferserver library.
nvdsinferserver::IBackend::kTpLayerNum
@ kTpLayerNum
Definition: infer_ibackend.h:72
nvdsinferserver::IBackend::specifyInputDims
virtual NvDsInferStatus specifyInputDims(const InputShapes &shapes)=0
Specify the input layers for the backend.
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: infer_ibackend.h:66
nvdsinferserver::IBackend::getLayerSize
virtual uint32_t getLayerSize() const =0
Get the number of layers (input and output) for the model.
nvdsinferserver::InferDataType::kFp32
@ kFp32
nvdsinferserver::SharedCuStream
std::shared_ptr< CudaStream > SharedCuStream
Cuda based pointers.
Definition: infer_common.h:84
nvdsinferserver::IBackend::getInputLayerSize
virtual uint32_t getInputLayerSize() const =0
Get the number of input layers.
nvdsinferserver::LayerDescription::inferDims
InferDims inferDims
Dimensions of the layer.
Definition: infer_ibackend.h:42
nvdsinferserver::InferDims
Holds the information about the dimensions of a neural network layer.
Definition: infer_datatypes.h:146
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: infer_ibackend.h:47
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::LayerDescription::dataType
InferDataType dataType
Data type of the layer.
Definition: infer_ibackend.h:38
nvdsinferserver::IBackend::getLayerInfo
virtual const LayerDescription * getLayerInfo(const std::string &bindingName) const =0
Get the layer description from the layer name.
nvdsinferserver::IBackend::kLTpLayerDesc
@ kLTpLayerDesc
Definition: infer_ibackend.h:72
nvdsinferserver::SharedBatchArray
std::shared_ptr< BaseBatchArray > SharedBatchArray
Definition: infer_common.h:75
NvDsInferStatus
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: nvdsinfer.h:218