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
c9511733
Commit
c9511733
authored
Sep 28, 2020
by
Chao Liu
Browse files
refactoring Array
parent
a289f7b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
composable_kernel/include/tensor_description/multi_index.hpp
composable_kernel/include/tensor_description/multi_index.hpp
+9
-1
composable_kernel/include/tensor_description/tensor_coordinate.hpp
...e_kernel/include/tensor_description/tensor_coordinate.hpp
+2
-2
composable_kernel/include/utility/array.hpp
composable_kernel/include/utility/array.hpp
+2
-9
No files found.
composable_kernel/include/tensor_description/multi_index.hpp
View file @
c9511733
...
...
@@ -9,12 +9,20 @@ namespace ck {
template
<
index_t
N
>
using
MultiIndex
=
Array
<
index_t
,
N
>
;
#if 1 // works
template
<
typename
...
Xs
>
__host__
__device__
constexpr
auto
make_multi_index
(
const
Xs
&
...
xs
)
{
return
make_array
<
index_t
>
(
xs
...);
return
make_array
<
const
index_t
>
(
std
::
forward
<
const
Xs
>
(
xs
)
...);
}
#else
template
<
typename
...
Xs
>
__host__
__device__
constexpr
auto
make_multi_index
(
Xs
&&
...
xs
)
{
return
make_array
<
const
index_t
>
(
std
::
forward
<
const
Xs
>
(
xs
)...);
}
#endif
#else
template
<
index_t
N
>
using
MultiIndex
=
StaticallyIndexedArray
<
index_t
,
N
>
;
...
...
composable_kernel/include/tensor_description/tensor_coordinate.hpp
View file @
c9511733
...
...
@@ -41,13 +41,13 @@ struct NativeTensorCoordinate
template
<
typename
...
Xs
>
__host__
__device__
constexpr
NativeTensorCoordinate
(
Xs
...
xs
)
:
NativeTensorCoordinate
(
I
ndex
{
xs
...
}
)
:
NativeTensorCoordinate
(
make_multi_i
ndex
(
xs
...
)
)
{
}
template
<
index_t
...
Xs
>
__host__
__device__
constexpr
NativeTensorCoordinate
(
Sequence
<
Xs
...
>
)
:
NativeTensorCoordinate
(
I
ndex
{
Xs
...
}
)
:
NativeTensorCoordinate
(
make_mutli_i
ndex
(
Xs
...
)
)
{
}
...
...
composable_kernel/include/utility/array.hpp
View file @
c9511733
...
...
@@ -45,19 +45,12 @@ struct Array<TData, 0>
__host__
__device__
static
constexpr
index_t
Size
()
{
return
0
;
}
};
#if 1
template
<
typename
X
,
typename
...
Xs
>
__host__
__device__
constexpr
auto
make_array
(
const
X
&
x
,
const
Xs
&
...
xs
)
{
return
Array
<
X
,
sizeof
...(
Xs
)
+
1
>
{{
x
,
static_cast
<
X
>
(
xs
)...}};
}
#else
template
<
typename
X
,
typename
...
Xs
>
__host__
__device__
constexpr
auto
make_array
(
X
&&
x
,
Xs
&&
...
xs
)
{
return
Array
<
remove_cv_t
<
remove_reference_t
<
X
>>
,
sizeof
...(
Xs
)
+
1
>
{{
x
,
xs
...}};
using
data_type
=
remove_cv_t
<
remove_reference_t
<
X
>>
;
return
Array
<
data_type
,
sizeof
...(
Xs
)
+
1
>
{{
std
::
forward
<
X
>
(
x
),
std
::
forward
<
Xs
>
(
xs
)...}};
}
#endif
// make empty array
template
<
typename
X
>
...
...
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