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
ba6664b0
Commit
ba6664b0
authored
Jul 18, 2022
by
Chao Liu
Browse files
fix test
parent
60deeedc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
134 deletions
+130
-134
test/conv_util/conv_util.cpp
test/conv_util/conv_util.cpp
+56
-55
test/reference_conv_fwd/reference_conv_fwd.cpp
test/reference_conv_fwd/reference_conv_fwd.cpp
+74
-79
No files found.
test/conv_util/conv_util.cpp
View file @
ba6664b0
...
@@ -17,24 +17,27 @@ namespace {
...
@@ -17,24 +17,27 @@ namespace {
class
TestConvUtil
:
public
::
testing
::
Test
class
TestConvUtil
:
public
::
testing
::
Test
{
{
public:
public:
void
SetNDParams
(
std
::
size_t
ndims
)
void
SetNDParams
(
std
::
size_t
ndims
,
std
::
size_t
s
,
std
::
size_t
d
,
std
::
size_t
p
)
{
{
conv_params
.
num_dim_spatial_
=
ndims
;
conv_params
=
ck
::
utils
::
conv
::
ConvParam
(
ndims
,
conv_params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
3
);
128
,
conv_params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
71
);
192
,
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
2
);
256
,
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
std
::
vector
<
ck
::
index_t
>
(
ndims
,
3
),
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
std
::
vector
<
ck
::
index_t
>
(
ndims
,
71
),
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
std
::
vector
<
ck
::
index_t
>
(
ndims
,
s
),
std
::
vector
<
ck
::
index_t
>
(
ndims
,
d
),
std
::
vector
<
ck
::
index_t
>
(
ndims
,
p
),
std
::
vector
<
ck
::
index_t
>
(
ndims
,
p
));
}
}
protected:
protected:
// ------- default 2D -------
// ------- default 2D -------
// input NCHW {128,192,71,71},
// input NCHW {128,192,71,71},
// weights KCYX {256,192,3,3},
// weights KCYX {256,192,3,3},
// stride {
2,2
},
// stride {
s, s
},
// dilations {
1,1
},
// dilations {
d,d
},
// padding {{
1,1
}, {
1,1}
}
// padding {{
p,p
}, {
p,p
}
ck
::
utils
::
conv
::
ConvParam
conv_params
;
ck
::
utils
::
conv
::
ConvParam
conv_params
;
};
};
...
@@ -42,35 +45,34 @@ class TestConvUtil : public ::testing::Test
...
@@ -42,35 +45,34 @@ class TestConvUtil : public ::testing::Test
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths1D
)
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths1D
)
{
{
SetNDParams
(
1
);
// stride 2, dilation 1, pad 1
SetNDParams
(
1
,
2
,
1
,
1
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
));
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
// stride 1, dilation 1, pad 1
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
SetNDParams
(
1
,
1
,
1
,
1
);
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
},
"Error: ConvParams 1D stride {1}."
));
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
};
// stride 2, dilation 1, pad 2
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
SetNDParams
(
1
,
2
,
1
,
2
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
},
std
::
vector
<
ck
::
index_t
>
{
37
},
"Error: ConvParams 1D padding left/right {2}."
));
"Error: ConvParams 1D padding left/right {2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
// stride 2, dilation 2, pad 2
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
SetNDParams
(
1
,
2
,
2
,
2
);
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D dilation {2}."
));
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
};
// stride 3, dilation 2, pad 1
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
SetNDParams
(
1
,
3
,
2
,
1
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
},
std
::
vector
<
ck
::
index_t
>
{
23
},
...
@@ -79,35 +81,35 @@ TEST_F(TestConvUtil, ConvParamsGetOutputSpatialLengths1D)
...
@@ -79,35 +81,35 @@ TEST_F(TestConvUtil, ConvParamsGetOutputSpatialLengths1D)
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths2D
)
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths2D
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_params
;
// stride 2, dilation 1, pad 1
SetNDParams
(
2
,
2
,
1
,
1
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D default constructor."
));
"Error: ConvParams 2D default constructor."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
// stride 1, dilation 1, pad 1
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
SetNDParams
(
2
,
1
,
1
,
1
);
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
},
"Error: ConvParams 2D stride {1,1}."
));
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
};
// stride 2, dilation 1, pad 2
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
SetNDParams
(
2
,
2
,
1
,
2
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
"Error: ConvParams 2D padding left/right {2,2}."
));
"Error: ConvParams 2D padding left/right {2,2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
// stride 2, dilation 2, pad 2
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
SetNDParams
(
2
,
2
,
2
,
2
);
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D dilation {2,2}."
));
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
};
// stride 3, dilation 2, pad 1
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
SetNDParams
(
2
,
3
,
2
,
1
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
...
@@ -116,37 +118,36 @@ TEST_F(TestConvUtil, ConvParamsGetOutputSpatialLengths2D)
...
@@ -116,37 +118,36 @@ TEST_F(TestConvUtil, ConvParamsGetOutputSpatialLengths2D)
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths3D
)
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths3D
)
{
{
SetNDParams
(
3
);
// stride 2, dilation 1, pad 1
SetNDParams
(
3
,
2
,
1
,
1
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D."
));
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
};
// stride 1, dilation 1, pad 1
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
SetNDParams
(
3
,
1
,
1
,
1
);
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
"Error: ConvParams 3D stride {1, 1, 1}."
));
"Error: ConvParams 3D stride {1, 1, 1}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
// stride 2, dilation 1, pad 2
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
SetNDParams
(
3
,
2
,
1
,
2
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
"Error: ConvParams 3D padding left/right {2, 2, 2}."
));
"Error: ConvParams 3D padding left/right {2, 2, 2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
// stride 2, dilation 2, pad 2
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
SetNDParams
(
3
,
2
,
2
,
2
);
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D dilation {2, 2, 2}."
));
"Error: ConvParams 3D dilation {2, 2, 2}."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
// stride 3, dilation 2, pad 1
conv_params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
SetNDParams
(
3
,
3
,
2
,
1
);
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
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
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
...
...
test/reference_conv_fwd/reference_conv_fwd.cpp
View file @
ba6664b0
...
@@ -81,19 +81,19 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParam& conv_param,
...
@@ -81,19 +81,19 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParam& conv_param,
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWC
)
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWC
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
2
,
conv_param
.
N_
=
1
;
1
,
conv_param
.
K_
=
1
;
1
,
conv_param
.
C_
=
2
;
2
,
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
}
;
std
::
vector
<
ck
::
index_t
>
{
3
,
3
}
,
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
6
,
6
}
;
std
::
vector
<
ck
::
index_t
>
{
6
,
6
}
,
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
;
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
,
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
;
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
,
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
}
;
std
::
vector
<
ck
::
index_t
>
{
0
,
0
}
,
conv_param
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
};
std
::
vector
<
ck
::
index_t
>
{
0
,
0
}
)
;
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
conv_param
);
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
conv_param
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
4
,
4
,
1
};
std
::
vector
<
float
>
ref_data
{
130.5
,
std
::
vector
<
float
>
ref_data
{
130.5
,
148.5
,
148.5
,
166.5
,
166.5
,
...
@@ -117,19 +117,19 @@ TEST(ReferenceConvolutionFWD, Conv2DNHWC)
...
@@ -117,19 +117,19 @@ TEST(ReferenceConvolutionFWD, Conv2DNHWC)
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWCStridesDilationsPadding
)
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWCStridesDilationsPadding
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
2
,
conv_param
.
N_
=
1
;
1
,
conv_param
.
K_
=
2
;
2
,
conv_param
.
C_
=
2
;
2
,
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
}
;
std
::
vector
<
ck
::
index_t
>
{
3
,
3
}
,
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
12
,
12
}
;
std
::
vector
<
ck
::
index_t
>
{
12
,
12
}
,
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
}
;
std
::
vector
<
ck
::
index_t
>
{
2
,
2
}
,
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
}
;
std
::
vector
<
ck
::
index_t
>
{
2
,
2
}
,
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
;
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
,
conv_param
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
std
::
vector
<
ck
::
index_t
>
{
1
,
1
}
)
;
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
conv_param
);
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
conv_param
);
std
::
vector
<
std
::
size_t
>
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
,
5
};
std
::
vector
<
std
::
size_t
>
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
5
,
5
,
2
};
std
::
vector
<
float
>
ref_data
{
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
,
...
@@ -143,17 +143,16 @@ TEST(ReferenceConvolutionFWD, Conv2DNHWCStridesDilationsPadding)
...
@@ -143,17 +143,16 @@ TEST(ReferenceConvolutionFWD, Conv2DNHWCStridesDilationsPadding)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWC
)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWC
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
1
,
conv_param
.
num_dim_spatial_
=
1
;
1
,
conv_param
.
N_
=
1
;
1
,
conv_param
.
K_
=
1
;
2
,
conv_param
.
C_
=
2
;
std
::
vector
<
ck
::
index_t
>
{
3
},
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
std
::
vector
<
ck
::
index_t
>
{
6
},
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
6
};
std
::
vector
<
ck
::
index_t
>
{
1
},
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
ck
::
index_t
>
{
1
},
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
ck
::
index_t
>
{
0
},
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
};
std
::
vector
<
ck
::
index_t
>
{
0
});
conv_param
.
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
,
...
@@ -163,7 +162,7 @@ TEST(ReferenceConvolutionFWD, Conv1DNWC)
...
@@ -163,7 +162,7 @@ TEST(ReferenceConvolutionFWD, Conv1DNWC)
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
conv_param
);
ck
::
tensor_layout
::
convolution
::
NWK
>
(
conv_param
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
4
,
1
};
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
};
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
...
@@ -172,17 +171,16 @@ TEST(ReferenceConvolutionFWD, Conv1DNWC)
...
@@ -172,17 +171,16 @@ TEST(ReferenceConvolutionFWD, Conv1DNWC)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCStridesDilationsPadding
)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCStridesDilationsPadding
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
1
,
conv_param
.
num_dim_spatial_
=
1
;
1
,
conv_param
.
N_
=
1
;
2
,
conv_param
.
K_
=
2
;
2
,
conv_param
.
C_
=
2
;
std
::
vector
<
ck
::
index_t
>
{
3
},
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
std
::
vector
<
ck
::
index_t
>
{
12
},
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
12
};
std
::
vector
<
ck
::
index_t
>
{
2
},
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
std
::
vector
<
ck
::
index_t
>
{
2
},
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
std
::
vector
<
ck
::
index_t
>
{
1
},
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
ck
::
index_t
>
{
1
});
conv_param
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
auto
out_tensor
=
auto
out_tensor
=
run_reference_convolution_forward
<
1
,
run_reference_convolution_forward
<
1
,
...
@@ -192,7 +190,7 @@ TEST(ReferenceConvolutionFWD, Conv1DNWCStridesDilationsPadding)
...
@@ -192,7 +190,7 @@ TEST(ReferenceConvolutionFWD, Conv1DNWCStridesDilationsPadding)
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
conv_param
);
ck
::
tensor_layout
::
convolution
::
NWK
>
(
conv_param
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
2
,
5
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
5
,
2
};
std
::
vector
<
float
>
ref_data
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
std
::
vector
<
float
>
ref_data
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
...
@@ -201,17 +199,16 @@ TEST(ReferenceConvolutionFWD, Conv1DNWCStridesDilationsPadding)
...
@@ -201,17 +199,16 @@ TEST(ReferenceConvolutionFWD, Conv1DNWCStridesDilationsPadding)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCSameOutputSize
)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCSameOutputSize
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
1
,
conv_param
.
num_dim_spatial_
=
1
;
2
,
conv_param
.
N_
=
2
;
16
,
conv_param
.
K_
=
16
;
4
,
conv_param
.
C_
=
4
;
std
::
vector
<
ck
::
index_t
>
{
3
},
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
std
::
vector
<
ck
::
index_t
>
{
16
},
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
};
std
::
vector
<
ck
::
index_t
>
{
1
},
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
ck
::
index_t
>
{
1
},
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
ck
::
index_t
>
{
1
},
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
ck
::
index_t
>
{
1
});
conv_param
.
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
,
...
@@ -295,17 +292,16 @@ TEST(ReferenceConvolutionFWD, Conv1DNWCSameOutputSize)
...
@@ -295,17 +292,16 @@ TEST(ReferenceConvolutionFWD, Conv1DNWCSameOutputSize)
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHW
)
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHW
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
3
,
conv_param
.
num_dim_spatial_
=
3
;
1
,
conv_param
.
N_
=
1
;
1
,
conv_param
.
K_
=
1
;
2
,
conv_param
.
C_
=
2
;
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
},
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
std
::
vector
<
ck
::
index_t
>
{
6
,
6
,
6
},
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
6
,
6
,
6
};
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
},
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
},
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
},
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
});
conv_param
.
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
,
...
@@ -334,17 +330,16 @@ TEST(ReferenceConvolutionFWD, Conv3DNCDHW)
...
@@ -334,17 +330,16 @@ TEST(ReferenceConvolutionFWD, Conv3DNCDHW)
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHWStridesDilations
)
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHWStridesDilations
)
{
{
ck
::
utils
::
conv
::
ConvParam
conv_param
;
ck
::
utils
::
conv
::
ConvParam
conv_param
(
3
,
conv_param
.
num_dim_spatial_
=
3
;
1
,
conv_param
.
N_
=
1
;
2
,
conv_param
.
K_
=
2
;
2
,
conv_param
.
C_
=
2
;
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
},
conv_param
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
std
::
vector
<
ck
::
index_t
>
{
12
,
12
,
12
},
conv_param
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
12
,
12
,
12
};
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
},
conv_param
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
},
conv_param
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
},
conv_param
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
});
conv_param
.
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
,
...
...
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