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
5e28dcda
Commit
5e28dcda
authored
Sep 08, 2022
by
Po-Yen, Chen
Browse files
Add GridwisePermute::CheckValidity()
parent
0c23d6fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
include/ck/tensor_operation/gpu/device/device_permute.hpp
include/ck/tensor_operation/gpu/device/device_permute.hpp
+1
-11
include/ck/tensor_operation/gpu/grid/gridwise_permute.hpp
include/ck/tensor_operation/gpu/grid/gridwise_permute.hpp
+20
-0
No files found.
include/ck/tensor_operation/gpu/device/device_permute.hpp
View file @
5e28dcda
...
@@ -212,17 +212,7 @@ struct DevicePermute : detail::DevicePermuteBase<DevicePermute<InDataType,
...
@@ -212,17 +212,7 @@ struct DevicePermute : detail::DevicePermuteBase<DevicePermute<InDataType,
static
bool
IsSupportedArgument
(
const
Argument
&
arg
)
static
bool
IsSupportedArgument
(
const
Argument
&
arg
)
{
{
// check if only swap last 2 dimensions
return
GridwisePermute
::
CheckValidity
(
arg
.
in_grid_desc_
,
arg
.
out_grid_desc_
);
if
(
!
(
std
::
equal
(
begin
(
arg
.
inLengths_
),
std
::
prev
(
end
(
arg
.
inLengths_
),
2
),
begin
(
arg
.
outLengths_
))
&&
std
::
tie
(
*
rbegin
(
arg
.
inLengths_
),
*
std
::
next
(
rbegin
(
arg
.
inLengths_
)))
==
std
::
tie
(
*
std
::
next
(
rbegin
(
arg
.
outLengths_
)),
*
rbegin
(
arg
.
outLengths_
))))
{
return
false
;
}
return
true
;
};
};
};
};
...
...
include/ck/tensor_operation/gpu/grid/gridwise_permute.hpp
View file @
5e28dcda
...
@@ -152,6 +152,26 @@ struct GridwisePermute
...
@@ -152,6 +152,26 @@ struct GridwisePermute
return
DefaultBlock2TileMap
{
desc
};
return
DefaultBlock2TileMap
{
desc
};
}
}
__host__
__device__
static
constexpr
bool
CheckValidity
(
const
InGridDesc
&
in_grid_desc
,
const
OutGridDesc
&
out_grid_desc
)
{
constexpr
index_t
NumDim
=
InGridDesc
::
GetNumOfDimension
();
bool
valid
=
true
;
static_for
<
0
,
NumDim
-
2
,
1
>
{}([
&
](
auto
I
)
{
if
(
valid
&&
in_grid_desc
.
GetLength
(
I
)
!=
out_grid_desc
.
GetLength
(
I
))
{
valid
=
false
;
}
});
return
valid
&&
(
in_grid_desc
.
GetLength
(
Number
<
NumDim
-
1
>
{})
==
out_grid_desc
.
GetLength
(
Number
<
NumDim
-
2
>
{}))
&&
(
in_grid_desc
.
GetLength
(
Number
<
NumDim
-
2
>
{})
==
out_grid_desc
.
GetLength
(
Number
<
NumDim
-
1
>
{}));
}
template
<
typename
Block2TileMap
>
template
<
typename
Block2TileMap
>
__device__
static
void
Run
(
const
InGridDesc
in_grid_desc
,
__device__
static
void
Run
(
const
InGridDesc
in_grid_desc
,
const
OutGridDesc
out_grid_desc
,
const
OutGridDesc
out_grid_desc
,
...
...
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