NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/libs/nvdsinferserver/infer_trtis_utils.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-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 
24 #ifndef __NVDSINFER_TRTIS_UTILS_H__
25 #define __NVDSINFER_TRTIS_UTILS_H__
26 
27 #include <string>
28 #include <thread>
29 #include <vector>
30 #include <memory>
31 #include <functional>
32 
33 #include "infer_common.h"
34 #include "infer_datatypes.h"
35 #include "infer_utils.h"
36 
37 #include "model_config.pb.h"
38 #include "tritonserver.h"
39 
45 #define CHECK_TRTIS_ERR_W_ACTION(trtisExpr, action, fmt, ...) \
46  do { \
47  UniqTritonT<TRITONSERVER_Error> errPtr( \
48  (trtisExpr), TRITONSERVER_ErrorDelete); \
49  if (errPtr) { \
50  InferError( \
51  "Triton: " fmt ", triton_err_str:%s, err_msg:%s", \
52  ##__VA_ARGS__, TRITONSERVER_ErrorCodeString(errPtr.get()), \
53  TRITONSERVER_ErrorMessage(errPtr.get())); \
54  action; \
55  } \
56  } while (0)
57 
62 #define RETURN_TRTIS_ERROR(trtisExpr, fmt, ...) \
63  CHECK_TRTIS_ERR_W_ACTION(trtisExpr, return NVDSINFER_TRITON_ERROR, fmt, ##__VA_ARGS__)
64 
69 #define CONTINUE_TRTIS_ERROR(trtisExpr, fmt, ...) \
70  CHECK_TRTIS_ERR_W_ACTION(trtisExpr, , fmt, ##__VA_ARGS__)
71 
72 namespace ni = inference;
73 
74 namespace nvdsinferserver {
75 
82 
89 
97 
104 InferTensorOrder TensorOrderFromTritonPb(ni::ModelInput::Format order);
105 
113 
122 
134 template <typename VecDims>
135 InferDims
136 DimsFromTriton(const VecDims& shape)
137 {
138  InferDims ret{0};
139  assert((int)shape.size() <= NVDSINFER_MAX_DIMS);
140  uint32_t i = 0;
141  for (const auto &v : shape) {
142  if (v < 0) {
143  ret.d[i] = -1;
144  } else {
145  ret.d[i] = v;
146  }
147  ++i;
148  }
149  ret.numDims = i;
150  if (!hasWildcard(ret)) {
151  normalizeDims(ret);
152  }
153  return ret;
154 }
155 
160 const char* TritonControlModeToStr(int32_t mode);
161 
162 } // namespace nvdsinferserver
163 
164 #endif /* __NVDSINFER_TRTIS_UTILS_H__ */
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::MemTypeFromTriton
InferMemType MemTypeFromTriton(TRITONSERVER_MemoryType type)
Maps the TRITONSERVER_MemoryType to the InferMemType.
nvdsinferserver::InferDataType
InferDataType
Datatype of the tensor buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:88
infer_common.h
Header file of the common declarations for the nvinferserver library.
TRITONSERVER_MemoryType
enum TRITONSERVER_memorytype_enum TRITONSERVER_MemoryType
TRITONSERVER_MemoryType.
nvdsinferserver::DataTypeFromTritonPb
InferDataType DataTypeFromTritonPb(ni::DataType type)
Maps the data type from Triton model configuration proto definition to InferDataType.
ds3d::DataType
DataType
Definition: sources/includes/ds3d/common/idatatype.h:82
nvdsinferserver::InferTensorOrder
InferTensorOrder
The type of tensor order.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:46
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.
nvdsinferserver::DimsFromTriton
InferDims DimsFromTriton(const VecDims &shape)
Converts the input shape vector from Triton to InferDims type.
Definition: sources/libs/nvdsinferserver/infer_trtis_utils.h:136
nvdsinfer::hasWildcard
bool hasWildcard(const nvinfer1::Dims &dims)
NVDSINFER_MAX_DIMS
#define NVDSINFER_MAX_DIMS
Definition: sources/includes/nvdsinfer.h:44
TRITONSERVER_DataType
enum TRITONSERVER_datatype_enum TRITONSERVER_DataType
TRITONSERVER_DataType.
infer_utils.h
Header file containing utility functions and classes used by the nvinferserver low level library.
nvdsinferserver::InferMemType
InferMemType
The memory types of inference buffers.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:61
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.
nvdsinferserver::TritonControlModeToStr
const char * TritonControlModeToStr(int32_t mode)
Returns a string describing the TRITONSERVER_ModelControlMode: none, explicit or poll.
ds3d::v2xinfer::format
static std::string format(const char *fmt,...)
Definition: sources/libs/ds3d/inference_custom_lib/ds3d_v2x_infer_custom_preprocess/tensor.hpp:31