onnxruntime/include/onnxruntime/core/common/string_helper.h
2022-01-06 11:03:14 -08:00

17 lines
547 B
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "core/session/onnxruntime_c_api.h"
namespace onnxruntime {
#if defined(USE_TENSORRT) || defined(USE_CUDA)
static char* StrDup(const std::string& str, _Inout_ OrtAllocator* allocator) {
char* output_string = reinterpret_cast<char*>(allocator->Alloc(allocator, str.size() + 1));
memcpy(output_string, str.c_str(), str.size());
output_string[str.size()] = '\0';
return output_string;
}
#endif
} // namespace onnxruntime