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
e599063f
Commit
e599063f
authored
May 10, 2024
by
illsilin
Browse files
sync from the public repo
parents
5dbbf5d6
566b6480
Changes
301
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
include/ck_tile/core/numeric/integral_constant.hpp
include/ck_tile/core/numeric/integral_constant.hpp
+83
-0
No files found.
Too many changes to show.
To preserve performance only
301 of 301+
files are displayed.
Plain diff
Email patch
include/ck_tile/core/numeric/integral_constant.hpp
0 → 100644
View file @
e599063f
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
#pragma once
#include "ck_tile/core/config.hpp"
#include "ck_tile/core/numeric/integer.hpp"
namespace
ck_tile
{
template
<
auto
v
>
struct
constant
{
using
value_type
=
decltype
(
v
);
using
type
=
constant
;
// using injected-class-name
static
constexpr
value_type
value
=
v
;
CK_TILE_HOST_DEVICE
constexpr
operator
value_type
()
const
noexcept
{
return
value
;
}
CK_TILE_HOST_DEVICE
constexpr
value_type
operator
()()
const
noexcept
{
return
value
;
}
CK_TILE_HOST_DEVICE
static
constexpr
bool
is_static
()
{
return
true
;
}
};
template
<
typename
T
,
T
v
>
struct
integral_constant
:
constant
<
v
>
{
using
value_type
=
T
;
using
type
=
integral_constant
;
// using injected-class-name
static
constexpr
T
value
=
v
;
// constexpr CK_TILE_HOST_DEVICE operator value_type() const noexcept { return value; }
// constexpr CK_TILE_HOST_DEVICE value_type operator()() const noexcept { return value; } //
};
template
<
index_t
v
>
using
number
=
constant
<
v
>
;
template
<
long_index_t
v
>
using
long_number
=
constant
<
v
>
;
template
<
bool
b
>
using
bool_constant
=
constant
<
b
>
;
#define CK_TILE_LEFT_UNARY_OP(OP) \
template <auto x> \
CK_TILE_HOST_DEVICE constexpr auto operator OP(constant<x>) \
{ \
return constant<(OP x)>{}; \
}
#define CK_TILE_BINARY_OP(OP) \
template <auto x, auto y> \
CK_TILE_HOST_DEVICE constexpr auto operator OP(constant<x>, constant<y>) \
{ \
return constant<(x OP y)>{}; \
}
CK_TILE_LEFT_UNARY_OP
(
+
)
CK_TILE_LEFT_UNARY_OP
(
-
)
CK_TILE_LEFT_UNARY_OP
(
~
)
CK_TILE_LEFT_UNARY_OP
(
!
)
CK_TILE_LEFT_UNARY_OP
(
*
)
CK_TILE_BINARY_OP
(
+
)
CK_TILE_BINARY_OP
(
-
)
CK_TILE_BINARY_OP
(
*
)
CK_TILE_BINARY_OP
(
/
)
CK_TILE_BINARY_OP
(
%
)
CK_TILE_BINARY_OP
(
&
)
CK_TILE_BINARY_OP
(
|
)
CK_TILE_BINARY_OP
(
^
)
CK_TILE_BINARY_OP
(
<<
)
CK_TILE_BINARY_OP
(
>>
)
CK_TILE_BINARY_OP
(
&&
)
CK_TILE_BINARY_OP
(
||
)
CK_TILE_BINARY_OP
(
==
)
CK_TILE_BINARY_OP
(
!=
)
CK_TILE_BINARY_OP
(
>
)
CK_TILE_BINARY_OP
(
<
)
CK_TILE_BINARY_OP
(
>=
)
CK_TILE_BINARY_OP
(
<=
)
#undef CK_TILE_LEFT_UNARY_OP
#undef CK_TILE_BINARY_OP
}
// namespace ck_tile
Prev
1
…
12
13
14
15
16
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