Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
composable_kernel
Commits
00207401
Commit
00207401
authored
Sep 19, 2022
by
Po-Yen, Chen
Browse files
Make sure we use unsigned type for shape & indices
parent
69a88385
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
example/39_permute/common.hpp
example/39_permute/common.hpp
+4
-0
No files found.
example/39_permute/common.hpp
View file @
00207401
...
@@ -283,6 +283,8 @@ inline auto is_valid_axes(const Axes& axes)
...
@@ -283,6 +283,8 @@ inline auto is_valid_axes(const Axes& axes)
template
<
typename
Shape
>
template
<
typename
Shape
>
inline
auto
is_valid_shape
(
const
Shape
&
shape
)
->
std
::
enable_if_t
<
detail
::
is_range_v
<
Shape
>
,
bool
>
inline
auto
is_valid_shape
(
const
Shape
&
shape
)
->
std
::
enable_if_t
<
detail
::
is_range_v
<
Shape
>
,
bool
>
{
{
static_assert
(
std
::
is_unsigned_v
<
ck
::
remove_cvref_t
<
decltype
(
*
std
::
begin
(
shape
))
>>
);
using
std
::
begin
,
std
::
end
;
using
std
::
begin
,
std
::
end
;
using
std
::
empty
;
using
std
::
empty
;
return
!
empty
(
shape
)
&&
std
::
all_of
(
begin
(
shape
),
end
(
shape
),
[](
auto
dim
)
{
return
0
<
dim
;
});
return
!
empty
(
shape
)
&&
std
::
all_of
(
begin
(
shape
),
end
(
shape
),
[](
auto
dim
)
{
return
0
<
dim
;
});
...
@@ -292,6 +294,8 @@ template <typename Shape, typename Indices>
...
@@ -292,6 +294,8 @@ template <typename Shape, typename Indices>
inline
auto
is_valid_indices
(
const
Shape
&
shape
,
const
Indices
&
indices
)
inline
auto
is_valid_indices
(
const
Shape
&
shape
,
const
Indices
&
indices
)
->
std
::
enable_if_t
<
detail
::
is_sized_range_v
<
Shape
>
&&
detail
::
is_sized_range_v
<
Indices
>
,
bool
>
->
std
::
enable_if_t
<
detail
::
is_sized_range_v
<
Shape
>
&&
detail
::
is_sized_range_v
<
Indices
>
,
bool
>
{
{
static_assert
(
std
::
is_unsigned_v
<
ck
::
remove_cvref_t
<
decltype
(
*
std
::
begin
(
indices
))
>>
);
if
(
!
is_valid_shape
(
shape
))
if
(
!
is_valid_shape
(
shape
))
{
{
return
false
;
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment