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
d3051d75
Unverified
Commit
d3051d75
authored
Jun 24, 2022
by
Chao Liu
Committed by
GitHub
Jun 24, 2022
Browse files
add license in file (#303)
parent
d1db6a0c
Changes
500
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1030 additions
and
970 deletions
+1030
-970
profiler/src/profile_gemm_bias_2d.cpp
profiler/src/profile_gemm_bias_2d.cpp
+3
-0
profiler/src/profile_gemm_bias_add_reduce.cpp
profiler/src/profile_gemm_bias_add_reduce.cpp
+3
-0
profiler/src/profile_gemm_bias_relu.cpp
profiler/src/profile_gemm_bias_relu.cpp
+3
-0
profiler/src/profile_gemm_bias_relu_add.cpp
profiler/src/profile_gemm_bias_relu_add.cpp
+3
-0
profiler/src/profile_gemm_reduce.cpp
profiler/src/profile_gemm_reduce.cpp
+3
-0
profiler/src/profile_grouped_gemm.cpp
profiler/src/profile_grouped_gemm.cpp
+3
-0
profiler/src/profile_reduce.cpp
profiler/src/profile_reduce.cpp
+3
-0
profiler/src/profiler.cpp
profiler/src/profiler.cpp
+3
-0
test/batched_gemm/batched_gemm_fp16.cpp
test/batched_gemm/batched_gemm_fp16.cpp
+3
-0
test/batched_gemm/batched_gemm_util.hpp
test/batched_gemm/batched_gemm_util.hpp
+3
-0
test/batched_gemm_reduce/batched_gemm_reduce_fp16.cpp
test/batched_gemm_reduce/batched_gemm_reduce_fp16.cpp
+3
-0
test/block_to_ctile_map/test_block_to_ctile_map.cpp
test/block_to_ctile_map/test_block_to_ctile_map.cpp
+3
-0
test/conv2d_bwd_data/conv2d_bwd_data.cpp
test/conv2d_bwd_data/conv2d_bwd_data.cpp
+3
-0
test/conv2d_bwd_weight/conv2d_bwd_weight.cpp
test/conv2d_bwd_weight/conv2d_bwd_weight.cpp
+3
-0
test/conv_util/conv_util.cpp
test/conv_util/conv_util.cpp
+207
-204
test/convnd_bwd_data/convnd_bwd_data.cpp
test/convnd_bwd_data/convnd_bwd_data.cpp
+3
-0
test/convnd_fwd/conv1d_fwd.cpp
test/convnd_fwd/conv1d_fwd.cpp
+192
-189
test/convnd_fwd/conv2d_fwd.cpp
test/convnd_fwd/conv2d_fwd.cpp
+266
-263
test/convnd_fwd/conv3d_fwd.cpp
test/convnd_fwd/conv3d_fwd.cpp
+317
-314
test/convnd_fwd/conv_util.hpp
test/convnd_fwd/conv_util.hpp
+3
-0
No files found.
profiler/src/profile_gemm_bias_2d.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
profiler/src/profile_gemm_bias_add_reduce.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
profiler/src/profile_gemm_bias_relu.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
profiler/src/profile_gemm_bias_relu_add.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
profiler/src/profile_gemm_reduce.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
profiler/src/profile_grouped_gemm.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
profiler/src/profile_reduce.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <fstream>
#include <cstdlib>
...
...
profiler/src/profiler.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
test/batched_gemm/batched_gemm_fp16.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include "profiler/include/profile_batched_gemm_impl.hpp"
...
...
test/batched_gemm/batched_gemm_util.hpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#ifndef BATCHED_GEMM_UTILS_HPP
#define BATCHED_GEMM_UTILS_HPP
...
...
test/batched_gemm_reduce/batched_gemm_reduce_fp16.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include "profiler/include/profile_batched_gemm_reduce_impl.hpp"
...
...
test/block_to_ctile_map/test_block_to_ctile_map.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <vector>
#include <gtest/gtest.h>
...
...
test/conv2d_bwd_data/conv2d_bwd_data.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include "config.hpp"
#include "device.hpp"
#include "host_tensor.hpp"
...
...
test/conv2d_bwd_weight/conv2d_bwd_weight.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
test/conv_util/conv_util.cpp
View file @
d3051d75
#include <iostream>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/conv_util.hpp"
namespace
{
class
TestConvUtil
:
public
::
testing
::
Test
{
public:
void
SetNDParams
(
std
::
size_t
ndims
)
{
conv_params
.
num_dim_spatial_
=
ndims
;
conv_params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
3
);
conv_params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
71
);
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
2
);
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
}
protected:
// ------- default 2D -------
// input NCHW {128,192,71,71},
// weights KCYX {256,192,3,3},
// stride {2,2},
// dilations {1,1},
// padding {{1,1}, {1,1}}
ck
::
utils
::
conv
::
ConvParams
conv_params
;
};
}
// namespace
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths2D
)
{
ck
::
utils
::
conv
::
ConvParams
conv_params
;
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D default constructor."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
},
"Error: ConvParams 2D stride {1,1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
"Error: ConvParams 2D padding left/right {2,2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D dilation {2,2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
"Error: ConvParams 2D strides{3,3}, padding {1,1}, dilations {2,2}."
));
}
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths1D
)
{
SetNDParams
(
1
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
},
"Error: ConvParams 1D stride {1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
},
"Error: ConvParams 1D padding left/right {2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D dilation {2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
},
"Error: ConvParams 1D strides{3}, padding {1}, dilations {2}."
));
}
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths3D
)
{
SetNDParams
(
3
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
"Error: ConvParams 3D stride {1, 1, 1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
"Error: ConvParams 3D padding left/right {2, 2, 2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D dilation {2, 2, 2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
"Error: ConvParams 3D strides{3, 3, 3}, padding {1, 1, 1}, dilations {2, 2, 2}."
));
}
TEST
(
ConvUtil
,
GetHostTensorDescriptor
)
{
namespace
tl
=
ck
::
tensor_layout
::
convolution
;
std
::
vector
<
std
::
size_t
>
dims
{
2
,
3
,
4
,
5
};
HostTensorDescriptor
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NHWC
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NHWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
1
,
3
*
5
,
3
},
"Error: wrong NHWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCHW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NCHW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
4
*
5
,
5
,
1
},
"Error: wrong NCHW dimensions strides!"
));
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NWC
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
1
,
3
},
"Error: wrong NWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NCW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
4
,
1
},
"Error: wrong NCW dimensions strides!"
));
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
,
5
,
6
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NDHWC
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NDHWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
1
,
// C
3
*
5
*
6
,
// D
3
*
6
,
// H
3
},
// W
"Error: wrong NDHWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCDHW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NCDHW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
4
*
5
*
6
,
// C
5
*
6
,
// D
6
,
// H
1
},
// W
"Error: wrong NCDHW dimensions strides!"
));
}
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/conv_util.hpp"
namespace
{
class
TestConvUtil
:
public
::
testing
::
Test
{
public:
void
SetNDParams
(
std
::
size_t
ndims
)
{
conv_params
.
num_dim_spatial_
=
ndims
;
conv_params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
3
);
conv_params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
71
);
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
2
);
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
}
protected:
// ------- default 2D -------
// input NCHW {128,192,71,71},
// weights KCYX {256,192,3,3},
// stride {2,2},
// dilations {1,1},
// padding {{1,1}, {1,1}}
ck
::
utils
::
conv
::
ConvParams
conv_params
;
};
}
// namespace
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths2D
)
{
ck
::
utils
::
conv
::
ConvParams
conv_params
;
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D default constructor."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
},
"Error: ConvParams 2D stride {1,1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
"Error: ConvParams 2D padding left/right {2,2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D dilation {2,2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
"Error: ConvParams 2D strides{3,3}, padding {1,1}, dilations {2,2}."
));
}
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths1D
)
{
SetNDParams
(
1
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
},
"Error: ConvParams 1D stride {1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
},
"Error: ConvParams 1D padding left/right {2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D dilation {2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
},
"Error: ConvParams 1D strides{3}, padding {1}, dilations {2}."
));
}
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths3D
)
{
SetNDParams
(
3
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
"Error: ConvParams 3D stride {1, 1, 1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
"Error: ConvParams 3D padding left/right {2, 2, 2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D dilation {2, 2, 2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
"Error: ConvParams 3D strides{3, 3, 3}, padding {1, 1, 1}, dilations {2, 2, 2}."
));
}
TEST
(
ConvUtil
,
GetHostTensorDescriptor
)
{
namespace
tl
=
ck
::
tensor_layout
::
convolution
;
std
::
vector
<
std
::
size_t
>
dims
{
2
,
3
,
4
,
5
};
HostTensorDescriptor
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NHWC
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NHWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
1
,
3
*
5
,
3
},
"Error: wrong NHWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCHW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NCHW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
4
*
5
,
5
,
1
},
"Error: wrong NCHW dimensions strides!"
));
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NWC
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
1
,
3
},
"Error: wrong NWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NCW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
4
,
1
},
"Error: wrong NCW dimensions strides!"
));
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
,
5
,
6
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NDHWC
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NDHWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
1
,
// C
3
*
5
*
6
,
// D
3
*
6
,
// H
3
},
// W
"Error: wrong NDHWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCDHW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NCDHW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
4
*
5
*
6
,
// C
5
*
6
,
// D
6
,
// H
1
},
// W
"Error: wrong NCDHW dimensions strides!"
));
}
test/convnd_bwd_data/convnd_bwd_data.cpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
...
...
test/convnd_fwd/conv1d_fwd.cpp
View file @
d3051d75
#include <iostream>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv1dFwdNWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
1
,
4
,
256
,
64
,
{
3
},
{
71
},
{
2
},
{
2
},
{
2
},
{
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
1
},
{
1
},
{
0
},
{
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
2
},
{
1
},
{
0
},
{
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv1DFwdNWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv1DFwdNWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
0.1
);
run_engine
.
SetRtol
(
1e-2
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv1dFwdNWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
1
,
4
,
256
,
64
,
{
3
},
{
71
},
{
2
},
{
2
},
{
2
},
{
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
1
},
{
1
},
{
0
},
{
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
2
},
{
1
},
{
0
},
{
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv1DFwdNWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv1DFwdNWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
0.1
);
run_engine
.
SetRtol
(
1e-2
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
test/convnd_fwd/conv2d_fwd.cpp
View file @
d3051d75
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv2dFwdNHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_default_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_default_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_stride1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_stride1_pad0_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_pad0_
);
}
}
template
<
typename
T
>
bool
test_oddC
()
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_oddC_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_oddC_
{
2
,
4
,
256
,
3
,
{
3
,
3
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv2DFwdNHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
1
,
1
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv2DFwdNHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
2e-4
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_oddC
)
{
EXPECT_TRUE
(
this
->
test_oddC
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
(
true
));
}
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv2dFwdNHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_default_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_default_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_stride1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_stride1_pad0_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_pad0_
);
}
}
template
<
typename
T
>
bool
test_oddC
()
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_oddC_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_oddC_
{
2
,
4
,
256
,
3
,
{
3
,
3
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv2DFwdNHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
1
,
1
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv2DFwdNHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
2e-4
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_oddC
)
{
EXPECT_TRUE
(
this
->
test_oddC
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
(
true
));
}
test/convnd_fwd/conv3d_fwd.cpp
View file @
d3051d75
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv3dFwdNDHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv3d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv3DFwdNDHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-3
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
InputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Input
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
32
,
1000
,
1000
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
FiltersOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Filters
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
4
,
1000
,
1000
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
,
16
,
16
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
OutputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Output
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
2
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1000
,
1000
,
30
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv3dFwdNDHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv3d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv3DFwdNDHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-3
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
InputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Input
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
32
,
1000
,
1000
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
FiltersOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Filters
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
4
,
1000
,
1000
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
,
16
,
16
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
OutputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Output
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
2
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1000
,
1000
,
30
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
test/convnd_fwd/conv_util.hpp
View file @
d3051d75
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#pragma once
#include <tuple>
...
...
Prev
1
…
20
21
22
23
24
25
Next
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