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
c52c308d
Commit
c52c308d
authored
Sep 26, 2020
by
Chao Liu
Browse files
refactor MultiIndex
parent
2a358d50
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
34 deletions
+47
-34
composable_kernel/include/kernel_algorithm/dummy_dynamic_transform_v1.hpp
...l/include/kernel_algorithm/dummy_dynamic_transform_v1.hpp
+1
-5
composable_kernel/include/kernel_algorithm/dummy_dynamic_transform_v2.hpp
...l/include/kernel_algorithm/dummy_dynamic_transform_v2.hpp
+17
-17
composable_kernel/include/tensor_description/dynamic_multi_index_transform.hpp
...lude/tensor_description/dynamic_multi_index_transform.hpp
+2
-1
composable_kernel/include/tensor_description/dynamic_tensor_descriptor_v2.hpp
...clude/tensor_description/dynamic_tensor_descriptor_v2.hpp
+2
-2
composable_kernel/include/tensor_description/multi_index.hpp
composable_kernel/include/tensor_description/multi_index.hpp
+1
-1
composable_kernel/include/utility/array.hpp
composable_kernel/include/utility/array.hpp
+7
-0
composable_kernel/include/utility/statically_indexed_array.hpp
...sable_kernel/include/utility/statically_indexed_array.hpp
+9
-0
driver/include/device_dummy_dynamic_transform_v2.hpp
driver/include/device_dummy_dynamic_transform_v2.hpp
+8
-8
No files found.
composable_kernel/include/kernel_algorithm/dummy_dynamic_transform_v1.hpp
View file @
c52c308d
...
...
@@ -555,11 +555,7 @@ struct DummyDynamicTransform_v1
MultiIndex
<
2
>
idx
;
// initialize idx
for
(
index_t
i
=
0
;
i
<
2
;
++
i
)
{
idx
(
i
)
=
p_wei_global
[
get_thread_local_1d_id
()
+
i
];
}
static_for
<
0
,
2
,
1
>
{}([
&
](
auto
i
)
{
idx
(
i
)
=
p_wei_global
[
get_thread_local_1d_id
()
+
i
];
});
const
index_t
niter
=
p_wei_global
[
10
];
...
...
composable_kernel/include/kernel_algorithm/dummy_dynamic_transform_v2.hpp
View file @
c52c308d
...
...
@@ -12,10 +12,10 @@ __host__ __device__ constexpr auto
map_convolution_into_gemm_v2
(
const
WeiDesc
&
wei_k_c_y_x_global_desc
,
const
InDesc
&
in_n_c_hi_wi_global_desc
,
const
OutDesc
&
out_n_k_ho_wo_global_desc
,
const
Array
<
index_t
,
2
>
conv_strides
,
const
Array
<
index_t
,
2
>
conv_dilations
,
const
Array
<
index_t
,
2
>
in_left_pads
,
const
Array
<
index_t
,
2
>
in_right_pads
)
const
MultiIndex
<
2
>
conv_strides
,
const
MultiIndex
<
2
>
conv_dilations
,
const
MultiIndex
<
2
>
in_left_pads
,
const
MultiIndex
<
2
>
in_right_pads
)
{
constexpr
auto
i0
=
Number
<
0
>
{};
constexpr
auto
i1
=
Number
<
1
>
{};
...
...
@@ -96,10 +96,10 @@ struct DummyDynamicTransform_v2_1
const
WeiDesc
wei_k_c_y_x_global_desc
,
const
InDesc
in_n_c_hi_wi_global_desc
,
const
OutDesc
out_n_k_ho_wo_global_desc
,
const
Array
<
index_t
,
2
>
conv_strides
,
const
Array
<
index_t
,
2
>
conv_dilations
,
const
Array
<
index_t
,
2
>
in_left_pads
,
const
Array
<
index_t
,
2
>
in_right_pads
)
const
const
MultiIndex
<
2
>
conv_strides
,
const
MultiIndex
<
2
>
conv_dilations
,
const
MultiIndex
<
2
>
in_left_pads
,
const
MultiIndex
<
2
>
in_right_pads
)
const
{
const
auto
transformed_tensor_descs
=
map_convolution_into_gemm_v2
(
move
(
wei_k_c_y_x_global_desc
),
...
...
@@ -124,7 +124,7 @@ struct DummyDynamicTransform_v2_1
make_dynamic_tensor_coordinate_v2
(
in_gemmk_gemmn_global_desc
,
idx
);
const
auto
in_gemmk_gemmn_coord_step
=
make_dynamic_tensor_coordinate_step_v2
(
in_gemmk_gemmn_global_desc
,
M
ulti
I
ndex
<
2
>
{{
1
,
0
}}
);
in_gemmk_gemmn_global_desc
,
make_m
ulti
_i
ndex
(
1
,
0
)
);
#pragma unroll
for
(
index_t
i
=
0
;
i
<
10
;
++
i
)
...
...
@@ -143,10 +143,10 @@ struct DummyDynamicTransform_v2_1
const
WeiDesc
wei_k_c_y_x_global_desc
,
const
InDesc
in_n_c_hi_wi_global_desc
,
const
OutDesc
out_n_k_ho_wo_global_desc
,
const
Array
<
index_t
,
2
>
conv_strides
,
const
Array
<
index_t
,
2
>
conv_dilations
,
const
Array
<
index_t
,
2
>
in_left_pads
,
const
Array
<
index_t
,
2
>
in_right_pads
)
const
const
MultiIndex
<
2
>
conv_strides
,
const
MultiIndex
<
2
>
conv_dilations
,
const
MultiIndex
<
2
>
in_left_pads
,
const
MultiIndex
<
2
>
in_right_pads
)
const
{
const
index_t
N
=
in_n_c_hi_wi_global_desc
.
GetLength
(
0
);
const
index_t
C
=
in_n_c_hi_wi_global_desc
.
GetLength
(
1
);
...
...
@@ -262,10 +262,10 @@ struct DummyDynamicTransform_v2_1
const
WeiDesc
wei_k_c_y_x_global_desc
,
const
InDesc
in_n_c_hi_wi_global_desc
,
const
OutDesc
out_n_k_ho_wo_global_desc
,
const
Array
<
index_t
,
2
>
conv_strides
,
const
Array
<
index_t
,
2
>
conv_dilations
,
const
Array
<
index_t
,
2
>
in_left_pads
,
const
Array
<
index_t
,
2
>
in_right_pads
)
const
const
MultiIndex
<
2
>
conv_strides
,
const
MultiIndex
<
2
>
conv_dilations
,
const
MultiIndex
<
2
>
in_left_pads
,
const
MultiIndex
<
2
>
in_right_pads
)
const
{
Run_1
(
p_wei_global
,
p_in_global
,
...
...
composable_kernel/include/tensor_description/dynamic_multi_index_transform.hpp
View file @
c52c308d
...
...
@@ -279,7 +279,8 @@ struct DynamicMerge
:
low_lengths_
{
low_lengths
},
low_lengths_scan_
{
reverse_exclusive_scan_on_array
(
low_lengths
,
math
::
multiplies
<
index_t
>
{},
index_t
{
1
})},
up_lengths_
{{
reduce_on_array
(
low_lengths
,
math
::
multiplies
<
index_t
>
(),
index_t
{
1
})}}
up_lengths_
{
make_multi_index
(
reduce_on_array
(
low_lengths
,
math
::
multiplies
<
index_t
>
(),
index_t
{
1
}))}
{
static_assert
(
LowerIndex
::
Size
()
==
NDimLow
,
"wrong!"
);
}
...
...
composable_kernel/include/tensor_description/dynamic_tensor_descriptor_v2.hpp
View file @
c52c308d
...
...
@@ -178,10 +178,10 @@ struct DynamicTensorDescriptor_v2
index_t
element_space_size
)
{
// zero initialization
HiddenIndex
hidden_lengths
{{
0
}}
;
HiddenIndex
hidden_lengths
=
make_zero_multi_index
<
ndim_hidden_
>
()
;
// this is the orignal tensor element space size
hidden_lengths
(
0
)
=
element_space_size
;
hidden_lengths
(
Number
<
0
>
{}
)
=
element_space_size
;
// lengths for all other hidden dimensions
static_for
<
0
,
ntransform_
,
1
>
{}([
&
transforms
,
&
hidden_lengths
](
auto
itran
)
{
...
...
composable_kernel/include/tensor_description/multi_index.hpp
View file @
c52c308d
...
...
@@ -5,7 +5,7 @@
namespace
ck
{
#if 1
// debug
#if 1
template
<
index_t
N
>
using
MultiIndex
=
Array
<
index_t
,
N
>
;
...
...
composable_kernel/include/utility/array.hpp
View file @
c52c308d
...
...
@@ -51,6 +51,13 @@ __host__ __device__ constexpr auto make_array(const X& x, const Xs&... xs)
return
Array
<
X
,
sizeof
...(
Xs
)
+
1
>
{{
x
,
static_cast
<
X
>
(
xs
)...}};
}
// make empty array
template
<
typename
X
>
__host__
__device__
constexpr
auto
make_array
()
{
return
Array
<
X
,
0
>
{};
}
template
<
typename
TData
,
index_t
NSize
>
__host__
__device__
constexpr
auto
push_back
(
Array
<
TData
,
NSize
>&
a
,
const
TData
&
x
)
{
...
...
composable_kernel/include/utility/statically_indexed_array.hpp
View file @
c52c308d
...
...
@@ -17,6 +17,8 @@ struct StaticallyIndexedArray<TData, 0> : Tuple<>
{
using
data_type
=
TData
;
using
base
=
Tuple
<>
;
__host__
__device__
explicit
constexpr
StaticallyIndexedArray
()
:
base
()
{}
};
template
<
typename
TData
>
...
...
@@ -387,5 +389,12 @@ __host__ __device__ constexpr auto make_statically_indexed_array(const X& x, con
return
StaticallyIndexedArray
<
X
,
sizeof
...(
Xs
)
+
1
>
(
x
,
static_cast
<
X
>
(
xs
)...);
}
// make empty StaticallyIndexedArray
template
<
typename
X
>
__host__
__device__
constexpr
auto
make_statically_indexed_array
()
{
return
StaticallyIndexedArray
<
X
,
0
>
();
}
}
// namespace ck
#endif
driver/include/device_dummy_dynamic_transform_v2.hpp
View file @
c52c308d
...
...
@@ -101,10 +101,10 @@ void device_dummy_dynamic_transform_v2(InDesc,
const
decltype
(
wei_kcyx_desc
),
const
decltype
(
in_nchw_desc
),
const
decltype
(
out_nkhw_desc
),
const
Array
<
index_t
,
2
>
,
const
Array
<
index_t
,
2
>
,
const
Array
<
index_t
,
2
>
,
const
Array
<
index_t
,
2
>>
,
const
MultiIndex
<
2
>
,
const
MultiIndex
<
2
>
,
const
MultiIndex
<
2
>
,
const
MultiIndex
<
2
>>
,
dim3
(
GridSize
),
dim3
(
BlockSize
),
0
,
...
...
@@ -125,10 +125,10 @@ void device_dummy_dynamic_transform_v2(InDesc,
float
*
const
,
float
*
const
,
const
decltype
(
in_gemmk_gemmn_global_desc
),
const
Array
<
index_t
,
2
>
,
const
Array
<
index_t
,
2
>
,
const
Array
<
index_t
,
2
>
,
const
Array
<
index_t
,
2
>>
,
const
MultiIndex
<
2
>
,
const
MultiIndex
<
2
>
,
const
MultiIndex
<
2
>
,
const
MultiIndex
<
2
>>
,
dim3
(
GridSize
),
dim3
(
BlockSize
),
0
,
...
...
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