Skip to content

Commit

Permalink
Changed MAX name to not collide with other libraries (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffburdick authored Apr 5, 2022
1 parent a5e7d89 commit 8e6bb10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
18 changes: 9 additions & 9 deletions include/matx_tensor_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ inline
private:
typename detail::base_type<T1>::type cond_;
typename detail::base_type<T2>::type op_;
std::array<index_t, detail::MAX(detail::get_rank<T1>(), detail::get_rank<T2>())> size_;
std::array<index_t, detail::matx_max(detail::get_rank<T1>(), detail::get_rank<T2>())> size_;

public:
using scalar_type = void; ///< Scalar type for type extraction
Expand Down Expand Up @@ -393,7 +393,7 @@ inline
index_t size2 = detail::get_expanded_size<Rank()>(op_, i);
MATX_ASSERT(size1 == 0 || size1 == Size(i), matxInvalidSize);
MATX_ASSERT(size2 == 0 || size2 == Size(i), matxInvalidSize);
size_[i] = detail::MAX(size1, size2);
size_[i] = detail::matx_max(size1, size2);
}
}
}
Expand All @@ -418,7 +418,7 @@ inline
*/
static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
{
return detail::MAX(detail::get_rank<T1>(), detail::get_rank<T2>());
return detail::matx_max(detail::get_rank<T1>(), detail::get_rank<T2>());
}

/**
Expand Down Expand Up @@ -451,7 +451,7 @@ inline
typename detail::base_type<C1>::type cond_;
typename detail::base_type<T1>::type op1_;
typename detail::base_type<T2>::type op2_;
std::array<index_t, detail::MAX(detail::get_rank<C1>(), detail::get_rank<T1>(), detail::get_rank<T2>())> size_;
std::array<index_t, detail::matx_max(detail::get_rank<C1>(), detail::get_rank<T1>(), detail::get_rank<T2>())> size_;

public:
using scalar_type = void; ///< Scalar type for type extraction
Expand Down Expand Up @@ -482,7 +482,7 @@ inline
index_t size0 = detail::get_expanded_size<Rank()>(cond_, i);
index_t size1 = detail::get_expanded_size<Rank()>(op1, i);
index_t size2 = detail::get_expanded_size<Rank()>(op2, i);
size_[i] = detail::MAX(size0, size1, size2);
size_[i] = detail::matx_max(size0, size1, size2);
MATX_ASSERT(size0 == 0 || size0 == Size(i), matxInvalidSize);
MATX_ASSERT(size1 == 0 || size1 == Size(i), matxInvalidSize);
MATX_ASSERT(size2 == 0 || size2 == Size(i), matxInvalidSize);
Expand Down Expand Up @@ -513,7 +513,7 @@ inline
*/
static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
{
return detail::MAX(detail::get_rank<C1>(), detail::get_rank<T1>(), detail::get_rank<T2>());
return detail::matx_max(detail::get_rank<C1>(), detail::get_rank<T1>(), detail::get_rank<T2>());
}

/**
Expand Down Expand Up @@ -1880,7 +1880,7 @@ auto __MATX_INLINE__ as_uint8(T t)
typename base_type<I1>::type in1_;
typename base_type<I2>::type in2_;
typename base_type<Op>::type op_;
std::array<index_t, detail::MAX(detail::get_rank<I1>(), detail::get_rank<I2>())> size_;
std::array<index_t, detail::matx_max(detail::get_rank<I1>(), detail::get_rank<I2>())> size_;

public:
// dummy type to signal this is a matxop
Expand All @@ -1894,7 +1894,7 @@ auto __MATX_INLINE__ as_uint8(T t)
{
index_t size1 = detail::get_expanded_size<Rank()>(in1_, i);
index_t size2 = detail::get_expanded_size<Rank()>(in2_, i);
size_[i] = detail::MAX(size1, size2);
size_[i] = detail::matx_max(size1, size2);
MATX_ASSERT(size1 == 0 || size1 == Size(i), matxInvalidSize);
MATX_ASSERT(size2 == 0 || size2 == Size(i), matxInvalidSize);
}
Expand All @@ -1912,7 +1912,7 @@ auto __MATX_INLINE__ as_uint8(T t)

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
{
return detail::MAX(detail::get_rank<I1>(), detail::get_rank<I2>());
return detail::matx_max(detail::get_rank<I1>(), detail::get_rank<I2>());
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ auto Size(int dim) const noexcept
Expand Down
18 changes: 8 additions & 10 deletions include/matx_tensor_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,16 @@ namespace detail {
make_index_sequence_rev<std::tuple_size_v<std::remove_reference_t<Tuple>>>{});
}
}

template <typename T>
__MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ T MAX(T a)
{
return a;
}

template <typename T, typename... Args>
__MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ T MAX(T a, Args... args)
template <typename T0, typename T1, typename... Tn>
constexpr auto matx_max(T0 &&t0, T1 &&t1, Tn &&... tn)
{
auto v = MAX(args...);
return (a >= v) ? a : v;
if constexpr (sizeof...(tn) == 0) {
return t0 > t1 ? t0 : t1;
}
else {
return matx_max(matx_max(t0, t1), tn...);
}
}

template <class T, class M = T>
Expand Down

0 comments on commit 8e6bb10

Please sign in to comment.