NVIDIA DeepStream SDK API Reference

7.0 Release
infer_trtis_utils.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-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 
19 #ifndef __NVDSINFER_TRTIS_UTILS_H__
20 #define __NVDSINFER_TRTIS_UTILS_H__
21 
22 #include <string>
23 #include <thread>
24 #include <vector>
25 #include <memory>
26 #include <functional>
27 
28 #include "infer_common.h"
29 #include "infer_datatypes.h"
30 #include "infer_utils.h"
31 
32 #include "model_config.pb.h"
33 #include "tritonserver.h"
34 
40 #define CHECK_TRTIS_ERR_W_ACTION(trtisExpr, action, fmt, ...) \
41  do { \
42  UniqTritonT<TRITONSERVER_Error> errPtr( \
43  (trtisExpr), TRITONSERVER_ErrorDelete); \
44  if (errPtr) { \
45  InferError( \
46  "Triton: " fmt ", triton_err_str:%s, err_msg:%s", \
47  ##__VA_ARGS__, TRITONSERVER_ErrorCodeString(errPtr.get()), \
48  TRITONSERVER_ErrorMessage(errPtr.get())); \
49  action; \
50  } \
51  } while (0)
52 
57 #define RETURN_TRTIS_ERROR(trtisExpr, fmt, ...) \
58  CHECK_TRTIS_ERR_W_ACTION(trtisExpr, return NVDSINFER_TRITON_ERROR, fmt, ##__VA_ARGS__)
59 
64 #define CONTINUE_TRTIS_ERROR(trtisExpr, fmt, ...) \
65  CHECK_TRTIS_ERR_W_ACTION(trtisExpr, , fmt, ##__VA_ARGS__)
66 
67 namespace ni = inference;
68 
69 namespace nvdsinferserver {
70 
77 
84 
92 
99 InferTensorOrder TensorOrderFromTritonPb(ni::ModelInput::Format order);
100 
107 InferTensorOrder TensorOrderFromTritonMeta(const std::string& format);
108 
117 
129 template <typename VecDims>
130 InferDims
131 DimsFromTriton(const VecDims& shape)
132 {
133  InferDims ret{0};
134  assert((int)shape.size() <= NVDSINFER_MAX_DIMS);
135  uint32_t i = 0;
136  for (const auto &v : shape) {
137  if (v < 0) {
138  ret.d[i] = -1;
139  } else {
140  ret.d[i] = v;
141  }
142  ++i;
143  }
144  ret.numDims = i;
145  if (!hasWildcard(ret)) {
146  normalizeDims(ret);
147  }
148  return ret;
149 }
150 
155 const char* TritonControlModeToStr(int32_t mode);
156 
157 } // namespace nvdsinferserver
158 
159 #endif /* __NVDSINFER_TRTIS_UTILS_H__ */
nvdsinferserver
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
Definition: infer_custom_process.h:24
nvdsinferserver::MemTypeFromTriton
InferMemType MemTypeFromTriton(TRITONSERVER_MemoryType type)
Maps the TRITONSERVER_MemoryType to the InferMemType.
nvdsinferserver::InferDataType
InferDataType
Datatype of the tensor buffer.
Definition: infer_datatypes.h:83
nvdsinferserver::DataTypeFromTritonPb
InferDataType DataTypeFromTritonPb(ni::DataType type)
Maps the data type from Triton model configuration proto definition to InferDataType.
ds3d::DataType
DataType
Definition: idatatype.h:77
infer_datatypes.h
Header file for the data types used in the inference processing.
nvdsinferserver::InferTensorOrder
InferTensorOrder
The type of tensor order.
Definition: infer_datatypes.h:41
TRITONSERVER_MemoryType
enum TRITONSERVER_memorytype_enum TRITONSERVER_MemoryType
TRITONSERVER_MemoryType.
nvdsinferserver::DataTypeToTriton
TRITONSERVER_DataType DataTypeToTriton(InferDataType type)
Maps the InferDataType to TRITONSERVER_DataType.
nvdsinferserver::normalizeDims
void normalizeDims(InferDims &dims)
nvdsinferserver::DataTypeFromTriton
InferDataType DataTypeFromTriton(TRITONSERVER_DataType type)
Maps the TRITONSERVER_DataType to the InferDataType.
infer_utils.h
Header file containing utility functions and classes used by the nvinferserver low level library.
nvdsinferserver::TritonControlModeToStr
const char * TritonControlModeToStr(int32_t mode)
Returns a string describing the TRITONSERVER_ModelControlMode: none, explicit or poll.
infer_common.h
Header file of the common declarations for the nvinferserver library.
nvdsinferserver::DimsFromTriton
InferDims DimsFromTriton(const VecDims &shape)
Converts the input shape vector from Triton to InferDims type.
Definition: infer_trtis_utils.h:131
NVDSINFER_MAX_DIMS
#define NVDSINFER_MAX_DIMS
Definition: nvdsinfer.h:39
TRITONSERVER_DataType
enum TRITONSERVER_datatype_enum TRITONSERVER_DataType
TRITONSERVER_DataType.
nvdsinferserver::InferMemType
InferMemType
The memory types of inference buffers.
Definition: infer_datatypes.h:56
nvdsinferserver::InferDims
Holds the information about the dimensions of a neural network layer.
Definition: infer_datatypes.h:146
INFER_EXPORT_API::hasWildcard
bool hasWildcard(const InferDims &dims)
Check if any of the InferDims dimensions are of dynamic size (-1 or negative values).
Definition: infer_utils.h:656
nvdsinferserver::TensorOrderFromTritonPb
InferTensorOrder TensorOrderFromTritonPb(ni::ModelInput::Format order)
Maps the tensor order from Triton model configuration proto definition to the InferTensorOrder type.
nvdsinferserver::TensorOrderFromTritonMeta
InferTensorOrder TensorOrderFromTritonMeta(const std::string &format)
Maps the tensor order from Triton metadata string to the InferTensorOrder type.
nvdsinferserver::MemTypeToTriton
TRITONSERVER_MemoryType MemTypeToTriton(InferMemType type)
Maps the InferMemType to the TRITONSERVER_MemoryType.
tritonserver.h