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
3549e344
"tests/pipelines/vscode:/vscode.git/clone" did not exist on "707b8684b3476cde8f63718f7e9b2daf3612302d"
Commit
3549e344
authored
Jul 25, 2022
by
Chao Liu
Browse files
adding group
parent
c0bfcf91
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
878 additions
and
298 deletions
+878
-298
example/09_convnd_fwd/convnd_fwd_common.hpp
example/09_convnd_fwd/convnd_fwd_common.hpp
+11
-65
example/09_convnd_fwd/convnd_fwd_xdl_fp16.cpp
example/09_convnd_fwd/convnd_fwd_xdl_fp16.cpp
+40
-21
include/ck/tensor_operation/gpu/device/device_conv_fwd_multiple_d_xdl_cshuffle.hpp
...on/gpu/device/device_conv_fwd_multiple_d_xdl_cshuffle.hpp
+410
-119
include/ck/tensor_operation/gpu/device/tensor_layout.hpp
include/ck/tensor_operation/gpu/device/tensor_layout.hpp
+213
-27
library/include/ck/library/reference_tensor_operation/cpu/reference_conv_fwd.hpp
...ary/reference_tensor_operation/cpu/reference_conv_fwd.hpp
+1
-6
library/include/ck/library/utility/convolution_host_tensor_descriptor_helper.hpp
...ary/utility/convolution_host_tensor_descriptor_helper.hpp
+190
-60
library/include/ck/library/utility/host_tensor.hpp
library/include/ck/library/utility/host_tensor.hpp
+13
-0
No files found.
example/09_convnd_fwd/convnd_fwd_common.hpp
View file @
3549e344
...
@@ -112,50 +112,14 @@ int run_conv_fwd(bool do_verification,
...
@@ -112,50 +112,14 @@ int run_conv_fwd(bool do_verification,
const
WeiElementOp
&
wei_element_op
,
const
WeiElementOp
&
wei_element_op
,
const
OutElementOp
&
out_element_op
)
const
OutElementOp
&
out_element_op
)
{
{
#if 0
const
auto
in_g_n_c_wis_desc
=
const auto in_g_n_c_wis_desc = ck::utils::conv::get_input_host_tensor_descriptor<InLayout>(conv_param);
ck
::
utils
::
conv
::
make_input_host_tensor_descriptor_packed
<
InLayout
>
(
conv_param
);
const auto wei_g_k_c_xs_desc = ck::utils::conv::get_weight_host_tensor_descriptor<WeiLayout>(conv_param);
const
auto
wei_g_k_c_xs_desc
=
const auto out_g_n_k_wos_desc = ck::utils::conv::get_output_host_tensor_descriptor<OutLayout>(conv_param);
ck
::
utils
::
conv
::
make_weight_host_tensor_descriptor_packed
<
WeiLayout
>
(
conv_param
);
#else
const
auto
bias_g_n_k_wos_desc
=
const
auto
in_g_n_wis_c_desc
=
HostTensorDescriptor
(
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_packed
<
OutLayout
>
(
conv_param
);
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
conv_param
.
G_
),
const
auto
out_g_n_k_wos_desc
=
static_cast
<
std
::
size_t
>
(
conv_param
.
N_
),
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_packed
<
OutLayout
>
(
conv_param
);
static_cast
<
std
::
size_t
>
(
conv_param
.
input_spatial_lengths_
[
0
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
input_spatial_lengths_
[
1
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
C_
)});
const
auto
wei_g_k_xs_c_desc
=
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
conv_param
.
G_
),
static_cast
<
std
::
size_t
>
(
conv_param
.
K_
),
static_cast
<
std
::
size_t
>
(
conv_param
.
filter_spatial_lengths_
[
0
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
filter_spatial_lengths_
[
1
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
C_
)});
const
auto
bias_g_n_wos_k_desc
=
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
conv_param
.
G_
),
static_cast
<
std
::
size_t
>
(
conv_param
.
N_
),
static_cast
<
std
::
size_t
>
(
conv_param
.
output_spatial_lengths_
[
0
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
output_spatial_lengths_
[
1
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
K_
)},
std
::
vector
<
std
::
size_t
>
{
0
,
0
,
0
,
0
,
1
});
const
auto
out_g_n_wos_k_desc
=
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
conv_param
.
G_
),
static_cast
<
std
::
size_t
>
(
conv_param
.
N_
),
static_cast
<
std
::
size_t
>
(
conv_param
.
output_spatial_lengths_
[
0
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
output_spatial_lengths_
[
1
]),
static_cast
<
std
::
size_t
>
(
conv_param
.
K_
)});
// tensor descriptor in NCHW/KXYC/NKHW dimensional order
const
auto
in_g_n_c_wis_desc
=
transpose_host_tensor_descriptor_given_new2old
(
in_g_n_wis_c_desc
,
std
::
vector
<
ck
::
index_t
>
{
0
,
1
,
4
,
2
,
3
});
const
auto
wei_g_k_c_xs_desc
=
transpose_host_tensor_descriptor_given_new2old
(
wei_g_k_xs_c_desc
,
std
::
vector
<
ck
::
index_t
>
{
0
,
1
,
4
,
2
,
3
});
const
auto
bias_g_n_k_wos_desc
=
transpose_host_tensor_descriptor_given_new2old
(
bias_g_n_wos_k_desc
,
std
::
vector
<
ck
::
index_t
>
{
0
,
1
,
4
,
2
,
3
});
const
auto
out_g_n_k_wos_desc
=
transpose_host_tensor_descriptor_given_new2old
(
out_g_n_wos_k_desc
,
std
::
vector
<
ck
::
index_t
>
{
0
,
1
,
4
,
2
,
3
});
#endif
Tensor
<
InDataType
>
in
(
in_g_n_c_wis_desc
);
Tensor
<
InDataType
>
in
(
in_g_n_c_wis_desc
);
Tensor
<
WeiDataType
>
wei
(
wei_g_k_c_xs_desc
);
Tensor
<
WeiDataType
>
wei
(
wei_g_k_c_xs_desc
);
...
@@ -267,9 +231,6 @@ int run_conv_fwd(bool do_verification,
...
@@ -267,9 +231,6 @@ int run_conv_fwd(bool do_verification,
Tensor
<
OutDataType
>
c_host
(
out_g_n_k_wos_desc
);
Tensor
<
OutDataType
>
c_host
(
out_g_n_k_wos_desc
);
auto
ref_conv
=
ck
::
tensor_operation
::
host
::
ReferenceConvFwd
<
NDimSpatial
,
auto
ref_conv
=
ck
::
tensor_operation
::
host
::
ReferenceConvFwd
<
NDimSpatial
,
InLayout
,
WeiLayout
,
OutLayout
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
...
@@ -291,24 +252,9 @@ int run_conv_fwd(bool do_verification,
...
@@ -291,24 +252,9 @@ int run_conv_fwd(bool do_verification,
ref_invoker
.
Run
(
ref_argument
);
ref_invoker
.
Run
(
ref_argument
);
for
(
int
g
=
0
;
g
<
out_host
.
mDesc
.
GetLengths
()[
0
];
g
++
)
// TODO: implement elementwise operation for host
{
out_host
.
ForEach
(
for
(
int
n
=
0
;
n
<
out_host
.
mDesc
.
GetLengths
()[
1
];
n
++
)
[
&
](
auto
&
,
auto
idx
)
{
out_element_op
(
out_host
(
idx
),
c_host
(
idx
),
bias
(
idx
));
});
{
for
(
int
k
=
0
;
k
<
out_host
.
mDesc
.
GetLengths
()[
2
];
k
++
)
{
for
(
int
ho
=
0
;
ho
<
out_host
.
mDesc
.
GetLengths
()[
3
];
ho
++
)
{
for
(
int
wo
=
0
;
wo
<
out_host
.
mDesc
.
GetLengths
()[
4
];
wo
++
)
{
out_element_op
(
out_host
(
g
,
n
,
k
,
ho
,
wo
),
c_host
(
g
,
n
,
k
,
ho
,
wo
),
bias
(
g
,
n
,
k
,
ho
,
wo
));
}
}
}
}
}
out_device_buf
.
FromDevice
(
out_device
.
mData
.
data
());
out_device_buf
.
FromDevice
(
out_device
.
mData
.
data
());
...
...
example/09_convnd_fwd/convnd_fwd_xdl_fp16.cpp
View file @
3549e344
...
@@ -71,22 +71,41 @@ static constexpr auto GemmSpec = ck::tensor_operation::device::GemmSpecializatio
...
@@ -71,22 +71,41 @@ static constexpr auto GemmSpec = ck::tensor_operation::device::GemmSpecializatio
template
<
ck
::
index_t
NDimSpatial
>
template
<
ck
::
index_t
NDimSpatial
>
using
DeviceConvNDFwdInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvFwdMultipleD_Xdl_CShuffle
<
using
DeviceConvNDFwdInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvFwdMultipleD_Xdl_CShuffle
<
NDimSpatial
,
NDimSpatial
,
#if 0
ck::tuple_element_t<NDimSpatial - 1,
ck::tuple_element_t<NDimSpatial - 1,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
NWC
,
ck::Tuple<ck::tensor_layout::convolution::
G_
NW
_
C,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck::tensor_layout::convolution::
G_
NHW
_
C,
ck
::
tensor_layout
::
convolution
::
NDHWC
>>
,
ck::tensor_layout::convolution::
G_
NDHW
_
C>>,
ck::tuple_element_t<NDimSpatial - 1,
ck::tuple_element_t<NDimSpatial - 1,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
KX
C
,
ck::Tuple<ck::tensor_layout::convolution::
G_K_X_
C,
ck
::
tensor_layout
::
convolution
::
K
YXC
,
ck::tensor_layout::convolution::
G_K_
YX
_
C,
ck
::
tensor_layout
::
convolution
::
K
ZYXC
>>
,
ck::tensor_layout::convolution::
G_K_
ZYX
_
C>>,
ck::Tuple<ck::tuple_element_t<NDimSpatial - 1,
ck::Tuple<ck::tuple_element_t<NDimSpatial - 1,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
NW_K
,
ck::Tuple<ck::tensor_layout::convolution::G_NW_K,
ck
::
tensor_layout
::
convolution
::
NHW_K
,
ck::tensor_layout::convolution::G_NHW_K,
ck
::
tensor_layout
::
convolution
::
NDHW_K
>>>
,
ck::tensor_layout::convolution::G_NDHW_K>>>,
ck::tuple_element_t<NDimSpatial - 1,
ck::Tuple<ck::tensor_layout::convolution::G_NW_K,
ck::tensor_layout::convolution::G_NHW_K,
ck::tensor_layout::convolution::G_NDHW_K>>,
#else
ck
::
tuple_element_t
<
NDimSpatial
-
1
,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
NWGC
,
ck
::
tensor_layout
::
convolution
::
NHWGC
,
ck
::
tensor_layout
::
convolution
::
NDHWGC
>>
,
ck
::
tuple_element_t
<
NDimSpatial
-
1
,
ck
::
tuple_element_t
<
NDimSpatial
-
1
,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
KXGC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_layout
::
convolution
::
KYXGC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>>
,
ck
::
tensor_layout
::
convolution
::
KZYXGC
>>
,
ck
::
Tuple
<
ck
::
tuple_element_t
<
NDimSpatial
-
1
,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
NWGK
,
ck
::
tensor_layout
::
convolution
::
NHWGK
,
ck
::
tensor_layout
::
convolution
::
NDHWGK
>>>
,
ck
::
tuple_element_t
<
NDimSpatial
-
1
,
ck
::
Tuple
<
ck
::
tensor_layout
::
convolution
::
NWGK
,
ck
::
tensor_layout
::
convolution
::
NHWGK
,
ck
::
tensor_layout
::
convolution
::
NDHWGK
>>
,
#endif
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
AccDataType
,
AccDataType
,
...
@@ -167,9 +186,9 @@ int main(int argc, char* argv[])
...
@@ -167,9 +186,9 @@ int main(int argc, char* argv[])
if
(
num_dim_spatial
==
1
)
if
(
num_dim_spatial
==
1
)
{
{
return
run_conv_fwd
<
1
,
return
run_conv_fwd
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NW
G
C
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KX
G
C
,
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
tensor_layout
::
convolution
::
NW
G
K
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
...
@@ -187,9 +206,9 @@ int main(int argc, char* argv[])
...
@@ -187,9 +206,9 @@ int main(int argc, char* argv[])
else
if
(
num_dim_spatial
==
2
)
else
if
(
num_dim_spatial
==
2
)
{
{
return
run_conv_fwd
<
2
,
return
run_conv_fwd
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
NHW
G
C
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
KYX
G
C
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_layout
::
convolution
::
NHW
G
K
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
...
@@ -207,9 +226,9 @@ int main(int argc, char* argv[])
...
@@ -207,9 +226,9 @@ int main(int argc, char* argv[])
else
if
(
num_dim_spatial
==
3
)
else
if
(
num_dim_spatial
==
3
)
{
{
return
run_conv_fwd
<
3
,
return
run_conv_fwd
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHW
G
C
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
KZYX
G
C
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
tensor_layout
::
convolution
::
NDHW
G
K
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
...
...
include/ck/tensor_operation/gpu/device/device_conv_fwd_multiple_d_xdl_cshuffle.hpp
View file @
3549e344
This diff is collapsed.
Click to expand it.
include/ck/tensor_operation/gpu/device/tensor_layout.hpp
View file @
3549e344
...
@@ -25,6 +25,39 @@ struct ColumnMajor : public BaseTensorLayout
...
@@ -25,6 +25,39 @@ struct ColumnMajor : public BaseTensorLayout
namespace
convolution
{
namespace
convolution
{
// input tensor
// packed NCW/NCHW/NCDHW
struct
NCW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NCW"
;
};
struct
NCHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NCHW"
;
};
struct
NCDHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NCDHW"
;
};
// packed GNCW/GNCHW/GNCDHW
struct
GNCW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GNCW"
;
};
struct
GNCHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GNCHW"
;
};
struct
GNCDHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GNCDHW"
;
};
// input tensor
// input tensor
// packed NWC/NHWC/NDHWC
// packed NWC/NHWC/NDHWC
struct
NWC
:
public
BaseTensorLayout
struct
NWC
:
public
BaseTensorLayout
...
@@ -43,20 +76,88 @@ struct NDHWC : public BaseTensorLayout
...
@@ -43,20 +76,88 @@ struct NDHWC : public BaseTensorLayout
};
};
// input tensor
// input tensor
// packed
NCW/NCHW/NC
DHW
// packed
GNWC/GNHWC/GN
DHW
C
struct
NCW
:
public
BaseTensorLayout
struct
GNWC
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"
NCW
"
;
static
constexpr
const
char
*
name
=
"
GNWC
"
;
};
};
struct
N
C
HW
:
public
BaseTensorLayout
struct
G
NHW
C
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"N
C
HW"
;
static
constexpr
const
char
*
name
=
"
G
NHW
C
"
;
};
};
struct
N
C
DHW
:
public
BaseTensorLayout
struct
G
NDHW
C
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"NCDHW"
;
static
constexpr
const
char
*
name
=
"GNDHWC"
;
};
// input tensor
// packed GNWC/GNHWC/GNDHWC
struct
NWGC
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NWGC"
;
};
struct
NHWGC
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NHWGC"
;
};
struct
NDHWGC
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NDHWGC"
;
};
// input tensor
// strided layout
struct
G_NW_C
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"G_NW_C"
;
};
struct
G_NHW_C
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"G_NHW_C"
;
};
struct
G_NDHW_C
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"G_NDHW_C"
;
};
// weight tensor
// packed KCX/KCYX/KCZYX
struct
KCX
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"KCX"
;
};
struct
KCYX
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"KCYX"
;
};
struct
KCZYX
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"KCZYX"
;
};
// weight tensor
// packed KCX/KCYX/KCZYX
struct
GKCX
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GKCX"
;
};
struct
GKCYX
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GKCYX"
;
};
struct
GKCZYX
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GKCZYX"
;
};
};
// weight tensor
// weight tensor
...
@@ -77,20 +178,88 @@ struct KZYXC : public BaseTensorLayout
...
@@ -77,20 +178,88 @@ struct KZYXC : public BaseTensorLayout
};
};
// weight tensor
// weight tensor
// packed
KCX/KCYX/KC
ZYX
// packed
GKXC/GKYXC/GK
ZYX
C
struct
KCX
:
public
BaseTensorLayout
struct
GKXC
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"
KCX
"
;
static
constexpr
const
char
*
name
=
"
GKXC
"
;
};
};
struct
K
C
YX
:
public
BaseTensorLayout
struct
G
KYX
C
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"K
C
YX"
;
static
constexpr
const
char
*
name
=
"
G
KYX
C
"
;
};
};
struct
K
C
ZYX
:
public
BaseTensorLayout
struct
G
KZYX
C
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"KCZYX"
;
static
constexpr
const
char
*
name
=
"GKZYXC"
;
};
// weight tensor
// packed KXGC/KYXGC/KZYXGC
struct
KXGC
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"KXGC"
;
};
struct
KYXGC
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"KYXGC"
;
};
struct
KZYXGC
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"KZYXGC"
;
};
// weight tensor
// strided
struct
G_K_X_C
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"G_K_X_C"
;
};
struct
G_K_YX_C
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"G_K_YX_C"
;
};
struct
G_K_ZYX_C
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"G_K_ZYX_C"
;
};
// output tensor
// packed NKW/NKHW/NKDHW
struct
NKW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NKW"
;
};
struct
NKHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NKHW"
;
};
struct
NKDHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NKDHW"
;
};
// output tensor
// packed GNKW/GNKHW/GNKDHW
struct
GNKW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GNKW"
;
};
struct
GNKHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GNKHW"
;
};
struct
GNKDHW
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"GNKDHW"
;
};
};
// output tensor
// output tensor
...
@@ -111,37 +280,54 @@ struct NDHWK : public BaseTensorLayout
...
@@ -111,37 +280,54 @@ struct NDHWK : public BaseTensorLayout
};
};
// output tensor
// output tensor
// packed
NKW/NKHW/NK
DHW
// packed
GNWK/GNHWK/GN
DHW
K
struct
NKW
:
public
BaseTensorLayout
struct
GNWK
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"
NKW
"
;
static
constexpr
const
char
*
name
=
"
GNWK
"
;
};
};
struct
N
K
HW
:
public
BaseTensorLayout
struct
G
NHW
K
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"N
K
HW"
;
static
constexpr
const
char
*
name
=
"
G
NHW
K
"
;
};
};
struct
N
K
DHW
:
public
BaseTensorLayout
struct
G
NDHW
K
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"NKDHW"
;
static
constexpr
const
char
*
name
=
"GNDHWK"
;
};
// output tensor
// packed NWGK/NHWGK/NDHWGK
struct
NWGK
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NWGK"
;
};
struct
NHWGK
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NHWGK"
;
};
struct
NDHWGK
:
public
BaseTensorLayout
{
static
constexpr
const
char
*
name
=
"NDHWGK"
;
};
};
// output tensor
// output tensor
// strided layout
// strided layout
struct
NW_K
:
public
BaseTensorLayout
struct
G_
NW_K
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"NW_K"
;
static
constexpr
const
char
*
name
=
"
G_
NW_K"
;
};
};
struct
NHW_K
:
public
BaseTensorLayout
struct
G_
NHW_K
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"NHW_K"
;
static
constexpr
const
char
*
name
=
"
G_
NHW_K"
;
};
};
struct
NDHW_K
:
public
BaseTensorLayout
struct
G_
NDHW_K
:
public
BaseTensorLayout
{
{
static
constexpr
const
char
*
name
=
"NDHW_K"
;
static
constexpr
const
char
*
name
=
"
G_
NDHW_K"
;
};
};
}
// namespace convolution
}
// namespace convolution
...
...
library/include/ck/library/reference_tensor_operation/cpu/reference_conv_fwd.hpp
View file @
3549e344
...
@@ -30,12 +30,8 @@ namespace host {
...
@@ -30,12 +30,8 @@ namespace host {
// operation.
// operation.
// @tparam NumDimSpatial Number of spatial dimensions.
// @tparam NumDimSpatial Number of spatial dimensions.
//
//
// FIXME: only support NDimSpatial = 1 to 3; only support NCHW and NHWC layout.
// tensor descriptor in GNCHW/GKCXY/GNKHW dimensional order
// Need to be more general
template
<
ck
::
index_t
NumDimSpatial
,
template
<
ck
::
index_t
NumDimSpatial
,
typename
InLayout
,
typename
WeiLayout
,
typename
OutLayout
,
typename
InDataType
,
typename
InDataType
,
typename
WeiDataType
,
typename
WeiDataType
,
typename
OutDataType
,
typename
OutDataType
,
...
@@ -91,7 +87,6 @@ struct ReferenceConvFwd : public device::BaseOperator
...
@@ -91,7 +87,6 @@ struct ReferenceConvFwd : public device::BaseOperator
float
Run
(
const
Argument
&
arg
)
float
Run
(
const
Argument
&
arg
)
{
{
// tensor descriptor in NCHW/KXYC/NKHW dimensional order
if
constexpr
(
NumDimSpatial
==
1
)
if
constexpr
(
NumDimSpatial
==
1
)
{
{
auto
func
=
[
&
](
auto
g
,
auto
n
,
auto
k
,
auto
wo
)
{
auto
func
=
[
&
](
auto
g
,
auto
n
,
auto
k
,
auto
wo
)
{
...
...
library/include/ck/library/utility/convolution_host_tensor_descriptor_helper.hpp
View file @
3549e344
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#pragma once
#pragma once
#include "ck/ck.hpp"
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/library/utility/convolution_parameter.hpp"
#include "ck/library/utility/convolution_parameter.hpp"
...
@@ -11,109 +12,238 @@ namespace ck {
...
@@ -11,109 +12,238 @@ namespace ck {
namespace
utils
{
namespace
utils
{
namespace
conv
{
namespace
conv
{
template
<
typename
InLayout
>
namespace
detail
{
HostTensorDescriptor
get_input_host_tensor_descriptor
(
const
ck
::
utils
::
conv
::
ConvParam
&
param
)
template
<
typename
OldLayout
>
std
::
vector
<
std
::
size_t
>
get_layout_transpose_gnchw_to_old
()
{
{
if
constexpr
(
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NWC
>
||
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNCW
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NHWC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GKCX
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NDHWC
>
)
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNKW
>
)
{
return
{
0
,
1
,
2
,
3
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNCHW
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GKCYX
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNKHW
>
)
{
return
{
0
,
1
,
2
,
3
,
4
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNCDHW
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GKCZYX
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNKDHW
>
)
{
return
{
0
,
1
,
2
,
3
,
4
,
5
};
}
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNWC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GKXC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNWK
>
)
{
return
{
0
,
1
,
3
,
2
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNHWC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GKYXC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNHWK
>
)
{
return
{
0
,
1
,
4
,
2
,
3
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNDHWC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GKZYXC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
GNDHWK
>
)
{
return
{
0
,
1
,
5
,
2
,
3
,
4
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
NWGC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
KXGC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
NWGK
>
)
{
return
{
2
,
0
,
3
,
1
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
NHWGC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
KYXGC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
NHWGK
>
)
{
return
{
3
,
0
,
4
,
1
,
2
};
}
else
if
constexpr
(
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
NDHWGC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
KZYXGC
>
||
ck
::
is_same_v
<
OldLayout
,
ck
::
tensor_layout
::
convolution
::
NDHWGK
>
)
{
return
{
4
,
0
,
5
,
1
,
2
,
3
};
}
else
{
{
std
::
vector
<
std
::
size_t
>
nhwc_lengths
{
static_cast
<
std
::
size_t
>
(
param
.
N_
),
printf
(
"%s
\n
"
,
__func__
);
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
}
}
nhwc_lengths
.
insert
(
nhwc_lengths
.
begin
()
+
1
,
}
// namespace detail
param
.
input_spatial_lengths_
.
begin
(),
param
.
input_spatial_lengths_
.
end
());
// make tensor descriptor for packed input tensor, and order the dimension in the order of GNCHW
// regardless of physical layout
template
<
typename
InLayout
>
HostTensorDescriptor
make_input_host_tensor_descriptor_packed
(
const
ck
::
utils
::
conv
::
ConvParam
&
param
)
{
std
::
vector
<
std
::
size_t
>
physical_lengths
;
return
HostTensorDescriptor
(
nhwc_lengths
);
if
constexpr
(
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
GNCW
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
GNCHW
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
GNCDHW
>
)
{
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
physical_lengths
.
insert
(
physical_lengths
.
end
(),
param
.
input_spatial_lengths_
.
begin
(),
param
.
input_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
}
else
if
constexpr
(
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NCW
>
||
else
if
constexpr
(
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
GNWC
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
N
C
HW
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
G
NHW
C
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
N
C
DHW
>
)
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
G
NDHW
C
>
)
{
{
std
::
vector
<
std
::
size_t
>
nchw_lengths
{
static_cast
<
std
::
size_t
>
(
param
.
N_
),
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
nchw_lengths
.
insert
(
nchw_lengths
.
end
(),
physical_lengths
.
insert
(
physical_lengths
.
begin
()
+
2
,
param
.
input_spatial_lengths_
.
begin
(),
param
.
input_spatial_lengths_
.
begin
(),
param
.
input_spatial_lengths_
.
end
());
param
.
input_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
else
if
constexpr
(
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NWGC
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NHWGC
>
||
ck
::
is_same_v
<
InLayout
,
ck
::
tensor_layout
::
convolution
::
NDHWGC
>
)
{
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
return
HostTensorDescriptor
(
nchw_lengths
);
physical_lengths
.
insert
(
physical_lengths
.
begin
()
+
1
,
param
.
input_spatial_lengths_
.
begin
(),
param
.
input_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
}
else
else
{
{
printf
(
"%s
\n
"
,
__func__
);
printf
(
"%s
\n
"
,
InLayout
::
name
);
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
}
}
return
transpose_host_tensor_descriptor_given_new2old
(
HostTensorDescriptor
(
physical_lengths
),
detail
::
get_layout_transpose_gnchw_to_old
<
InLayout
>
());
}
}
// make tensor descriptor for packed weight tensor, and order the dimension in the order of GKCYX
// regardless of physical layout
template
<
typename
WeiLayout
>
template
<
typename
WeiLayout
>
HostTensorDescriptor
get_weight_host_tensor_descriptor
(
const
ck
::
utils
::
conv
::
ConvParam
&
param
)
HostTensorDescriptor
make_weight_host_tensor_descriptor_packed
(
const
ck
::
utils
::
conv
::
ConvParam
&
param
)
{
{
if
constexpr
(
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KXC
>
||
std
::
vector
<
std
::
size_t
>
physical_lengths
;
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KYXC
>
||
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KZYXC
>
)
{
std
::
vector
<
std
::
size_t
>
kyxc_lengths
{
static_cast
<
std
::
size_t
>
(
param
.
K_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
kyxc_lengths
.
insert
(
kyxc_lengths
.
begin
()
+
1
,
if
constexpr
(
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
GKCX
>
||
param
.
filter_spatial_lengths_
.
begin
(),
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
GKCYX
>
||
param
.
filter_spatial_lengths_
.
end
());
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
GKCZYX
>
)
{
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
K_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
return
HostTensorDescriptor
(
kyxc_lengths
);
physical_lengths
.
insert
(
physical_lengths
.
end
(),
param
.
filter_spatial_lengths_
.
begin
(),
param
.
filter_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
}
else
if
constexpr
(
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
K
C
X
>
||
else
if
constexpr
(
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KX
C
>
||
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
K
C
YX
>
||
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KYX
C
>
||
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
K
C
ZYX
>
)
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KZYX
C
>
)
{
{
std
::
vector
<
std
::
size_t
>
kcyx_lengths
{
static_cast
<
std
::
size_t
>
(
param
.
K_
),
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
static_cast
<
std
::
size_t
>
(
param
.
K_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
kcyx_lengths
.
insert
(
kcyx_lengths
.
end
(),
physical_lengths
.
insert
(
physical_lengths
.
begin
()
+
2
,
param
.
filter_spatial_lengths_
.
begin
(),
param
.
filter_spatial_lengths_
.
begin
(),
param
.
filter_spatial_lengths_
.
end
());
param
.
filter_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
else
if
constexpr
(
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KXGC
>
||
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KYXGC
>
||
ck
::
is_same_v
<
WeiLayout
,
ck
::
tensor_layout
::
convolution
::
KZYXGC
>
)
{
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
K_
),
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
C_
)};
return
HostTensorDescriptor
(
kcyx_lengths
);
physical_lengths
.
insert
(
physical_lengths
.
begin
()
+
1
,
param
.
filter_spatial_lengths_
.
begin
(),
param
.
filter_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
}
else
else
{
{
printf
(
"%s
\n
"
,
__func__
);
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
}
}
return
transpose_host_tensor_descriptor_given_new2old
(
HostTensorDescriptor
(
physical_lengths
),
detail
::
get_layout_transpose_gnchw_to_old
<
WeiLayout
>
());
}
}
// make tensor descriptor for packed output tensor, and order the dimension in the order of GNKHW
// regardless of physical layout
template
<
typename
OutLayout
>
template
<
typename
OutLayout
>
HostTensorDescriptor
get_output_host_tensor_descriptor
(
const
ck
::
utils
::
conv
::
ConvParam
&
param
)
HostTensorDescriptor
make_output_host_tensor_descriptor_packed
(
const
ck
::
utils
::
conv
::
ConvParam
&
param
)
{
{
if
constexpr
(
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NWK
>
||
std
::
vector
<
std
::
size_t
>
physical_lengths
;
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
||
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
)
{
std
::
vector
<
std
::
size_t
>
nhwk_lengths
{
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
K_
)};
nhwk_lengths
.
insert
(
nhwk_lengths
.
begin
()
+
1
,
if
constexpr
(
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
GNKW
>
||
param
.
output_spatial_lengths_
.
begin
(),
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
GNKHW
>
||
param
.
output_spatial_lengths_
.
end
());
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
GNKDHW
>
)
{
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
K_
)};
return
HostTensorDescriptor
(
nhwk_lengths
);
physical_lengths
.
insert
(
physical_lengths
.
end
(),
param
.
output_spatial_lengths_
.
begin
(),
param
.
output_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
}
else
if
constexpr
(
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NKW
>
||
else
if
constexpr
(
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
GNWK
>
||
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
N
K
HW
>
||
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
G
NHW
K
>
||
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
N
K
DHW
>
)
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
G
NDHW
K
>
)
{
{
std
::
vector
<
std
::
size_t
>
nkhw_lengths
{
static_cast
<
std
::
size_t
>
(
param
.
N_
),
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
K_
)};
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
K_
)};
nkhw_lengths
.
insert
(
nkhw_lengths
.
end
(),
physical_lengths
.
insert
(
physical_lengths
.
begin
()
+
2
,
param
.
output_spatial_lengths_
.
begin
(),
param
.
output_spatial_lengths_
.
begin
(),
param
.
output_spatial_lengths_
.
end
());
param
.
output_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
else
if
constexpr
(
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NWGK
>
||
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NHWGK
>
||
ck
::
is_same_v
<
OutLayout
,
ck
::
tensor_layout
::
convolution
::
NDHWGK
>
)
{
physical_lengths
=
std
::
vector
<
std
::
size_t
>
{
static_cast
<
std
::
size_t
>
(
param
.
N_
),
static_cast
<
std
::
size_t
>
(
param
.
G_
),
static_cast
<
std
::
size_t
>
(
param
.
K_
)};
return
HostTensorDescriptor
(
nkhw_lengths
);
physical_lengths
.
insert
(
physical_lengths
.
begin
()
+
1
,
param
.
output_spatial_lengths_
.
begin
(),
param
.
output_spatial_lengths_
.
begin
()
+
param
.
num_dim_spatial_
);
}
}
else
else
{
{
printf
(
"%s
\n
"
,
__func__
);
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
throw
std
::
runtime_error
(
"wrong! unsupported layout"
);
}
}
return
transpose_host_tensor_descriptor_given_new2old
(
HostTensorDescriptor
(
physical_lengths
),
detail
::
get_layout_transpose_gnchw_to_old
<
OutLayout
>
());
}
}
}
// namespace conv
}
// namespace conv
...
...
library/include/ck/library/utility/host_tensor.hpp
View file @
3549e344
...
@@ -358,6 +358,19 @@ struct Tensor
...
@@ -358,6 +358,19 @@ struct Tensor
mDesc
.
GetLengths
()[
4
])(
num_thread
);
mDesc
.
GetLengths
()[
4
])(
num_thread
);
break
;
break
;
}
}
case
6
:
{
auto
f
=
[
&
](
auto
i0
,
auto
i1
,
auto
i2
,
auto
i3
,
auto
i4
,
auto
i5
)
{
(
*
this
)(
i0
,
i1
,
i2
,
i3
,
i4
)
=
g
(
i0
,
i1
,
i2
,
i3
,
i4
,
i5
);
};
make_ParallelTensorFunctor
(
f
,
mDesc
.
GetLengths
()[
0
],
mDesc
.
GetLengths
()[
1
],
mDesc
.
GetLengths
()[
2
],
mDesc
.
GetLengths
()[
3
],
mDesc
.
GetLengths
()[
4
],
mDesc
.
GetLengths
()[
5
])(
num_thread
);
break
;
}
default:
throw
std
::
runtime_error
(
"unspported dimension"
);
default:
throw
std
::
runtime_error
(
"unspported dimension"
);
}
}
}
}
...
...
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