diff --git a/docs/Coding_Conventions_and_Standards.md b/docs/Coding_Conventions_and_Standards.md index 9484b3837f..b09408c2df 100644 --- a/docs/Coding_Conventions_and_Standards.md +++ b/docs/Coding_Conventions_and_Standards.md @@ -26,7 +26,7 @@ Other * Don't use else after return. see: [https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return](https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return) * Don't overuse std::shared\_ptr. Use std::shared\_ptr only if it's not clear when and where the object will be deallocated. See also: [https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr) * Avoid using the 'long' type, which could be either 32 bits or 64 bits. -* If there is a legitimate need to allocate objects on the heap, prefer using std::make_unique(). References for the reasoning: +* If there is a legitimate need to allocate objects on the heap, prefer using onnxruntime::make_unique(). References for the reasoning: * https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-make_unique * https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/ * https://abseil.io/tips/126 diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 5ef0478067..b2625b3e5d 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -989,7 +989,7 @@ static OrtStatus* OrtCreateValueImplSeqHelperTensor(const Tensor& tensor, static OrtStatus* OrtCreateValueImplSeqHelper(const OrtValue* const* in, size_t num_values, OrtValue** out) { - auto seq_ptr = std::make_unique(); + auto seq_ptr = onnxruntime::make_unique(); seq_ptr->tensors.resize(num_values); // use the data type of the first tensor as the data type of the seq diff --git a/onnxruntime/test/providers/provider_test_utils.h b/onnxruntime/test/providers/provider_test_utils.h index 6803806730..27c84fcffc 100644 --- a/onnxruntime/test/providers/provider_test_utils.h +++ b/onnxruntime/test/providers/provider_test_utils.h @@ -181,7 +181,12 @@ struct SequenceTensorTypeProto : ONNX_NAMESPACE::TypeProto { }; template -const SequenceTensorTypeProto s_sequence_tensor_type_proto; +struct SequenceTensorType { + static const SequenceTensorTypeProto s_sequence_tensor_type_proto; +}; + +template +const SequenceTensorTypeProto SequenceTensorType::s_sequence_tensor_type_proto; // To use OpTester: // 1. Create one with the op name @@ -248,7 +253,7 @@ class OpTester { void AddSeqInput(const char* name, const SeqTensors& seq_tensors) { auto mltype = DataTypeImpl::GetType(); ORT_ENFORCE(mltype != nullptr, "TensorSeq must be a registered cpp type"); - auto ptr = std::make_unique(); + auto ptr = onnxruntime::make_unique(); auto num_tensors = seq_tensors.tensors.size(); ptr->tensors.resize(num_tensors); for (int i = 0; i < num_tensors; ++i) { @@ -273,7 +278,8 @@ class OpTester { OrtValue value; value.Init(ptr.get(), mltype, mltype->GetDeleteFunc()); ptr.release(); - input_data_.push_back(Data(NodeArg(name, &s_sequence_tensor_type_proto), std::move(value), optional(), optional())); + input_data_.push_back(Data(NodeArg(name, &SequenceTensorType::s_sequence_tensor_type_proto), std::move(value), + optional(), optional())); } template