Skip to content

Commit

Permalink
lintrunner -a
Browse files Browse the repository at this point in the history
  • Loading branch information
chilo-ms committed Jan 17, 2024
1 parent 178e86f commit a69758d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
14 changes: 7 additions & 7 deletions onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ ONNX_NAMESPACE::ModelProto* CreateCtxNodeModel(const GraphViewer& graph_viewer,

/*
* Get "EP context node" model path
*
*
*
*
* If ep_context_file_path is provided:
* - If ep_context_file_path is a file:
* - If it's a file name without any path associated with it, return "engine_cache_path/ep_context_file_path".
- If it's a file name with path associated with it, return "ep_context_file_path".
* - If ep_context_file_path is a directory, return "ep_context_file_path/original_model_name_ctx.onnx".
* If ep_context_file_path is not provided:
* - Return "engine_cache_path/original_model_name_ctx.onnx".
*
*
*
*
* Example 1:
* ep_context_file_path = "/home/user/ep_context_model_foler"
* engine_cache_path = "trt_engine.engine"
* original_model_path = "model.onnx"
* => return "/home/user/ep_context_model_folder/model_ctx.onnx"
*
*
* Example 2:
* ep_context_file_path = "my_ctx_model.onnx"
* engine_cache_path = "/home/user/cache_folder/trt_engine.engine"
Expand All @@ -165,13 +165,13 @@ ONNX_NAMESPACE::ModelProto* CreateCtxNodeModel(const GraphViewer& graph_viewer,
* engine_cache_path = "trt_engine.engine"
* original_model_path = "model.onnx"
* => return "/home/user2/ep_context_model_foler/my_ctx_model.onnx"
*
*
* Example 4:
* ep_context_file_path = ""
* engine_cache_path = "/home/user3/cache_folder/trt_engine.engine"
* original_model_path = "model.onnx"
* => return "/home/user3/cache_folder/model_ctx.onnx"
*
*
*/
std::string GetCtxNodeModelPath(const std::string& ep_context_file_path,
const std::string& engine_cache_path,
Expand Down
3 changes: 2 additions & 1 deletion onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ static const std::string EMBED_MODE = "embed_mode";
static const std::string EP_CACHE_CONTEXT = "ep_cache_context";
static const std::string COMPUTE_CAPABILITY = "hardware_architecture";
static const std::string EPCONTEXT_OP_DOMAIN = "com.microsoft";
static const std::string EPCONTEXT_WARNING = "It's suggested to set the ORT graph optimization level to 0 and \
static const std::string EPCONTEXT_WARNING =

Check warning on line 19 in onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h#L19

For a static/global string constant, use a C style string instead: "static const char EPCONTEXT_WARNING[]". [runtime/string] [4]
Raw output
onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h:19:  For a static/global string constant, use a C style string instead: "static const char EPCONTEXT_WARNING[]".  [runtime/string] [4]
"It's suggested to set the ORT graph optimization level to 0 and \

Check warning on line 20 in onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h#L20

Multi-line string ("...") found. This lint script doesn't do well with such strings, and may give bogus warnings. Use C++11 raw strings or concatenation instead. [readability/multiline_string] [5]
Raw output
onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h:20:  Multi-line string ("...") found.  This lint script doesn't do well with such strings, and may give bogus warnings.  Use C++11 raw strings or concatenation instead.  [readability/multiline_string] [5]

Check warning on line 20 in onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h#L20

Use operator && instead of and [readability/alt_tokens] [2]
Raw output
onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h:20:  Use operator && instead of and  [readability/alt_tokens] [2]
make \"embed_mode\" to 0 (\"ep_cache_context\" is the cache path)\

Check warning on line 21 in onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h#L21

Extra space before ( in function call [whitespace/parens] [4]
Raw output
onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h:21:  Extra space before ( in function call  [whitespace/parens] [4]
for the best model loading time";

Check warning on line 22 in onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h#L22

Multi-line string ("...") found. This lint script doesn't do well with such strings, and may give bogus warnings. Use C++11 raw strings or concatenation instead. [readability/multiline_string] [5]
Raw output
onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h:22:  Multi-line string ("...") found.  This lint script doesn't do well with such strings, and may give bogus warnings.  Use C++11 raw strings or concatenation instead.  [readability/multiline_string] [5]

Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/session/provider_bridge_ort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1480,10 +1480,10 @@ std::shared_ptr<IExecutionProviderFactory> TensorrtProviderFactoryCreator::Creat

std::shared_ptr<IExecutionProviderFactory> TensorrtProviderFactoryCreator::Create(void* session_options, const OrtTensorRTProviderOptionsV2* provider_options) {

Check warning on line 1481 in onnxruntime/core/session/provider_bridge_ort.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/session/provider_bridge_ort.cc#L1481

Lines should be <= 120 characters long [whitespace/line_length] [2]
Raw output
onnxruntime/core/session/provider_bridge_ort.cc:1481:  Lines should be <= 120 characters long  [whitespace/line_length] [2]
// We need to create a new provider options V2 object and copy from provider_options, due to the "const" object pointed by provider_options can't be modified.

Check warning on line 1482 in onnxruntime/core/session/provider_bridge_ort.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/session/provider_bridge_ort.cc#L1482

Lines should be <= 120 characters long [whitespace/line_length] [2]
Raw output
onnxruntime/core/session/provider_bridge_ort.cc:1482:  Lines should be <= 120 characters long  [whitespace/line_length] [2]
//
//
// Note: No need to worry about tensorrt_options being a local variable, CreateExecutionProviderFactory() in TRT EP will

Check warning on line 1484 in onnxruntime/core/session/provider_bridge_ort.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/session/provider_bridge_ort.cc#L1484

Lines should be <= 120 characters long [whitespace/line_length] [2]
Raw output
onnxruntime/core/session/provider_bridge_ort.cc:1484:  Lines should be <= 120 characters long  [whitespace/line_length] [2]
// create a factory object that copies any provider options from tensorrt_options including "const char*" provider options.

Check warning on line 1485 in onnxruntime/core/session/provider_bridge_ort.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/session/provider_bridge_ort.cc#L1485

Lines should be <= 120 characters long [whitespace/line_length] [2]
Raw output
onnxruntime/core/session/provider_bridge_ort.cc:1485:  Lines should be <= 120 characters long  [whitespace/line_length] [2]
OrtTensorRTProviderOptionsV2 tensorrt_options = *provider_options; // copy and assign from provider_options
OrtTensorRTProviderOptionsV2 tensorrt_options = *provider_options; // copy and assign from provider_options

#if !defined(ORT_MINIMAL_BUILD) && defined(USE_TENSORRT)
onnxruntime::UpdateOrtTensorRTProviderOptionsV2FromSessionOptionsConfigs(reinterpret_cast<OrtSessionOptions*>(session_options), &tensorrt_options);

Check warning on line 1489 in onnxruntime/core/session/provider_bridge_ort.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/session/provider_bridge_ort.cc#L1489

Lines should be <= 120 characters long [whitespace/line_length] [2]
Raw output
onnxruntime/core/session/provider_bridge_ort.cc:1489:  Lines should be <= 120 characters long  [whitespace/line_length] [2]
Expand Down Expand Up @@ -1768,7 +1768,7 @@ ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_MIGraphX, _In_ OrtS

ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider_TensorRT, _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptions* tensorrt_options) {
API_IMPL_BEGIN

std::shared_ptr<onnxruntime::IExecutionProviderFactory> factory;

#if !defined(ORT_MINIMAL_BUILD) && defined(USE_TENSORRT)
Expand Down
12 changes: 6 additions & 6 deletions onnxruntime/python/onnxruntime_pybind_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,12 @@ std::unique_ptr<IExecutionProvider> CreateExecutionProviderInstance(
ORT_THROW("[ERROR] [TensorRT] The value for the key 'trt_dump_ep_context_model' should be 'True' or 'False'. Default value is 'False'.\n");
}
} else if (option.first == "trt_ep_context_file_path") {
if (!option.second.empty()) {
ep_context_file_path = option.second;
params.trt_ep_context_file_path = ep_context_file_path.c_str();
} else {
ORT_THROW("[ERROR] [TensorRT] The value for the key 'trt_ep_context_file_path' should be a string.\n");
}
if (!option.second.empty()) {
ep_context_file_path = option.second;
params.trt_ep_context_file_path = ep_context_file_path.c_str();
} else {
ORT_THROW("[ERROR] [TensorRT] The value for the key 'trt_ep_context_file_path' should be a string.\n");
}
} else if (option.first == "trt_ep_context_embed_mode") {
if (!option.second.empty()) {
params.trt_ep_context_embed_mode = std::stoi(option.second);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, args):
trt.init_libnvinfer_plugins(logger, "")
if len(self.plugins):
import ctypes

ctypes.CDLL(self.plugins)

# Deserialize an TRT engine
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CreateBaseModel(std::string model_name,
}

bool HasCacheFileWithPrefix(const std::string& prefix, std::string file_dir = "") {
std::filesystem::path target_dir;
std::filesystem::path target_dir;
if (file_dir.empty()) {
target_dir = std::filesystem::current_path();
} else {
Expand Down

0 comments on commit a69758d

Please sign in to comment.