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
2a807013
Commit
2a807013
authored
Jan 27, 2025
by
Rostyslav Geyyer
Browse files
Add size checks in pack function
parent
7c6a541b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
include/ck/utility/data_type.hpp
include/ck/utility/data_type.hpp
+16
-0
test/data_type/test_bf6.cpp
test/data_type/test_bf6.cpp
+5
-3
test/data_type/test_fp6.cpp
test/data_type/test_fp6.cpp
+5
-3
No files found.
include/ck/utility/data_type.hpp
View file @
2a807013
...
...
@@ -62,8 +62,12 @@ struct f6x16_pk_t
return
data_union
.
f6_array
[
I
];
}
// V is vector_size and E is number of elements
template
<
size_t
V
,
size_t
E
>
__host__
__device__
inline
type
pack
(
f6_t
*
x
)
{
static_assert
(
V
==
1
||
V
==
2
,
"Vector size must be 1 or 2."
);
static_assert
(
E
==
16
,
"Number of elements must be 16."
);
type
*
retval
=
reinterpret_cast
<
type
*>
(
x
);
return
*
retval
;
}
...
...
@@ -92,8 +96,12 @@ struct f6x32_pk_t
return
data_union
.
f6_array
[
I
];
}
// V is vector_size and E is number of elements
template
<
size_t
V
,
size_t
E
>
__host__
__device__
inline
type
pack
(
f6_t
*
x
)
{
static_assert
(
V
==
1
,
"Vector size must be 1."
);
static_assert
(
E
==
32
,
"Number of elements must be 16."
);
type
*
retval
=
reinterpret_cast
<
type
*>
(
x
);
return
*
retval
;
}
...
...
@@ -122,8 +130,12 @@ struct bf6x16_pk_t
return
data_union
.
bf6_array
[
I
];
}
// V is vector_size and E is number of elements
template
<
size_t
V
,
size_t
E
>
__host__
__device__
inline
type
pack
(
bf6_t
*
x
)
{
static_assert
(
V
==
1
||
V
==
2
,
"Vector size must be 1 or 2."
);
static_assert
(
E
==
16
,
"Number of elements must be 16."
);
type
*
retval
=
reinterpret_cast
<
type
*>
(
x
);
return
*
retval
;
}
...
...
@@ -152,8 +164,12 @@ struct bf6x32_pk_t
return
data_union
.
bf6_array
[
I
];
}
// V is vector_size and E is number of elements
template
<
size_t
V
,
size_t
E
>
__host__
__device__
inline
type
pack
(
bf6_t
*
x
)
{
static_assert
(
V
==
1
,
"Vector size must be 1."
);
static_assert
(
E
==
32
,
"Number of elements must be 16."
);
type
*
retval
=
reinterpret_cast
<
type
*>
(
x
);
return
*
retval
;
}
...
...
test/data_type/test_bf6.cpp
View file @
2a807013
...
...
@@ -271,7 +271,8 @@ TEST(BF6, TestAsType16x1)
});
// assign test values to the vector
ck
::
static_for
<
0
,
vector_size
,
1
>
{}([
&
](
auto
i
)
{
right_vec
.
template
AsType
<
bf6x16_pk_t
>()(
Number
<
i
>
{})
=
bf6x16_pk_t
{}.
pack
(
test_vec
.
data
());
right_vec
.
template
AsType
<
bf6x16_pk_t
>()(
Number
<
i
>
{})
=
bf6x16_pk_t
{}.
pack
<
vector_size
,
packed_size
>
(
test_vec
.
data
());
});
// copy the vector
vector_type
<
bf6x16_pk_t
,
vector_size
>
left_vec
{
right_vec
};
...
...
@@ -310,7 +311,7 @@ TEST(BF6, TestAsType16x2)
// assign test values to the vector
ck
::
static_for
<
0
,
vector_size
,
1
>
{}([
&
](
auto
i
)
{
right_vec
.
template
AsType
<
bf6x16_pk_t
>()(
Number
<
i
>
{})
=
bf6x16_pk_t
{}.
pack
(
test_vec
.
data
()
+
i
*
packed_size
);
bf6x16_pk_t
{}.
pack
<
vector_size
,
packed_size
>
(
test_vec
.
data
()
+
i
*
packed_size
);
});
// copy the vector
vector_type
<
bf6x16_pk_t
,
vector_size
>
left_vec
{
right_vec
};
...
...
@@ -348,7 +349,8 @@ TEST(BF6, TestAsType32x1)
});
// assign test values to the vector
ck
::
static_for
<
0
,
vector_size
,
1
>
{}([
&
](
auto
i
)
{
right_vec
.
template
AsType
<
bf6x32_pk_t
>()(
Number
<
i
>
{})
=
bf6x32_pk_t
{}.
pack
(
test_vec
.
data
());
right_vec
.
template
AsType
<
bf6x32_pk_t
>()(
Number
<
i
>
{})
=
bf6x32_pk_t
{}.
pack
<
vector_size
,
packed_size
>
(
test_vec
.
data
());
});
// copy the vector
vector_type
<
bf6x32_pk_t
,
vector_size
>
left_vec
{
right_vec
};
...
...
test/data_type/test_fp6.cpp
View file @
2a807013
...
...
@@ -269,7 +269,8 @@ TEST(FP6, TestAsType16x1)
});
// assign test values to the vector
ck
::
static_for
<
0
,
vector_size
,
1
>
{}([
&
](
auto
i
)
{
right_vec
.
template
AsType
<
f6x16_pk_t
>()(
Number
<
i
>
{})
=
f6x16_pk_t
{}.
pack
(
test_vec
.
data
());
right_vec
.
template
AsType
<
f6x16_pk_t
>()(
Number
<
i
>
{})
=
f6x16_pk_t
{}.
pack
<
vector_size
,
packed_size
>
(
test_vec
.
data
());
});
// copy the vector
vector_type
<
f6x16_pk_t
,
vector_size
>
left_vec
{
right_vec
};
...
...
@@ -308,7 +309,7 @@ TEST(FP6, TestAsType16x2)
// assign test values to the vector
ck
::
static_for
<
0
,
vector_size
,
1
>
{}([
&
](
auto
i
)
{
right_vec
.
template
AsType
<
f6x16_pk_t
>()(
Number
<
i
>
{})
=
f6x16_pk_t
{}.
pack
(
test_vec
.
data
()
+
i
*
packed_size
);
f6x16_pk_t
{}.
pack
<
vector_size
,
packed_size
>
(
test_vec
.
data
()
+
i
*
packed_size
);
});
// copy the vector
vector_type
<
f6x16_pk_t
,
vector_size
>
left_vec
{
right_vec
};
...
...
@@ -345,7 +346,8 @@ TEST(FP6, TestAsType32x1)
});
// assign test values to the vector
ck
::
static_for
<
0
,
vector_size
,
1
>
{}([
&
](
auto
i
)
{
right_vec
.
template
AsType
<
f6x32_pk_t
>()(
Number
<
i
>
{})
=
f6x32_pk_t
{}.
pack
(
test_vec
.
data
());
right_vec
.
template
AsType
<
f6x32_pk_t
>()(
Number
<
i
>
{})
=
f6x32_pk_t
{}.
pack
<
vector_size
,
packed_size
>
(
test_vec
.
data
());
});
// copy the vector
vector_type
<
f6x32_pk_t
,
vector_size
>
left_vec
{
right_vec
};
...
...
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