API
 
Loading...
Searching...
No Matches
parserOnnxConfig.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2024 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 PARSER_ONNX_CONFIG_H
19#define PARSER_ONNX_CONFIG_H
20
21#include <cstring>
22#include <iostream>
23#include <string>
24
25#include "/opt/MagAOX/vendor/TensorRT-10.0.0.6/include/NvInfer.h"
26#include "/opt/MagAOX/vendor/TensorRT-10.0.0.6/include/NvOnnxConfig.h"
27#include "/opt/MagAOX/vendor/TensorRT-10.0.0.6/include/NvOnnxParser.h"
28
29#define ONNX_DEBUG 1
30
31/**
32 * \class ParserOnnxConfig
33 * \brief Configuration Manager Class Concrete Implementation
34 *
35 * \note:
36 *
37 */
38
39class ParserOnnxConfig : public nvonnxparser::IOnnxConfig
40{
41
42protected:
43 std::string mModelFilename{};
44 std::string mTextFilename{};
45 std::string mFullTextFilename{};
46 nvinfer1::DataType mModelDtype;
47 nvonnxparser::IOnnxConfig::Verbosity mVerbosity;
49
50public:
52 : mModelDtype(nvinfer1::DataType::kFLOAT)
53 , mVerbosity(static_cast<int>(nvinfer1::ILogger::Severity::kWARNING))
54 , mPrintLayercInfo(false)
55 {
56#ifdef ONNX_DEBUG
57 if (isDebug())
58 {
59 std::cout << " ParserOnnxConfig::ctor(): " << this << "\t" << std::endl;
60 }
61#endif
62 }
63
65 {
66#ifdef ONNX_DEBUG
67 if (isDebug())
68 {
69 std::cout << "ParserOnnxConfig::dtor(): " << this << std::endl;
70 }
71#endif
72 }
73
74public:
75 void setModelDtype(const nvinfer1::DataType modelDtype) noexcept override
76 {
77 mModelDtype = modelDtype;
78 }
79
80 nvinfer1::DataType getModelDtype() const noexcept override
81 {
82 return mModelDtype;
83 }
84
85 const char* getModelFileName() const noexcept override
86 {
87 return mModelFilename.c_str();
88 }
89 void setModelFileName(const char* onnxFilename) noexcept override
90 {
91 mModelFilename = std::string(onnxFilename);
92 }
93 nvonnxparser::IOnnxConfig::Verbosity getVerbosityLevel() const noexcept override
94 {
95 return mVerbosity;
96 }
97 void addVerbosity() noexcept override
98 {
99 ++mVerbosity;
100 }
101 void reduceVerbosity() noexcept override
102 {
103 --mVerbosity;
104 }
105 void setVerbosityLevel(nvonnxparser::IOnnxConfig::Verbosity verbosity) noexcept override
106 {
107 mVerbosity = verbosity;
108 }
109
110 const char* getTextFileName() const noexcept override
111 {
112 return mTextFilename.c_str();
113 }
114 void setTextFileName(const char* textFilename) noexcept override
115 {
116 mTextFilename = std::string(textFilename);
117 }
118 const char* getFullTextFileName() const noexcept override
119 {
120 return mFullTextFilename.c_str();
121 }
122 void setFullTextFileName(const char* fullTextFilename) noexcept override
123 {
124 mFullTextFilename = std::string(fullTextFilename);
125 }
126 bool getPrintLayerInfo() const noexcept override
127 {
128 return mPrintLayercInfo;
129 }
130 void setPrintLayerInfo(bool src) noexcept override
131 {
132 mPrintLayercInfo = src;
133 } //!< get the boolean variable corresponding to the Layer Info, see getPrintLayerInfo()
134
135 virtual bool isDebug() const noexcept
136 {
137#if ONNX_DEBUG
138 return (std::getenv("ONNX_DEBUG") ? true : false);
139#else
140 return false;
141#endif
142 }
143}; // class ParserOnnxConfig
144
145#endif
Configuration Manager Class Concrete Implementation.
const char * getTextFileName() const noexcept override
bool getPrintLayerInfo() const noexcept override
nvinfer1::DataType getModelDtype() const noexcept override
const char * getModelFileName() const noexcept override
void setModelFileName(const char *onnxFilename) noexcept override
nvonnxparser::IOnnxConfig::Verbosity mVerbosity
nvinfer1::DataType mModelDtype
void setTextFileName(const char *textFilename) noexcept override
std::string mFullTextFilename
void reduceVerbosity() noexcept override
void setPrintLayerInfo(bool src) noexcept override
get the boolean variable corresponding to the Layer Info, see getPrintLayerInfo()
~ParserOnnxConfig() override
void setFullTextFileName(const char *fullTextFilename) noexcept override
void addVerbosity() noexcept override
virtual bool isDebug() const noexcept
nvonnxparser::IOnnxConfig::Verbosity getVerbosityLevel() const noexcept override
std::string mModelFilename
void setModelDtype(const nvinfer1::DataType modelDtype) noexcept override
const char * getFullTextFileName() const noexcept override
void setVerbosityLevel(nvonnxparser::IOnnxConfig::Verbosity verbosity) noexcept override
std::string mTextFilename