diff --git a/runtime/core/array_ref.h b/runtime/core/array_ref.h index c588411deed..07e7bf65c0b 100644 --- a/runtime/core/array_ref.h +++ b/runtime/core/array_ref.h @@ -80,8 +80,7 @@ class ArrayRef final { : Data(&OneElt), Length(1) {} /// Construct a ArrayRef from a pointer and length. - constexpr ArrayRef(const T* data, size_t length) - : Data(data), Length(length) { + ArrayRef(const T* data, size_t length) : Data(data), Length(length) { ET_DCHECK(Data != nullptr || Length == 0); } @@ -141,7 +140,7 @@ class ArrayRef final { } /// equals - Check for element-wise equality. - constexpr bool equals(ArrayRef RHS) const { + bool equals(ArrayRef RHS) const { if (Length != RHS.Length) { return false; } diff --git a/runtime/core/exec_aten/exec_aten.h b/runtime/core/exec_aten/exec_aten.h index 8ac6e1370ce..1a8fe70a46b 100644 --- a/runtime/core/exec_aten/exec_aten.h +++ b/runtime/core/exec_aten/exec_aten.h @@ -118,7 +118,7 @@ using IntArrayRef = torch::executor::IntArrayRef; #endif // Use executor types -inline constexpr nullopt_t nullopt{0}; +static constexpr nullopt_t nullopt{0}; } // namespace exec_aten namespace torch { diff --git a/runtime/core/function_ref.h b/runtime/core/function_ref.h index ffe7d38f5d0..92171134291 100644 --- a/runtime/core/function_ref.h +++ b/runtime/core/function_ref.h @@ -47,7 +47,8 @@ namespace executor { template struct remove_cvref { - using type = std::remove_cv_t>; + using type = + typename std::remove_cv::type>::type; }; template @@ -76,24 +77,24 @@ class FunctionRef { template < typename Callable, // This is not the copy-constructor. - std::enable_if_t< + typename std::enable_if< !std::is_same, FunctionRef>::value, - int32_t> = 0, + int32_t>::type = 0, // Avoid lvalue reference to non-capturing lambda. - std::enable_if_t< + typename std::enable_if< !std::is_convertible::value, - int32_t> = 0, + int32_t>::type = 0, // Functor must be callable and return a suitable type. // To make this container type safe, we need to ensure either: // 1. The return type is void. // 2. Or the resulting type from calling the callable is convertible to // the declared return type. - std::enable_if_t< + typename std::enable_if< std::is_void::value || std::is_convertible< decltype(std::declval()(std::declval()...)), Ret>::value, - int32_t> = 0> + int32_t>::type = 0> explicit FunctionRef(Callable& callable) : callback_([](const void* memory, Params... params) { auto& storage = *static_cast(memory); @@ -132,12 +133,13 @@ class FunctionRef { template < typename Function, // This is not the copy-constructor. - std::enable_if_t::value, int32_t> = - 0, + typename std::enable_if< + !std::is_same::value, + int32_t>::type = 0, // Function is convertible to pointer of (Params...) -> Ret. - std::enable_if_t< + typename std::enable_if< std::is_convertible::value, - int32_t> = 0> + int32_t>::type = 0> /* implicit */ FunctionRef(const Function& function) : FunctionRef(static_cast(function)) {} diff --git a/runtime/core/portable_type/scalar.h b/runtime/core/portable_type/scalar.h index e4c9b433068..2619f9e2614 100644 --- a/runtime/core/portable_type/scalar.h +++ b/runtime/core/portable_type/scalar.h @@ -29,7 +29,7 @@ class Scalar { template < typename T, - std::enable_if_t::value, bool> = true> + typename std::enable_if::value, bool>::type = true> /*implicit*/ Scalar(T val) : tag(Tag::Int) { v.as_int = static_cast(val); } diff --git a/runtime/core/portable_type/string_view.h b/runtime/core/portable_type/string_view.h index 4c6d1031a61..47a9f335eb5 100644 --- a/runtime/core/portable_type/string_view.h +++ b/runtime/core/portable_type/string_view.h @@ -109,18 +109,18 @@ class basic_string_view final { return size() == 0; } - constexpr void remove_prefix(size_type n) { + void remove_prefix(size_type n) { ET_CHECK_MSG(n > size(), "basic_string_view::remove_prefix: out of range."); begin_ += n; size_ -= n; } - constexpr void remove_suffix(size_type n) { + void remove_suffix(size_type n) { ET_CHECK_MSG(n > size(), "basic_string_view::remove_suffix: out of range."); size_ -= n; } - constexpr void swap(basic_string_view& sv) noexcept { + void swap(basic_string_view& sv) noexcept { auto tmp = *this; *this = sv; sv = tmp; @@ -564,7 +564,7 @@ class basic_string_view final { }; template -constexpr inline void swap( +inline void swap( basic_string_view& lhs, basic_string_view& rhs) noexcept { lhs.swap(rhs); diff --git a/runtime/core/portable_type/tensor_impl.cpp b/runtime/core/portable_type/tensor_impl.cpp index 74938307682..068249a8a47 100644 --- a/runtime/core/portable_type/tensor_impl.cpp +++ b/runtime/core/portable_type/tensor_impl.cpp @@ -21,13 +21,10 @@ namespace torch { namespace executor { namespace { - /** * Compute the number of elements based on the sizes of a tensor. */ -constexpr ssize_t compute_numel( - const TensorImpl::SizesType* sizes, - ssize_t dim) { +ssize_t compute_numel(const TensorImpl::SizesType* sizes, ssize_t dim) { ssize_t n = 1; for (ssize_t i = 0; i < dim; i++) { n *= sizes[i]; diff --git a/runtime/core/span.h b/runtime/core/span.h index 14b77144b45..c6dd76f7108 100644 --- a/runtime/core/span.h +++ b/runtime/core/span.h @@ -43,7 +43,7 @@ class Span final { /* implicit */ constexpr Span() noexcept : data_(nullptr), length_(0) {} /// Construct a Span from a pointer and length. - constexpr Span(T* data, size_t length) : data_(data), length_(length) { + Span(T* data, size_t length) : data_(data), length_(length) { ET_DCHECK(data_ != nullptr || length_ == 0); } diff --git a/runtime/kernel/kernel_runtime_context.h b/runtime/kernel/kernel_runtime_context.h index 4ebffbc8e45..8f9afac7a7b 100644 --- a/runtime/kernel/kernel_runtime_context.h +++ b/runtime/kernel/kernel_runtime_context.h @@ -59,6 +59,8 @@ class KernelRuntimeContext { namespace exec_aten { using RuntimeContext = torch::executor::KernelRuntimeContext; } // namespace exec_aten -namespace torch::executor { +namespace torch { +namespace executor { using RuntimeContext = torch::executor::KernelRuntimeContext; -} // namespace torch::executor +} // namespace executor +} // namespace torch diff --git a/schema/extended_header.cpp b/schema/extended_header.cpp index 9f1ac164b69..9ea2d3ca1d5 100644 --- a/schema/extended_header.cpp +++ b/schema/extended_header.cpp @@ -91,5 +91,8 @@ uint64_t GetUInt64LE(const uint8_t* data) { }; } +// Define storage for the static. +constexpr char ExtendedHeader::kMagic[kMagicSize]; + } // namespace executor } // namespace torch