Skip to content

Commit

Permalink
Add check for well formed runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui committed Nov 8, 2023
1 parent 3d44dff commit 5dd3ac5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/backend_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ TritonModel::GetBackendLibraryProperties(
}
python_backend_based_backend_libdir = *backend_libdir;
} else {
RETURN_IF_ERROR(IsRuntimeLibraryNameWellFormed(backend_libname));
*is_python_backend_based_backend = backend_libname == kPythonFilename;
}

Expand Down
15 changes: 15 additions & 0 deletions src/model_config_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2466,4 +2466,19 @@ AssembleCPPRuntimeLibraryName(const std::string& backend_name)
#endif
}

Status
IsRuntimeLibraryNameWellFormed(const std::string& library_name)
{
const static std::vector<std::string> excluded_strings = {"\\", "/"};
for (const auto& excluded_str : excluded_strings) {
if (library_name.find(excluded_str) != library_name.npos) {
return Status(
Status::Code::INVALID_ARG,
"Model configuration runtime field contains illegal sub-string '" +
excluded_str + "'");
}
}
return Status::Success;
}

}} // namespace triton::core
6 changes: 6 additions & 0 deletions src/model_config_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,10 @@ std::string InstanceConfigSignature(
/// \return The assembled C++ runtime library name.
std::string AssembleCPPRuntimeLibraryName(const std::string& backend_name);

/// Check if runtime library name is well formed.
/// \param library_name The library name to check.
/// \return Success status if '\' and '/' characters are not in library name.
/// Error status if otherwise.
Status IsRuntimeLibraryNameWellFormed(const std::string& library_name);

}} // namespace triton::core

0 comments on commit 5dd3ac5

Please sign in to comment.