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
5195dbbb
Commit
5195dbbb
authored
Apr 25, 2023
by
Rostyslav Geyyer
Browse files
Move type_convert to elemwise op, update the op
parent
f86e4436
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
46 deletions
+15
-46
include/ck/tensor_operation/gpu/element/unary_element_wise_operation.hpp
...or_operation/gpu/element/unary_element_wise_operation.hpp
+11
-29
include/ck/tensor_operation/gpu/thread/threadwise_tensor_slice_transfer_v3r1.hpp
...tion/gpu/thread/threadwise_tensor_slice_transfer_v3r1.hpp
+4
-17
No files found.
include/ck/tensor_operation/gpu/element/unary_element_wise_operation.hpp
View file @
5195dbbb
...
...
@@ -56,6 +56,12 @@ struct PassThrough
y
=
type_convert
<
bhalf_t
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
bhalf_t
,
half_t
>
(
bhalf_t
&
y
,
const
half_t
&
x
)
const
{
y
=
type_convert
<
bhalf_t
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
int8_t
,
int8_t
>
(
int8_t
&
y
,
const
int8_t
&
x
)
const
{
...
...
@@ -86,51 +92,27 @@ struct UnaryConvert
}
};
struct
Unary
Convert
Precision
struct
Convert
BF16RTN
{
template
<
typename
Y
,
typename
X
>
__host__
__device__
void
operator
()(
Y
&
y
,
const
X
&
x
)
const
;
template
<
>
__host__
__device__
void
operator
()
<
float
,
float
>
(
float
&
y
,
const
float
&
x
)
const
{
y
=
type_convert_precision
<
float
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
half_t
,
half_t
>
(
half_t
&
y
,
const
half_t
&
x
)
const
{
y
=
type_convert_precision
<
half_t
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
bhalf_t
,
bhalf_t
>
(
bhalf_t
&
y
,
const
bhalf_t
&
x
)
const
__host__
__device__
void
operator
()
<
bhalf_t
,
half_t
>
(
bhalf_t
&
y
,
const
half_t
&
x
)
const
{
y
=
type_convert_precision
<
bhalf_t
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
double
,
double
>
(
double
&
y
,
const
double
&
x
)
const
{
y
=
type_convert_precision
<
double
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
int8_t
,
int8_t
>
(
int8_t
&
y
,
const
int8_t
&
x
)
const
{
y
=
type_convert_precision
<
int8_t
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
bhalf_t
,
half_t
>
(
bhalf_t
&
y
,
const
half_t
&
x
)
const
__host__
__device__
void
operator
()
<
bhalf_t
,
float
>
(
bhalf_t
&
y
,
const
float
&
x
)
const
{
y
=
type_convert_precision
<
bhalf_t
>
(
x
);
}
template
<
>
__host__
__device__
void
operator
()
<
b
half_t
,
floa
t
>
(
b
half_t
&
y
,
const
floa
t
&
x
)
const
__host__
__device__
void
operator
()
<
half_t
,
half_
t
>
(
half_t
&
y
,
const
half_
t
&
x
)
const
{
y
=
type_convert_precision
<
b
half_t
>
(
x
);
y
=
type_convert_precision
<
half_t
>
(
x
);
}
};
...
...
include/ck/tensor_operation/gpu/thread/threadwise_tensor_slice_transfer_v3r1.hpp
View file @
5195dbbb
...
...
@@ -339,23 +339,10 @@ struct ThreadwiseTensorSliceTransfer_v3r1
}
static_ford
<
SliceLengths
>
{}([
&
](
auto
idx
)
{
// if elementwise op does conversion, use the op instead of type_convert
if
constexpr
(
is_same
<
SrcElementwiseOperation
,
ck
::
tensor_operation
::
element_wise
::
UnaryConvert
>::
value
||
is_same
<
SrcElementwiseOperation
,
ck
::
tensor_operation
::
element_wise
::
UnaryConvertPrecision
>::
value
)
{
// apply the src elementwise op and convert under the hood if needed
DstData
dst_v
;
src_element_op_
(
dst_v
,
src_thread_scratch_tuple_
[
thread_scratch_id
][
idx
]);
dst_thread_scratch_
(
idx
)
=
dst_v
;
}
// else apply elementwise op and use type_convert for conversion
else
{
SrcData
src_v
;
src_element_op_
(
src_v
,
src_thread_scratch_tuple_
[
thread_scratch_id
][
idx
]);
dst_thread_scratch_
(
idx
)
=
type_convert
<
DstData
>
(
src_v
);
}
});
#endif
}
...
...
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