Fix build for gcc 4.8.5. (#2036)

This commit is contained in:
Pranav Sharma 2019-10-08 00:50:53 -07:00 committed by GitHub
parent b70fc34fae
commit f13b66768a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View file

@ -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

View file

@ -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<TensorSeq>();
auto seq_ptr = onnxruntime::make_unique<TensorSeq>();
seq_ptr->tensors.resize(num_values);
// use the data type of the first tensor as the data type of the seq

View file

@ -181,7 +181,12 @@ struct SequenceTensorTypeProto : ONNX_NAMESPACE::TypeProto {
};
template <typename ElemType>
const SequenceTensorTypeProto<ElemType> s_sequence_tensor_type_proto;
struct SequenceTensorType {
static const SequenceTensorTypeProto<ElemType> s_sequence_tensor_type_proto;
};
template <typename ElemType>
const SequenceTensorTypeProto<ElemType> SequenceTensorType<ElemType>::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<T>& seq_tensors) {
auto mltype = DataTypeImpl::GetType<TensorSeq>();
ORT_ENFORCE(mltype != nullptr, "TensorSeq must be a registered cpp type");
auto ptr = std::make_unique<TensorSeq>();
auto ptr = onnxruntime::make_unique<TensorSeq>();
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<T>), std::move(value), optional<float>(), optional<float>()));
input_data_.push_back(Data(NodeArg(name, &SequenceTensorType<T>::s_sequence_tensor_type_proto), std::move(value),
optional<float>(), optional<float>()));
}
template <typename TKey, typename TVal>