From ec04b6203b632b83359cd87186dc6deee9a0a8e1 Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Thu, 29 Apr 2021 19:13:09 -0700 Subject: [PATCH] Remove conditional compilation of std::is_trivially_copyable since we are no longer supporting GCC 4. (#7504) --- onnxruntime/core/framework/data_transfer_utils.h | 3 --- onnxruntime/core/framework/endian_utils.h | 9 +-------- onnxruntime/core/framework/tensorprotoutils.cc | 6 ------ onnxruntime/core/providers/cuda/shared_inc/cuda_utils.h | 3 --- 4 files changed, 1 insertion(+), 20 deletions(-) diff --git a/onnxruntime/core/framework/data_transfer_utils.h b/onnxruntime/core/framework/data_transfer_utils.h index 7b19e8318b..c3ed5ece2f 100644 --- a/onnxruntime/core/framework/data_transfer_utils.h +++ b/onnxruntime/core/framework/data_transfer_utils.h @@ -45,10 +45,7 @@ common::Status CopyTensorDataToSpan( const DataTransferManager& data_transfer_manager, const Tensor& src_tensor, const OrtMemoryInfo& dst_alloc_info, gsl::span dst_span) { -// std::is_trivially_copyable is not implemented in older versions of GCC -#if !defined(__GNUC__) || __GNUC__ >= 5 static_assert(std::is_trivially_copyable::value, "Element type must be trivially copyable."); -#endif ORT_RETURN_IF_NOT(src_tensor.DataType() == DataTypeImpl::GetType(), "Data type mismatch"); ORT_RETURN_IF_NOT(src_tensor.SizeInBytes() == static_cast(dst_span.size_bytes()), "src size != dst size"); Tensor dst_tensor{src_tensor.DataType(), src_tensor.Shape(), dst_span.data(), dst_alloc_info}; diff --git a/onnxruntime/core/framework/endian_utils.h b/onnxruntime/core/framework/endian_utils.h index 92460679a9..d44ce641c5 100644 --- a/onnxruntime/core/framework/endian_utils.h +++ b/onnxruntime/core/framework/endian_utils.h @@ -51,15 +51,11 @@ common::Status ReadLittleEndian(size_t element_size, gsl::span destination_bytes); /** - * Reads from a little-endian source with check that T is trivially copyable. - * @remarks Check is skipped for if building with gcc v4 + * Reads from a little-endian source. */ template common::Status ReadLittleEndian(gsl::span source_bytes, gsl::span destination) { -// std::is_trivially_copyable is not implemented in older versions of GCC -#if !defined(__GNUC__) || __GNUC__ >= 5 static_assert(std::is_trivially_copyable::value, "T must be trivially copyable"); -#endif const auto destination_bytes = gsl::make_span(reinterpret_cast(destination.data()), destination.size_bytes()); return ReadLittleEndian(sizeof(T), source_bytes, destination_bytes); @@ -70,10 +66,7 @@ common::Status ReadLittleEndian(gsl::span source_bytes, gsl */ template common::Status WriteLittleEndian(gsl::span source, gsl::span destination_bytes) { -// std::is_trivially_copyable is not implemented in older versions of GCC -#if !defined(__GNUC__) || __GNUC__ >= 5 static_assert(std::is_trivially_copyable::value, "T must be trivially copyable"); -#endif const auto source_bytes = gsl::make_span(reinterpret_cast(source.data()), source.size_bytes()); return detail::CopyLittleEndian(sizeof(T), source_bytes, destination_bytes); } diff --git a/onnxruntime/core/framework/tensorprotoutils.cc b/onnxruntime/core/framework/tensorprotoutils.cc index a0e3adbd99..f7e12d3a79 100644 --- a/onnxruntime/core/framework/tensorprotoutils.cc +++ b/onnxruntime/core/framework/tensorprotoutils.cc @@ -111,10 +111,7 @@ static Status UnpackTensorWithRawDataImpl(const void* raw_data, size_t raw_data_ template Status UnpackTensorWithRawData(const void* raw_data, size_t raw_data_len, size_t expected_num_elements, /*out*/ T* p_data) { - // std::is_trivially_copyable is not implemented in older versions of GCC -#if !defined(__GNUC__) || __GNUC__ >= 5 static_assert(std::is_trivially_copyable::value, "T must be trivially copyable"); -#endif return UnpackTensorWithRawDataImpl(raw_data, raw_data_len, expected_num_elements, sizeof(T), reinterpret_cast(p_data)); @@ -204,10 +201,7 @@ template Status UnpackTensorWithExternalData(const ONNX_NAMESPACE::TensorProto& tensor, const ORTCHAR_T* tensor_proto_dir, size_t expected_num_elements, /*out*/ T* p_data) { - // std::is_trivially_copyable is not implemented in older versions of GCC -#if !defined(__GNUC__) || __GNUC__ >= 5 static_assert(std::is_trivially_copyable::value, "T must be trivially copyable"); -#endif return UnpackTensorWithExternalDataImpl(tensor, tensor_proto_dir, expected_num_elements, sizeof(T), reinterpret_cast(p_data)); diff --git a/onnxruntime/core/providers/cuda/shared_inc/cuda_utils.h b/onnxruntime/core/providers/cuda/shared_inc/cuda_utils.h index 483934990b..244fe0a5c7 100644 --- a/onnxruntime/core/providers/cuda/shared_inc/cuda_utils.h +++ b/onnxruntime/core/providers/cuda/shared_inc/cuda_utils.h @@ -60,10 +60,7 @@ struct TArray { } TArray(const std::vector& vec) : TArray(static_cast(vec.size())) { -// std::is_trivially_copyable is not implemented in older versions of GCC -#if !defined(__GNUC__) || __GNUC__ >= 5 static_assert(std::is_trivially_copyable::value, "T must be trivially copyable."); -#endif memcpy(data_, vec.data(), vec.size() * sizeof(T)); }