NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/utils/tensor_init.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025-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 
18 #ifndef TENSOR_INIT_H
19 #define TENSOR_INIT_H
20 
21 #include <Eigen/Dense>
22 #include "tensor.h"
23 #include "log_utils.h"
24 #include "../infer/tensor_rt_engine.h"
25 
35 Tensor* createTensor(const std::string& tensor_name,
36  const std::vector<int>& shape,
37  NvDsDataType data_type = NvDsDataType_FP32,
38  int gpu_id = -1);
39 
49 void initOrgProjectionMatTensor(TensorCache* tensorCache, int batch_size, int num_sensors, const std::vector<Eigen::Matrix<float, 4, 4>>& calib_matrices, int gpu_id);
50 
51 
60 void initProjectionMatTensor(TensorCache* tensorCache, int batch_size, int num_sensors,
61  const std::vector<Eigen::Matrix<float, 4, 4>>& calib_matrices);
62 
70 void initImageWHTensor(TensorCache* tensorCache, int width, int height);
71 
77 void initInputCachedAnchorTensor(TensorCache* tensorCache);
78 
84 void initInputCachedFeatureTensor(TensorCache* tensorCache);
85 
92 void intiPrevExistsTensor(TensorCache* tensorCache, float value);
93 
100 void initIntervalMaskTensor(TensorCache* tensorCache, float value);
101 
108 void initGroupOriginTensor(TensorCache* tensorCache, const std::vector<float>& group_origin);
109 
116 void updateInputCachedAnchorTensor(TensorCache* tensorCache, torch::Tensor anchor);
117 
124 void updateInputCachedFeatureTensor(TensorCache* tensorCache, torch::Tensor feature);
125 
136  const std::map<std::string, Eigen::Matrix<float, 4, 4>>& cameraMatrices,
137  const std::vector<std::string>& currentBatchCameras,
138  int batch_size,
139  int num_sensors);
140 
151  const std::map<std::string, Eigen::Matrix<float, 4, 4>>& cameraMatrices,
152  const std::vector<std::string>& currentBatchCameras,
153  int batch_size, int num_sensors);
154 #endif /* TENSOR_INIT_H */
width
JDIMENSION JDIMENSION * width
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jpeglib.h:1001
TensorCache
Class to manage multiple tensors with string-based lookup.
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/utils/tensor.h:511
createTensor
Tensor * createTensor(const std::string &tensor_name, const std::vector< int > &shape, NvDsDataType data_type=NvDsDataType_FP32, int gpu_id=-1)
Creates a tensor with the specified shape, data type, and GPU ID.
initProjectionMatTensor
void initProjectionMatTensor(TensorCache *tensorCache, int batch_size, int num_sensors, const std::vector< Eigen::Matrix< float, 4, 4 >> &calib_matrices)
Initializes projection matrix tensor using pre-allocated memory and updates the TensorCache.
initInputCachedAnchorTensor
void initInputCachedAnchorTensor(TensorCache *tensorCache)
Initializes cached anchor tensor using pre-allocated memory and updates the TensorCache.
updateInputCachedAnchorTensor
void updateInputCachedAnchorTensor(TensorCache *tensorCache, torch::Tensor anchor)
Updates input cached anchor tensor using pre-allocated memory.
intiPrevExistsTensor
void intiPrevExistsTensor(TensorCache *tensorCache, float value)
Initializes prev_exists tensor using pre-allocated memory and updates the TensorCache.
updateInputCachedFeatureTensor
void updateInputCachedFeatureTensor(TensorCache *tensorCache, torch::Tensor feature)
Updates input cached feature tensor using pre-allocated memory.
updateOrgProjectionMatrixForBatch
void updateOrgProjectionMatrixForBatch(TensorCache *tensorCache, const std::map< std::string, Eigen::Matrix< float, 4, 4 >> &cameraMatrices, const std::vector< std::string > &currentBatchCameras, int batch_size, int num_sensors)
Updates the original projection matrix tensor based on the current camera names in the batch.
tensor.h
initImageWHTensor
void initImageWHTensor(TensorCache *tensorCache, int width, int height)
Initializes image width/height tensor using pre-allocated memory and updates the TensorCache.
initIntervalMaskTensor
void initIntervalMaskTensor(TensorCache *tensorCache, float value)
Initializes interval mask tensor using pre-allocated memory and updates the TensorCache.
initOrgProjectionMatTensor
void initOrgProjectionMatTensor(TensorCache *tensorCache, int batch_size, int num_sensors, const std::vector< Eigen::Matrix< float, 4, 4 >> &calib_matrices, int gpu_id)
Initialize projection matrix tensor and update the TensorCache.
Tensor
Structure to store tensor information.
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/utils/tensor.h:40
initGroupOriginTensor
void initGroupOriginTensor(TensorCache *tensorCache, const std::vector< float > &group_origin)
Initializes group origin tensor using pre-allocated memory and updates the TensorCache.
NvDsDataType_FP32
@ NvDsDataType_FP32
FP32 data type.
Definition: includes/nvds_roi_meta.h:62
updateProjectionMatrixForBatch
void updateProjectionMatrixForBatch(TensorCache *tensorCache, const std::map< std::string, Eigen::Matrix< float, 4, 4 >> &cameraMatrices, const std::vector< std::string > &currentBatchCameras, int batch_size, int num_sensors)
Updates projection matrix tensor based on the current camera names in the batch.
log_utils.h
initInputCachedFeatureTensor
void initInputCachedFeatureTensor(TensorCache *tensorCache)
Initializes cached feature tensor using pre-allocated memory and updates the TensorCache.
NvDsDataType
NvDsDataType
Data type used for model in infer.
Definition: includes/nvds_roi_meta.h:59