Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions runtime/core/array_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/core/exec_aten/exec_aten.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 13 additions & 11 deletions runtime/core/function_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace executor {

template <typename T>
struct remove_cvref {
using type = std::remove_cv_t<std::remove_reference_t<T>>;
using type =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
};

template <typename T>
Expand Down Expand Up @@ -76,24 +77,24 @@ class FunctionRef<Ret(Params...)> {
template <
typename Callable,
// This is not the copy-constructor.
std::enable_if_t<
typename std::enable_if<
!std::is_same<remove_cvref_t<Callable>, 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<Callable, Ret (*)(Params...)>::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<Ret>::value ||
std::is_convertible<
decltype(std::declval<Callable>()(std::declval<Params>()...)),
Ret>::value,
int32_t> = 0>
int32_t>::type = 0>
explicit FunctionRef(Callable& callable)
: callback_([](const void* memory, Params... params) {
auto& storage = *static_cast<const Storage*>(memory);
Expand Down Expand Up @@ -132,12 +133,13 @@ class FunctionRef<Ret(Params...)> {
template <
typename Function,
// This is not the copy-constructor.
std::enable_if_t<!std::is_same<Function, FunctionRef>::value, int32_t> =
0,
typename std::enable_if<
!std::is_same<Function, FunctionRef>::value,
int32_t>::type = 0,
// Function is convertible to pointer of (Params...) -> Ret.
std::enable_if_t<
typename std::enable_if<
std::is_convertible<Function, Ret (*)(Params...)>::value,
int32_t> = 0>
int32_t>::type = 0>
/* implicit */ FunctionRef(const Function& function)
: FunctionRef(static_cast<Ret (*)(Params...)>(function)) {}

Expand Down
2 changes: 1 addition & 1 deletion runtime/core/portable_type/scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Scalar {

template <
typename T,
std::enable_if_t<std::is_integral<T>::value, bool> = true>
typename std::enable_if<std::is_integral<T>::value, bool>::type = true>
/*implicit*/ Scalar(T val) : tag(Tag::Int) {
v.as_int = static_cast<int64_t>(val);
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/core/portable_type/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -564,7 +564,7 @@ class basic_string_view final {
};

template <class CharT>
constexpr inline void swap(
inline void swap(
basic_string_view<CharT>& lhs,
basic_string_view<CharT>& rhs) noexcept {
lhs.swap(rhs);
Expand Down
5 changes: 1 addition & 4 deletions runtime/core/portable_type/tensor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion runtime/core/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 4 additions & 2 deletions runtime/kernel/kernel_runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions schema/extended_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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