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
9b1437db
Unverified
Commit
9b1437db
authored
Sep 15, 2023
by
Bartlomiej Wroblewski
Committed by
GitHub
Sep 15, 2023
Browse files
Merge branch 'develop' into bwroblew/dl_fails_vec_size
parents
27a59270
f9d0eddb
Changes
102
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
42 deletions
+109
-42
test/data_type/f8.cpp
test/data_type/f8.cpp
+57
-24
test/grouped_convnd_bwd_weight/test_grouped_convnd_bwd_weight.cpp
...uped_convnd_bwd_weight/test_grouped_convnd_bwd_weight.cpp
+52
-18
No files found.
test/data_type/f
p
8.cpp
→
test/data_type/f8.cpp
View file @
9b1437db
...
@@ -12,10 +12,11 @@ using ck::type_convert;
...
@@ -12,10 +12,11 @@ using ck::type_convert;
TEST
(
FP8
,
NumericLimits
)
TEST
(
FP8
,
NumericLimits
)
{
{
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
Min
(),
0x08
);
// constants given for negative zero nan mode
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
Max
(),
0x77
);
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
Min
(),
type_convert
<
f8_t
>
(
0x08
));
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
Lowest
(),
0xF7
);
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
Max
(),
type_convert
<
f8_t
>
(
0x7F
));
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
QuietNaN
(),
0x80
);
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
Lowest
(),
type_convert
<
f8_t
>
(
0xFF
));
EXPECT_EQ
(
ck
::
NumericLimits
<
f8_t
>::
QuietNaN
(),
type_convert
<
f8_t
>
(
0x80
));
}
}
TEST
(
FP8
,
ConvertFP32Nearest
)
TEST
(
FP8
,
ConvertFP32Nearest
)
...
@@ -35,12 +36,20 @@ TEST(FP8, ConvertFP32Nearest)
...
@@ -35,12 +36,20 @@ TEST(FP8, ConvertFP32Nearest)
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
abs_tol
);
abs_tol
);
// convert inf float to f8_t and check if it is qNan
// convert inf float to f8_t and check if it is qNan
ASSERT_NEAR
(
0x80
,
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
abs_tol
);
ASSERT_NEAR
(
type_convert
<
f8_t
>
(
0x80
),
// positive float value to fp8 and back, check if holds
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
float
pos_float
=
0.0078125
f
;
abs_tol
);
// positive norm float value to fp8 and back, check if holds
float
pos_float
=
0.017578125
f
;
ASSERT_NEAR
(
pos_float
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
pos_float
)),
abs_tol
);
// negative norm float value to fp8 and back, check if holds
float
neg_float
=
-
0.015625
f
;
ASSERT_NEAR
(
neg_float
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
neg_float
)),
abs_tol
);
// positive subnorm float value to fp8 and back, check if holds
pos_float
=
0.00390625
f
;
ASSERT_NEAR
(
pos_float
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
pos_float
)),
abs_tol
);
ASSERT_NEAR
(
pos_float
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
pos_float
)),
abs_tol
);
// negative float value to fp8 and back, check if holds
// negative
subnorm
float value to fp8 and back, check if holds
float
neg_float
=
-
0.0
156
25
0
f
;
neg_float
=
-
0.0
019531
25
f
;
ASSERT_NEAR
(
neg_float
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
neg_float
)),
abs_tol
);
ASSERT_NEAR
(
neg_float
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
neg_float
)),
abs_tol
);
}
}
...
@@ -61,12 +70,20 @@ TEST(FP8, ConvertFP32Stochastic)
...
@@ -61,12 +70,20 @@ TEST(FP8, ConvertFP32Stochastic)
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
abs_tol
);
abs_tol
);
// convert inf float to f8_t and check if it is qNan
// convert inf float to f8_t and check if it is qNan
ASSERT_NEAR
(
0x80
,
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
abs_tol
);
ASSERT_NEAR
(
type_convert
<
f8_t
>
(
0x80
),
// positive float value to fp8 and back, check if holds
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
float
pos_float
=
0.0078125
f
;
abs_tol
);
// positive norm float value to fp8 and back, check if holds
float
pos_float
=
0.017578125
f
;
ASSERT_NEAR
(
pos_float
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
pos_float
)),
abs_tol
);
// negative norm float value to fp8 and back, check if holds
float
neg_float
=
-
0.015625
f
;
ASSERT_NEAR
(
neg_float
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
neg_float
)),
abs_tol
);
// positive subnorm float value to fp8 and back, check if holds
pos_float
=
0.00390625
f
;
ASSERT_NEAR
(
pos_float
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
pos_float
)),
abs_tol
);
ASSERT_NEAR
(
pos_float
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
pos_float
)),
abs_tol
);
// negative float value to fp8 and back, check if holds
// negative
subnorm
float value to fp8 and back, check if holds
float
neg_float
=
-
0.0
156
25
0
f
;
neg_float
=
-
0.0
019531
25
f
;
ASSERT_NEAR
(
neg_float
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
neg_float
)),
abs_tol
);
ASSERT_NEAR
(
neg_float
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
neg_float
)),
abs_tol
);
}
}
...
@@ -87,12 +104,20 @@ TEST(FP8, ConvertFP16Nearest)
...
@@ -87,12 +104,20 @@ TEST(FP8, ConvertFP16Nearest)
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
Max
())),
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
Max
())),
abs_tol
);
abs_tol
);
// convert QuietNaN fp16 to f8_t and check if it is QuietNaN
// convert QuietNaN fp16 to f8_t and check if it is QuietNaN
ASSERT_NEAR
(
0x80
,
type_convert
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
QuietNaN
()),
abs_tol
);
ASSERT_NEAR
(
type_convert
<
f8_t
>
(
0x80
),
// positive fp16 value to fp8 and back, check if holds
type_convert
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
QuietNaN
()),
half_t
pos_half
=
half_t
{
0.0078125
};
abs_tol
);
// positive norm fp16 value to fp8 and back, check if holds
half_t
pos_half
=
half_t
{
0.017578125
};
ASSERT_NEAR
(
pos_half
,
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
pos_half
)),
abs_tol
);
// negative norm fp16 value to fp8 and back, check if holds
half_t
neg_half
=
half_t
{
-
0.015625
};
ASSERT_NEAR
(
neg_half
,
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
neg_half
)),
abs_tol
);
// positive subnorm fp16 value to fp8 and back, check if holds
pos_half
=
half_t
{
0.00390625
};
ASSERT_NEAR
(
pos_half
,
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
pos_half
)),
abs_tol
);
ASSERT_NEAR
(
pos_half
,
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
pos_half
)),
abs_tol
);
// negative fp16 value to fp8 and back, check if holds
// negative
subnorm
fp16 value to fp8 and back, check if holds
half_t
neg_half
=
half_t
{
-
0.0
156
25
0
};
neg_half
=
half_t
{
-
0.0
019531
25
};
ASSERT_NEAR
(
neg_half
,
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
neg_half
)),
abs_tol
);
ASSERT_NEAR
(
neg_half
,
type_convert
<
half_t
>
(
type_convert
<
f8_t
>
(
neg_half
)),
abs_tol
);
}
}
...
@@ -113,11 +138,19 @@ TEST(FP8, ConvertFP16Stochastic)
...
@@ -113,11 +138,19 @@ TEST(FP8, ConvertFP16Stochastic)
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
Max
())),
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
Max
())),
abs_tol
);
abs_tol
);
// convert QuietNaN fp16 to f8_t and check if it is QuietNaN
// convert QuietNaN fp16 to f8_t and check if it is QuietNaN
ASSERT_NEAR
(
0x80
,
f8_convert_sr
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
QuietNaN
()),
abs_tol
);
ASSERT_NEAR
(
type_convert
<
f8_t
>
(
0x80
),
// positive fp16 value to fp8 and back, check if holds
f8_convert_sr
<
f8_t
>
(
ck
::
NumericLimits
<
half_t
>::
QuietNaN
()),
half_t
pos_half
=
half_t
{
0.0078125
};
abs_tol
);
// positive norm fp16 value to fp8 and back, check if holds
half_t
pos_half
=
half_t
{
0.017578125
};
ASSERT_NEAR
(
pos_half
,
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
pos_half
)),
abs_tol
);
// negative norm fp16 value to fp8 and back, check if holds
half_t
neg_half
=
half_t
{
-
0.015625
};
ASSERT_NEAR
(
neg_half
,
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
neg_half
)),
abs_tol
);
// positive subnorm fp16 value to fp8 and back, check if holds
pos_half
=
half_t
{
0.00390625
};
ASSERT_NEAR
(
pos_half
,
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
pos_half
)),
abs_tol
);
ASSERT_NEAR
(
pos_half
,
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
pos_half
)),
abs_tol
);
// negative fp16 value to fp8 and back, check if holds
// negative
subnorm
fp16 value to fp8 and back, check if holds
half_t
neg_half
=
half_t
{
-
0.0
156
25
0
};
neg_half
=
half_t
{
-
0.0
019531
25
};
ASSERT_NEAR
(
neg_half
,
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
neg_half
)),
abs_tol
);
ASSERT_NEAR
(
neg_half
,
type_convert
<
half_t
>
(
f8_convert_sr
<
f8_t
>
(
neg_half
)),
abs_tol
);
}
}
test/grouped_convnd_bwd_weight/test_grouped_convnd_bwd_weight.cpp
View file @
9b1437db
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
#include "profiler/profile_grouped_conv_bwd_weight_impl.hpp"
#include "profiler/profile_grouped_conv_bwd_weight_impl.hpp"
using
namespace
ck
::
tensor_layout
::
convolution
;
template
<
typename
Tuple
>
template
<
typename
Tuple
>
class
TestGroupedConvndBwdWeight
:
public
::
testing
::
Test
class
TestGroupedConvndBwdWeight
:
public
::
testing
::
Test
{
{
...
@@ -27,28 +29,59 @@ class TestGroupedConvndBwdWeight : public ::testing::Test
...
@@ -27,28 +29,59 @@ class TestGroupedConvndBwdWeight : public ::testing::Test
using
NDimSpatial
=
std
::
tuple_element_t
<
6
,
Tuple
>
;
using
NDimSpatial
=
std
::
tuple_element_t
<
6
,
Tuple
>
;
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
ck
::
index_t
split_k
{
2
};
std
::
vector
<
ck
::
index_t
>
split_ks
{
1
,
2
};
bool
skip_case
(
const
ck
::
utils
::
conv
::
ConvParam
&
params
,
const
ck
::
index_t
split_k
)
{
// K or C are odd is supported only by DL kernel (only applies to fp16)
// DL kernel is only supported for split_k=1
if
constexpr
(
std
::
is_same_v
<
InDataType
,
ck
::
half_t
>
)
{
if
(
split_k
!=
1
&&
(
params
.
K_
%
2
!=
0
||
params
.
C_
%
2
!=
0
))
{
return
true
;
}
}
// 1d NWGC is only supported by DL kernel
// DL kernel is only supported for split_k=1
if
constexpr
(
std
::
is_same_v
<
InLayout
,
NWGC
>
&&
std
::
is_same_v
<
OutLayout
,
NWGK
>
)
{
if
(
split_k
!=
1
)
{
return
true
;
}
}
return
false
;
}
void
Run
()
void
Run
()
{
{
EXPECT_FALSE
(
conv_params
.
empty
());
EXPECT_FALSE
(
conv_params
.
empty
());
bool
pass
=
true
;
bool
pass
=
true
;
for
(
auto
&
param
:
conv_param
s
)
for
(
auto
split_k
:
split_k
s
)
{
{
pass
=
pass
&&
ck
::
profiler
::
profile_grouped_conv_bwd_weight_impl
<
NDimSpatial
{},
for
(
auto
&
param
:
conv_params
)
InLayout
,
{
WeiLayout
,
if
(
!
skip_case
(
param
,
split_k
))
OutLayout
,
{
InDataType
,
pass
=
pass
&&
ck
::
profiler
::
profile_grouped_conv_bwd_weight_impl
<
NDimSpatial
{},
WeiDataType
,
InLayout
,
OutDataType
>
(
WeiLayout
,
true
,
// do_verification
OutLayout
,
1
,
// init_method: integer value
InDataType
,
false
,
// do_log
WeiDataType
,
false
,
// time_kernel
OutDataType
>
(
param
,
true
,
// do_verification
split_k
);
1
,
// init_method: integer value
false
,
// do_log
false
,
// time_kernel
param
,
split_k
);
}
}
}
}
EXPECT_TRUE
(
pass
);
EXPECT_TRUE
(
pass
);
}
}
...
@@ -69,12 +102,13 @@ class TestGroupedConvndBwdWeight3d : public TestGroupedConvndBwdWeight<Tuple>
...
@@ -69,12 +102,13 @@ class TestGroupedConvndBwdWeight3d : public TestGroupedConvndBwdWeight<Tuple>
{
{
};
};
using
namespace
ck
::
tensor_layout
::
convolution
;
using
KernelTypes1d
=
::
testing
::
Types
<
using
KernelTypes1d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
float
,
float
,
GNWC
,
GKXC
,
GNWK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
float
,
float
,
float
,
GNWC
,
GKXC
,
GNWK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
GNWC
,
GKXC
,
GNWK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
GNWC
,
GKXC
,
GNWK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
ck
::
bhalf_t
,
float
,
ck
::
bhalf_t
,
GNWC
,
GKXC
,
GNWK
,
ck
::
Number
<
1
>>>
;
std
::
tuple
<
ck
::
bhalf_t
,
float
,
ck
::
bhalf_t
,
GNWC
,
GKXC
,
GNWK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
float
,
float
,
float
,
NWGC
,
GKXC
,
NWGK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
NWGC
,
GKXC
,
NWGK
,
ck
::
Number
<
1
>>
,
std
::
tuple
<
ck
::
bhalf_t
,
float
,
ck
::
bhalf_t
,
NWGC
,
GKXC
,
NWGK
,
ck
::
Number
<
1
>>>
;
using
KernelTypes2d
=
::
testing
::
Types
<
using
KernelTypes2d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
float
,
float
,
GNHWC
,
GKYXC
,
GNHWK
,
ck
::
Number
<
2
>>
,
std
::
tuple
<
float
,
float
,
float
,
GNHWC
,
GKYXC
,
GNHWK
,
ck
::
Number
<
2
>>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
GNHWC
,
GKYXC
,
GNHWK
,
ck
::
Number
<
2
>>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
GNHWC
,
GKYXC
,
GNHWK
,
ck
::
Number
<
2
>>
,
...
...
Prev
1
2
3
4
5
6
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