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
a3b4c5cb
Commit
a3b4c5cb
authored
Jun 03, 2022
by
wangshaojie6
Browse files
merge develop branch and add gridwise pipeline v3
parents
48918ab9
1677cf70
Changes
361
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
154 additions
and
163 deletions
+154
-163
test/reference_conv_fwd/reference_conv_fwd.cpp
test/reference_conv_fwd/reference_conv_fwd.cpp
+154
-163
No files found.
test/reference_conv_fwd/reference_conv_fwd.cpp
View file @
a3b4c5cb
...
@@ -4,10 +4,11 @@
...
@@ -4,10 +4,11 @@
#include <numeric>
#include <numeric>
#include <type_traits>
#include <type_traits>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "check_err.hpp"
#include "check_err.hpp"
#include "config.hpp"
#include "config.hpp"
#include "conv_
fwd_
util.hpp"
#include "conv_util.hpp"
#include "element_wise_operation.hpp"
#include "element_wise_operation.hpp"
#include "fill.hpp"
#include "fill.hpp"
#include "host_tensor.hpp"
#include "host_tensor.hpp"
...
@@ -33,21 +34,21 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParams& params,
...
@@ -33,21 +34,21 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParams& params,
const
FillInputOp
&
fill_input_op
=
FillInputOp
{},
const
FillInputOp
&
fill_input_op
=
FillInputOp
{},
const
FillWeightsOp
&
fill_weights_op
=
FillWeightsOp
{
0.5
f
})
const
FillWeightsOp
&
fill_weights_op
=
FillWeightsOp
{
0.5
f
})
{
{
std
::
vector
<
std
::
size_t
>
input_dims
{
static_cast
<
std
::
size_t
>
(
params
.
N
),
std
::
vector
<
std
::
size_t
>
input_dims
{
static_cast
<
std
::
size_t
>
(
params
.
N
_
),
static_cast
<
std
::
size_t
>
(
params
.
C
)};
static_cast
<
std
::
size_t
>
(
params
.
C
_
)};
input_dims
.
insert
(
std
::
end
(
input_dims
),
input_dims
.
insert
(
std
::
end
(
input_dims
),
std
::
begin
(
params
.
input_spatial_lengths
),
std
::
begin
(
params
.
input_spatial_lengths
_
),
std
::
end
(
params
.
input_spatial_lengths
));
std
::
end
(
params
.
input_spatial_lengths
_
));
std
::
vector
<
std
::
size_t
>
filter_dims
{
static_cast
<
std
::
size_t
>
(
params
.
K
),
std
::
vector
<
std
::
size_t
>
filter_dims
{
static_cast
<
std
::
size_t
>
(
params
.
K
_
),
static_cast
<
std
::
size_t
>
(
params
.
C
)};
static_cast
<
std
::
size_t
>
(
params
.
C
_
)};
filter_dims
.
insert
(
std
::
end
(
filter_dims
),
filter_dims
.
insert
(
std
::
end
(
filter_dims
),
std
::
begin
(
params
.
filter_spatial_lengths
),
std
::
begin
(
params
.
filter_spatial_lengths
_
),
std
::
end
(
params
.
filter_spatial_lengths
));
std
::
end
(
params
.
filter_spatial_lengths
_
));
const
std
::
vector
<
ck
::
index_t
>&
output_spatial_lengths
=
params
.
GetOutputSpatialLengths
();
const
std
::
vector
<
ck
::
index_t
>&
output_spatial_lengths
=
params
.
GetOutputSpatialLengths
();
std
::
vector
<
std
::
size_t
>
output_dims
{
static_cast
<
std
::
size_t
>
(
params
.
N
),
std
::
vector
<
std
::
size_t
>
output_dims
{
static_cast
<
std
::
size_t
>
(
params
.
N
_
),
static_cast
<
std
::
size_t
>
(
params
.
K
)};
static_cast
<
std
::
size_t
>
(
params
.
K
_
)};
output_dims
.
insert
(
std
::
end
(
output_dims
),
output_dims
.
insert
(
std
::
end
(
output_dims
),
std
::
begin
(
output_spatial_lengths
),
std
::
begin
(
output_spatial_lengths
),
std
::
end
(
output_spatial_lengths
));
std
::
end
(
output_spatial_lengths
));
...
@@ -73,32 +74,32 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParams& params,
...
@@ -73,32 +74,32 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParams& params,
auto
ref_argument
=
ref_conv
.
MakeArgument
(
input
,
auto
ref_argument
=
ref_conv
.
MakeArgument
(
input
,
weights
,
weights
,
host_output
,
host_output
,
params
.
conv_filter_strides
,
params
.
conv_filter_strides
_
,
params
.
conv_filter_dilations
,
params
.
conv_filter_dilations
_
,
params
.
input_left_pads
,
params
.
input_left_pads
_
,
params
.
input_right_pads
,
params
.
input_right_pads
_
,
InElementOp
{},
InElementOp
{},
WeiElementOp
{},
WeiElementOp
{},
OutElementOp
{});
OutElementOp
{});
ref_invoker
.
Run
(
ref_argument
);
ref_invoker
.
Run
(
ref_argument
);
// std::cout <<"output: " << host_output.mDesc << std::endl << host_output.mData << std::endl;
return
host_output
;
return
host_output
;
}
}
bool
test_conv2d_nhwc
()
}
// anonymous namespace
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWC
)
{
{
bool
res
{
true
};
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
N
=
1
;
params
.
N
_
=
1
;
params
.
K
=
1
;
params
.
K
_
=
1
;
params
.
C
=
2
;
params
.
C
_
=
2
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
params
.
filter_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
6
,
6
};
params
.
input_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
6
,
6
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
conv_filter_strides
_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
conv_filter_dilations
_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
};
params
.
input_left_pads
_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
};
params
.
input_right_pads
_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
};
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
params
);
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
params
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
,
4
};
...
@@ -118,51 +119,50 @@ bool test_conv2d_nhwc()
...
@@ -118,51 +119,50 @@ bool test_conv2d_nhwc()
472.5
,
472.5
,
490.5
,
490.5
,
508.5
};
508.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimension
s!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect result
s!"
)
)
;
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
}
params
.
N
=
1
;
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWCStridesDilationsPadding
)
params
.
K
=
2
;
{
params
.
C
=
2
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
params
.
N_
=
1
;
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
12
,
12
};
params
.
K_
=
2
;
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
params
.
C_
=
2
;
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
12
,
12
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_tensor
=
run_reference_convolution_forward
<
2
>
(
params
);
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
params
);
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
,
5
};
std
::
vector
<
std
::
size_t
>
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
,
5
};
ref_data
=
std
::
vector
<
float
>
{
std
::
vector
<
float
>
ref_data
{
210.
,
210.
,
327.
,
327.
,
351.
,
351.
,
375.
,
375.
,
399.
,
399.
,
210.
,
210.
,
327.
,
327.
,
351.
,
351.
,
375.
,
375.
,
399.
,
399.
,
459.
,
459.
,
706.5
,
706.5
,
742.5
,
742.5
,
778.5
,
778.5
,
814.5
,
814.5
,
459.
,
459.
,
706.5
,
706.5
,
742.5
,
742.5
,
778.5
,
778.5
,
814.5
,
814.5
,
747.
,
747.
,
1138.5
,
1138.5
,
1174.5
,
1174.5
,
1210.5
,
1210.5
,
1246.5
,
1246.5
,
747.
,
747.
,
1138.5
,
1138.5
,
1174.5
,
1174.5
,
1210.5
,
1210.5
,
1246.5
,
1246.5
,
1035.
,
1035.
,
1570.5
,
1570.5
,
1606.5
,
1606.5
,
1642.5
,
1642.5
,
1678.5
,
1678.5
,
1035.
,
1035.
,
1570.5
,
1570.5
,
1606.5
,
1606.5
,
1642.5
,
1642.5
,
1678.5
,
1678.5
,
1323.
,
1323.
,
2002.5
,
2002.5
,
2038.5
,
2038.5
,
2074.5
,
2074.5
,
2110.5
,
2110.5
};
1323.
,
1323.
,
2002.5
,
2002.5
,
2038.5
,
2038.5
,
2074.5
,
2074.5
,
2110.5
,
2110.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimensions!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
));
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
return
res
;
}
}
bool
test_conv1d_nwc
(
)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWC
)
{
{
bool
res
{
true
};
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
num_dim_spatial
_
=
1
;
params
.
N
=
1
;
params
.
N
_
=
1
;
params
.
K
=
1
;
params
.
K
_
=
1
;
params
.
C
=
2
;
params
.
C
_
=
2
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
filter_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
6
};
params
.
input_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
6
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_strides
_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_dilations
_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
};
params
.
input_left_pads
_
=
std
::
vector
<
ck
::
index_t
>
{
0
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
};
params
.
input_right_pads
_
=
std
::
vector
<
ck
::
index_t
>
{
0
};
auto
out_tensor
=
auto
out_tensor
=
run_reference_convolution_forward
<
1
,
run_reference_convolution_forward
<
1
,
...
@@ -174,46 +174,53 @@ bool test_conv1d_nwc()
...
@@ -174,46 +174,53 @@ bool test_conv1d_nwc()
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
};
std
::
vector
<
float
>
ref_data
{
7.5
,
13.5
,
19.5
,
25.5
};
std
::
vector
<
float
>
ref_data
{
7.5
,
13.5
,
19.5
,
25.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimension
s!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect result
s!"
)
)
;
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
}
params
.
num_dim_spatial
=
1
;
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCStridesDilationsPadding
)
params
.
N
=
1
;
{
params
.
K
=
2
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
C
=
2
;
params
.
num_dim_spatial_
=
1
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
N_
=
1
;
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
12
};
params
.
K_
=
2
;
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
C_
=
2
;
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
12
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_tensor
=
run_reference_convolution_forward
<
1
,
auto
out_tensor
=
float
,
run_reference_convolution_forward
<
1
,
float
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NWC
,
float
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ck
::
tensor_layout
::
convolution
::
KXC
,
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
};
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ref_data
=
std
::
vector
<
float
>
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
2
,
5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
std
::
vector
<
float
>
ref_data
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
ref_dims
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
"Error: wrong output tensor dimensions!"
);
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
));
}
params
.
num_dim_spatial
=
1
;
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCSameOutputSize
)
params
.
N
=
2
;
{
params
.
K
=
16
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
C
=
4
;
params
.
num_dim_spatial_
=
1
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
N_
=
2
;
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
16
};
params
.
K_
=
16
;
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
C_
=
4
;
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
auto
out_tensor2
=
run_reference_convolution_forward
<
1
,
auto
out_tensor2
=
run_reference_convolution_forward
<
1
,
float
,
float
,
...
@@ -224,8 +231,8 @@ bool test_conv1d_nwc()
...
@@ -224,8 +231,8 @@ bool test_conv1d_nwc()
ck
::
tensor_layout
::
convolution
::
NWK
>
(
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
16
,
16
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
2
,
16
,
16
};
ref_data
=
std
::
vector
<
float
>
{
std
::
vector
<
float
>
ref_data
{
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
...
@@ -290,28 +297,24 @@ bool test_conv1d_nwc()
...
@@ -290,28 +297,24 @@ bool test_conv1d_nwc()
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
};
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor2
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor2
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimensions!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor2
.
mData
,
ref_data
,
"Error: incorrect results!"
));
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor2
.
mData
,
ref_data
,
"Error: incorrect results!"
);
return
res
;
}
}
bool
test_conv3d_ncdhw
(
)
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHW
)
{
{
bool
res
{
true
};
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
3
;
params
.
num_dim_spatial
_
=
3
;
params
.
N
=
1
;
params
.
N
_
=
1
;
params
.
K
=
1
;
params
.
K
_
=
1
;
params
.
C
=
2
;
params
.
C
_
=
2
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
filter_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
6
,
6
,
6
};
params
.
input_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
6
,
6
,
6
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
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
.
conv_filter_dilations
_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_left_pads
_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_right_pads
_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
auto
out_tensor
=
run_reference_convolution_forward
<
3
,
auto
out_tensor
=
run_reference_convolution_forward
<
3
,
float
,
float
,
...
@@ -331,32 +334,37 @@ bool test_conv3d_ncdhw()
...
@@ -331,32 +334,37 @@ bool test_conv3d_ncdhw()
634.5
,
637.2
,
639.9
,
642.60004
,
650.7
,
653.4
,
656.10004
,
658.8
,
634.5
,
637.2
,
639.9
,
642.60004
,
650.7
,
653.4
,
656.10004
,
658.8
,
699.3
,
702.
,
704.7
,
707.4
,
715.5
,
718.2
,
720.9
,
723.60004
,
699.3
,
702.
,
704.7
,
707.4
,
715.5
,
718.2
,
720.9
,
723.60004
,
731.7
,
734.4001
,
737.10004
,
739.8
,
747.9001
,
750.60004
,
753.3
,
756.
};
731.7
,
734.4001
,
737.10004
,
739.8
,
747.9001
,
750.60004
,
753.3
,
756.
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
ref_dims
,
"Error [case 1]: wrong output tensor dimensions!"
);
"Error [case 1]: wrong output tensor dimensions!"
));
res
=
res
&&
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 1]: incorrect results!"
);
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 1]: incorrect results!"
));
}
params
.
N
=
1
;
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHWStridesDilations
)
params
.
K
=
2
;
{
params
.
C
=
2
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
num_dim_spatial_
=
3
;
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
12
,
12
,
12
};
params
.
N_
=
1
;
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
K_
=
2
;
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
C_
=
2
;
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
12
,
12
,
12
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
out_tensor
=
run_reference_convolution_forward
<
3
,
auto
out_tensor
=
run_reference_convolution_forward
<
3
,
float
,
float
,
float
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NCDHW
,
ck
::
tensor_layout
::
convolution
::
NCDHW
,
ck
::
tensor_layout
::
convolution
::
KCZYX
,
ck
::
tensor_layout
::
convolution
::
KCZYX
,
ck
::
tensor_layout
::
convolution
::
NKDHW
>
(
ck
::
tensor_layout
::
convolution
::
NKDHW
>
(
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
4
,
4
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
2
,
4
,
4
,
4
};
ref_data
=
std
::
vector
<
float
>
{
std
::
vector
<
float
>
ref_data
{
2756.7002
,
2764.7998
,
2772.9001
,
2781.
,
2853.9001
,
2862.
,
2870.1
,
2878.2002
,
2756.7002
,
2764.7998
,
2772.9001
,
2781.
,
2853.9001
,
2862.
,
2870.1
,
2878.2002
,
2951.1
,
2959.2002
,
2967.2998
,
2975.4001
,
3048.2998
,
3056.4001
,
3064.5
,
3072.6
,
2951.1
,
2959.2002
,
2967.2998
,
2975.4001
,
3048.2998
,
3056.4001
,
3064.5
,
3072.6
,
3923.1
,
3931.2
,
3939.2998
,
3947.4
,
4020.2998
,
4028.4001
,
4036.5002
,
4044.5999
,
3923.1
,
3931.2
,
3939.2998
,
3947.4
,
4020.2998
,
4028.4001
,
4036.5002
,
4044.5999
,
...
@@ -373,26 +381,9 @@ bool test_conv3d_ncdhw()
...
@@ -373,26 +381,9 @@ bool test_conv3d_ncdhw()
5283.9004
,
5292.
,
5300.0996
,
5308.2
,
5381.0996
,
5389.2
,
5397.3
,
5405.4004
,
5283.9004
,
5292.
,
5300.0996
,
5308.2
,
5381.0996
,
5389.2
,
5397.3
,
5405.4004
,
6255.9004
,
6264.0005
,
6272.1
,
6280.2
,
6353.1
,
6361.2
,
6369.301
,
6377.4
,
6255.9004
,
6264.0005
,
6272.1
,
6280.2
,
6353.1
,
6361.2
,
6369.301
,
6377.4
,
6450.301
,
6458.4
,
6466.5
,
6474.6
,
6547.5
,
6555.6
,
6563.699
,
6571.801
};
6450.301
,
6458.4
,
6466.5
,
6474.6
,
6547.5
,
6555.6
,
6563.699
,
6571.801
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
ref_dims
,
"Error [case 2]: wrong output tensor dimensions!"
);
"Error [case 2]: wrong output tensor dimensions!"
));
res
=
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 2]: incorrect results!"
,
1e-4
f
,
1e-6
f
));
out_tensor
.
mData
,
ref_data
,
"Error [case 2]: incorrect results!"
,
1e-4
f
,
1e-6
f
);
return
res
;
}
}
// anonymous namespace
int
main
(
void
)
{
bool
res
{
true
};
res
=
test_conv2d_nhwc
();
std
::
cout
<<
"test_conv2d_nhwc ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv1d_nwc
();
std
::
cout
<<
"TestConv1DNHWC ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ncdhw
();
std
::
cout
<<
"test_conv3d_ncdhw ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
res
?
0
:
1
;
}
}
Prev
1
…
15
16
17
18
19
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