Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
NvInferLegacyDims.h207 linesDownload Raw Back to include
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2025 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 NV_INFER_LEGACY_DIMS_H
19#define NV_INFER_LEGACY_DIMS_H
20
21#define NV_INFER_INTERNAL_INCLUDE 1
22#include "NvInferRuntimeBase.h" // IWYU pragma: exports
23#undef NV_INFER_INTERNAL_INCLUDE
24
25//!
26//! \file NvInferLegacyDims.h
27//!
28//! This file contains declarations of legacy dimensions types which use channel
29//! semantics in their names, and declarations on which those types rely.
30//!
31
32//!
33//! \namespace nvinfer1
34//!
35//! \brief The TensorRT API version 1 namespace.
36//!
37namespace nvinfer1
38{
39//!
40//! \class Dims2
41//!
42//! \brief Descriptor for two-dimensional data.
43//!
44class Dims2 : public Dims
45{
46public:
47    //!
48    //! \brief Construct an empty Dims2 object.
49    //!
50    Dims2()
51        : Dims2(0, 0)
52    {
53    }
54
55    //!
56    //! \brief Construct a Dims2 from 2 elements.
57    //!
58    //! \param d0 The first element.
59    //! \param d1 The second element.
60    //!
61    Dims2(int64_t d0, int64_t d1)
62    {
63        nbDims = 2;
64        d[0] = d0;
65        d[1] = d1;
66        for (int64_t i{nbDims}; i < Dims::MAX_DIMS; ++i)
67        {
68            d[i] = 0;
69        }
70    }
71};
72
73//!
74//! \class DimsHW
75//!
76//! \brief Descriptor for two-dimensional spatial data.
77//!
78class DimsHW : public Dims2
79{
80public:
81    //!
82    //! \brief Construct an empty DimsHW object.
83    //!
84    DimsHW()
85        : Dims2()
86    {
87    }
88
89    //!
90    //! \brief Construct a DimsHW given height and width.
91    //!
92    //! \param height the height of the data
93    //! \param width the width of the data
94    //!
95    DimsHW(int64_t height, int64_t width)
96        : Dims2(height, width)
97    {
98    }
99
100    //!
101    //! \brief Get the height.
102    //!
103    //! \return The height.
104    //!
105    int64_t& h()
106    {
107        return d[0];
108    }
109
110    //!
111    //! \brief Get the height.
112    //!
113    //! \return The height.
114    //!
115    int64_t h() const
116    {
117        return d[0];
118    }
119
120    //!
121    //! \brief Get the width.
122    //!
123    //! \return The width.
124    //!
125    int64_t& w()
126    {
127        return d[1];
128    }
129
130    //!
131    //! \brief Get the width.
132    //!
133    //! \return The width.
134    //!
135    int64_t w() const
136    {
137        return d[1];
138    }
139};
140
141//!
142//! \class Dims3
143//!
144//! \brief Descriptor for three-dimensional data.
145//!
146class Dims3 : public Dims2
147{
148public:
149    //!
150    //! \brief Construct an empty Dims3 object.
151    //!
152    Dims3()
153        : Dims3(0, 0, 0)
154    {
155    }
156
157    //!
158    //! \brief Construct a Dims3 from 3 elements.
159    //!
160    //! \param d0 The first element.
161    //! \param d1 The second element.
162    //! \param d2 The third element.
163    //!
164    Dims3(int64_t d0, int64_t d1, int64_t d2)
165        : Dims2(d0, d1)
166    {
167        nbDims = 3;
168        d[2] = d2;
169    }
170};
171
172//!
173//! \class Dims4
174//!
175//! \brief Descriptor for four-dimensional data.
176//!
177class Dims4 : public Dims3
178{
179public:
180    //!
181    //! \brief Construct an empty Dims4 object.
182    //!
183    Dims4()
184        : Dims4(0, 0, 0, 0)
185    {
186    }
187
188    //!
189    //! \brief Construct a Dims4 from 4 elements.
190    //!
191    //! \param d0 The first element.
192    //! \param d1 The second element.
193    //! \param d2 The third element.
194    //! \param d3 The fourth element.
195    //!
196    Dims4(int64_t d0, int64_t d1, int64_t d2, int64_t d3)
197        : Dims3(d0, d1, d2)
198    {
199        nbDims = 4;
200        d[3] = d3;
201    }
202};
203
204} // namespace nvinfer1
205
206#endif // NV_INFER_LEGCY_DIMS_H
207 
codekingpro/portable-devtools · Team Ai