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_ROCM
Commits
e72c0c43
Commit
e72c0c43
authored
Mar 26, 2022
by
carlushuang
Browse files
Merge remote-tracking branch 'origin/develop' into cpu_avx2
parents
d714fa15
313bbea5
Changes
262
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
38 deletions
+127
-38
test/reference_conv_fwd/reference_conv_fwd.cpp
test/reference_conv_fwd/reference_conv_fwd.cpp
+125
-32
test/space_filling_curve/space_filling_curve.cpp
test/space_filling_curve/space_filling_curve.cpp
+2
-6
No files found.
test/reference_conv_fwd/reference_conv_fwd.cpp
View file @
e72c0c43
...
...
@@ -23,11 +23,16 @@ template <typename T>
struct
FillMonotonicSeq
{
T
m_init_value
{
0
};
T
m_step
{
1
};
template
<
typename
ForwardIter
>
void
operator
()(
ForwardIter
first
,
ForwardIter
last
)
const
{
std
::
iota
(
first
,
last
,
m_init_value
);
std
::
generate
(
first
,
last
,
[
=
,
n
=
m_init_value
]()
mutable
{
auto
tmp
=
n
;
n
+=
m_step
;
return
tmp
;
});
}
};
...
...
@@ -53,7 +58,7 @@ template <ck::index_t NDim,
typename
FillInputOp
=
FillMonotonicSeq
<
InDataType
>,
typename
FillWeightsOp
=
FillConstant
<
WeiDataType
>>
Tensor
<
OutDataType
>
RunReferenceConv
(
const
ck
::
conv_util
::
ConvParams
&
params
,
const
FillInputOp
&
fill_input_op
=
FillInputOp
{
0
},
const
FillInputOp
&
fill_input_op
=
FillInputOp
{},
const
FillWeightsOp
&
fill_weights_op
=
FillWeightsOp
{
0.5
f
})
{
std
::
vector
<
std
::
size_t
>
input_dims
{
static_cast
<
std
::
size_t
>
(
params
.
N
),
...
...
@@ -84,6 +89,9 @@ Tensor<OutDataType> RunReferenceConv(const ck::conv_util::ConvParams& params,
fill_weights_op
(
weights
.
begin
(),
weights
.
end
());
std
::
fill
(
host_output
.
begin
(),
host_output
.
end
(),
OutDataType
(
0.
f
));
// std::cout <<"input: " << input.mDesc << std::endl << input.mData << std::endl;
// std::cout <<"weight: " << weights.mDesc << std::endl << weights.mData << std::endl;
auto
ref_conv
=
ck
::
tensor_operation
::
host
::
ReferenceConvFwd
<
InDataType
,
WeiDataType
,
OutDataType
,
...
...
@@ -104,6 +112,7 @@ Tensor<OutDataType> RunReferenceConv(const ck::conv_util::ConvParams& params,
OutElementOp
{});
ref_invoker
.
Run
(
ref_argument
);
// std::cout <<"output: " << host_output.mDesc << std::endl << host_output.mData << std::endl;
return
host_output
;
}
...
...
@@ -139,10 +148,10 @@ bool TestConv2DNHWC()
472.5
,
490.5
,
508.5
};
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
params
.
N
=
1
;
params
.
K
=
2
;
...
...
@@ -162,10 +171,10 @@ bool TestConv2DNHWC()
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
,
1323.
,
1323.
,
2002.5
,
2002.5
,
2038.5
,
2038.5
,
2074.5
,
2074.5
,
2110.5
,
2110.5
};
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
return
res
;
}
...
...
@@ -194,10 +203,10 @@ bool TestConv1DNWC()
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
};
std
::
vector
<
float
>
ref_data
{
7.5
,
13.5
,
19.5
,
25.5
};
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
params
.
num_dim_spatial
=
1
;
params
.
N
=
1
;
...
...
@@ -219,10 +228,10 @@ bool TestConv1DNWC()
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
};
ref_data
=
std
::
vector
<
float
>
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
_util
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
params
.
num_dim_spatial
=
1
;
params
.
N
=
2
;
...
...
@@ -235,16 +244,14 @@ bool TestConv1DNWC()
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
auto
out_tensor2
=
RunReferenceConv
<
1
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
,
[](
auto
first
,
auto
last
)
{
std
::
generate
(
first
,
last
,
[
n
=
0
]()
mutable
{
return
float
(
n
++
)
*
float
(
0.1
f
);
});
});
auto
out_tensor2
=
RunReferenceConv
<
1
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
,
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
16
,
16
};
ref_data
=
std
::
vector
<
float
>
{
...
...
@@ -312,10 +319,94 @@ bool TestConv1DNWC()
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
};
res
=
res
&&
test_util
::
check_err
(
out_tensor2
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test_util
::
check_err
(
out_tensor2
.
mData
,
ref_data
,
"Error: incorrect results!"
);
res
=
res
&&
test
::
check_err
(
out_tensor2
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor2
.
mData
,
ref_data
,
"Error: incorrect results!"
);
return
res
;
}
bool
TestConv3DNCDHW
()
{
bool
res
{
true
};
ck
::
conv_util
::
ConvParams
params
;
params
.
num_dim_spatial
=
3
;
params
.
N
=
1
;
params
.
K
=
1
;
params
.
C
=
2
;
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
.
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
>
{
0
,
0
,
0
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
auto
out_tensor
=
RunReferenceConv
<
3
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NCDHW
,
ck
::
tensor_layout
::
convolution
::
KCZYX
,
ck
::
tensor_layout
::
convolution
::
NKDHW
>
(
params
,
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
,
4
,
4
};
std
::
vector
<
float
>
ref_data
{
407.7
,
410.40002
,
413.09998
,
415.80002
,
423.90002
,
426.6
,
429.30002
,
432.
,
440.1
,
442.80002
,
445.5
,
448.2
,
456.30002
,
459.
,
461.7
,
464.40002
,
504.90002
,
507.6
,
510.30002
,
513.
,
521.1
,
523.8
,
526.5
,
529.2001
,
537.3
,
540.
,
542.7001
,
545.4
,
553.5
,
556.2001
,
558.9
,
561.6
,
602.10004
,
604.8
,
607.5
,
610.2
,
618.3
,
621.
,
623.7
,
626.4
,
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
,
731.7
,
734.4001
,
737.10004
,
739.8
,
747.9001
,
750.60004
,
753.3
,
756.
};
res
=
res
&&
test
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error [case 1]: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 1]: incorrect results!"
);
params
.
N
=
1
;
params
.
K
=
2
;
params
.
C
=
2
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
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
=
RunReferenceConv
<
3
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NCDHW
,
ck
::
tensor_layout
::
convolution
::
KCZYX
,
ck
::
tensor_layout
::
convolution
::
NKDHW
>
(
params
,
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
4
,
4
,
4
};
ref_data
=
std
::
vector
<
float
>
{
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
,
3923.1
,
3931.2
,
3939.2998
,
3947.4
,
4020.2998
,
4028.4001
,
4036.5002
,
4044.5999
,
4117.5
,
4125.6
,
4133.7
,
4141.8
,
4214.7
,
4222.8
,
4230.9004
,
4239.
,
5089.5
,
5097.5996
,
5105.7
,
5113.8
,
5186.7
,
5194.8
,
5202.9
,
5211.
,
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
,
6450.301
,
6458.4
,
6466.5
,
6474.6
,
6547.5
,
6555.6
,
6563.699
,
6571.801
,
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
,
3923.1
,
3931.2
,
3939.2998
,
3947.4
,
4020.2998
,
4028.4001
,
4036.5002
,
4044.5999
,
4117.5
,
4125.6
,
4133.7
,
4141.8
,
4214.7
,
4222.8
,
4230.9004
,
4239.
,
5089.5
,
5097.5996
,
5105.7
,
5113.8
,
5186.7
,
5194.8
,
5202.9
,
5211.
,
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
,
6450.301
,
6458.4
,
6466.5
,
6474.6
,
6547.5
,
6555.6
,
6563.699
,
6571.801
};
res
=
res
&&
test
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error [case 2]: wrong output tensor dimensions!"
);
res
=
res
&&
test
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 2]: incorrect results!"
,
1e-4
f
,
1e-6
f
);
return
res
;
}
...
...
@@ -329,5 +420,7 @@ int main(void)
std
::
cout
<<
"TestConv2DNHWC ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
TestConv1DNWC
();
std
::
cout
<<
"TestConv1DNHWC ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
TestConv3DNCDHW
();
std
::
cout
<<
"TestConv3DNCDHW ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
0
;
}
test/space_filling_curve/space_filling_curve.cpp
View file @
e72c0c43
...
...
@@ -14,12 +14,8 @@ int main(int argc, char** argv)
(
void
)
argc
;
(
void
)
argv
;
{
traverse_using_space_filling_curve
();
auto
err
=
hipDeviceSynchronize
();
(
void
)
err
;
assert
(
err
==
hipSuccess
);
}
traverse_using_space_filling_curve
();
return
0
;
}
...
...
Prev
1
…
10
11
12
13
14
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