Skip to content

Commit 9ab75e0

Browse files
committed
Updated to use min/max
1 parent 1f47854 commit 9ab75e0

File tree

8 files changed

+62
-46
lines changed

8 files changed

+62
-46
lines changed

docs_input/api/math/extrema/max.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
max
44
===
55

6-
Reduces the input by the maximum values across the specified axes.
6+
Reduces the input by the maximum values across the specified axes or performs
7+
an element-wise maximum on each element in the input operators.
78

89
.. doxygenfunction:: max(const InType &in, const int (&dims)[D])
910
.. doxygenfunction:: max(const InType &in)
11+
.. doxygenfunction:: max(Op t, Op t2)
1012

1113
Examples
1214
~~~~~~~~
@@ -22,3 +24,9 @@ Examples
2224
:start-after: example-begin max-test-2
2325
:end-before: example-end max-test-2
2426
:dedent:
27+
28+
.. literalinclude:: ../../../../test/00_operators/OperatorTests.cu
29+
:language: cpp
30+
:start-after: example-begin max-el-test-1
31+
:end-before: example-end max-el-test-1
32+
:dedent:

docs_input/api/math/extrema/maximum.rst

-18
This file was deleted.

docs_input/api/math/extrema/min.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
min
44
===
55

6-
Reduces the input by the minimum values across the specified axes.
6+
Reduces the input by the minimum values across the specified axes or performs
7+
an element-wise minimum on each element in the input operators.
78

89
.. doxygenfunction:: min(const InType &in, const int (&dims)[D])
910
.. doxygenfunction:: min(const InType &in)
11+
.. doxygenfunction:: max(Op t, Op t2)
1012

1113
Examples
1214
~~~~~~~~
@@ -22,3 +24,9 @@ Examples
2224
:start-after: example-begin min-test-2
2325
:end-before: example-end min-test-2
2426
:dedent:
27+
28+
.. literalinclude:: ../../../../test/00_operators/OperatorTests.cu
29+
:language: cpp
30+
:start-after: example-begin min-el-test-1
31+
:end-before: example-end min-el-test-1
32+
:dedent:

docs_input/api/math/extrema/minimum.rst

-18
This file was deleted.

include/matx/operators/binary_operators.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ namespace matx
384384
DEFINE_BINARY_OP(operator&, detail::AndOp);
385385
DEFINE_BINARY_OP(operator^, detail::XorOp);
386386
DEFINE_BINARY_OP(pow, detail::PowOp);
387-
DEFINE_BINARY_OP(maximum, detail::MaximumOp);
387+
DEFINE_BINARY_OP(max, detail::MaximumOp);
388388
DEFINE_BINARY_OP(atan2, detail::Atan2Op);
389-
DEFINE_BINARY_OP(minimum, detail::MinimumOp);
389+
DEFINE_BINARY_OP(min, detail::MinimumOp);
390390
DEFINE_BINARY_OP(operator<, detail::LTOp);
391391
DEFINE_BINARY_OP(operator>, detail::GTOp);
392392
DEFINE_BINARY_OP(operator<=, detail::LTEOp);

include/matx/operators/max.h

+18
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ __MATX_INLINE__ auto max(const InType &in, const int (&dims)[D])
138138
return detail::MaxOp<decltype(permop), InType::Rank() - D>(permop);
139139
}
140140

141+
template <typename InType, int D>
142+
[[deprecated("Use max() instead of rmax() for reductions")]]
143+
__MATX_INLINE__ auto rmax(const InType &in, const int (&dims)[D])
144+
{
145+
static_assert(D < InType::Rank(), "reduction dimensions must be <= Rank of input");
146+
auto perm = detail::getPermuteDims<InType::Rank()>(dims);
147+
auto permop = permute(in, perm);
148+
149+
return detail::MaxOp<decltype(permop), InType::Rank() - D>(permop);
150+
}
151+
141152
/**
142153
* Compute max reduction of an operator
143154
*
@@ -156,4 +167,11 @@ __MATX_INLINE__ auto max(const InType &in)
156167
return detail::MaxOp<decltype(in), 0>(in);
157168
}
158169

170+
template <typename InType>
171+
[[deprecated("Use max() instead of rmax() for reductions")]]
172+
__MATX_INLINE__ auto rmax(const InType &in)
173+
{
174+
return detail::MaxOp<decltype(in), 0>(in);
175+
}
176+
159177
}

include/matx/operators/min.h

+18
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ __MATX_INLINE__ auto min(const InType &in, const int (&dims)[D])
138138
return detail::MinOp<decltype(permop), InType::Rank() - D>(permop);
139139
}
140140

141+
template <typename InType, int D>
142+
[[deprecated("Use min() instead of rmin() for reductions")]]
143+
__MATX_INLINE__ auto rmin(const InType &in, const int (&dims)[D])
144+
{
145+
static_assert(D < InType::Rank(), "reduction dimensions must be <= Rank of input");
146+
auto perm = detail::getPermuteDims<InType::Rank()>(dims);
147+
auto permop = permute(in, perm);
148+
149+
return detail::MinOp<decltype(permop), InType::Rank() - D>(permop);
150+
}
151+
141152
/**
142153
* Compute min reduction of an operator
143154
*
@@ -156,4 +167,11 @@ __MATX_INLINE__ auto min(const InType &in)
156167
return detail::MinOp<decltype(in), 0>(in);
157168
}
158169

170+
template <typename InType>
171+
[[deprecated("Use min() instead of rmin() for reductions")]]
172+
__MATX_INLINE__ auto rmin(const InType &in)
173+
{
174+
return detail::MinOp<decltype(in), 0>(in);
175+
}
176+
159177
}

test/00_operators/OperatorTests.cu

+6-6
Original file line numberDiff line numberDiff line change
@@ -1760,15 +1760,15 @@ TYPED_TEST(OperatorTestsNumericNonComplexAllExecs, OperatorFuncs)
17601760
tiv0() = c;
17611761
TestType d = c + 1;
17621762

1763-
// example-begin maximum-test-1
1764-
(tov0 = maximum(tiv0, d)).run(exec);
1765-
// example-end maximum-test-1
1763+
// example-begin max-el-test-1
1764+
(tov0 = max(tiv0, d)).run(exec);
1765+
// example-end max-el-test-1
17661766
cudaStreamSynchronize(0);
17671767
EXPECT_TRUE(MatXUtils::MatXTypeCompare(tov0(), std::max(c, d)));
17681768

1769-
// example-begin minimum-test-1
1770-
(tov0 = minimum(tiv0, d)).run(exec);
1771-
// example-end minimum-test-1
1769+
// example-begin min-el-test-1
1770+
(tov0 = min(tiv0, d)).run(exec);
1771+
// example-end min-el-test-1
17721772
cudaStreamSynchronize(0);
17731773
EXPECT_TRUE(MatXUtils::MatXTypeCompare(tov0(), std::min(c, d)));
17741774

0 commit comments

Comments
 (0)