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
MIGraphX
Commits
3411649c
Commit
3411649c
authored
Nov 17, 2023
by
Umang Yadav
Browse files
remove non-JIT related code
parent
78ec77ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
156 deletions
+41
-156
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+1
-1
src/targets/gpu/compile_hip_code_object.cpp
src/targets/gpu/compile_hip_code_object.cpp
+0
-1
src/targets/gpu/kernels/include/migraphx/kernels/float8.hpp
src/targets/gpu/kernels/include/migraphx/kernels/float8.hpp
+36
-150
src/targets/gpu/kernels/include/migraphx/kernels/hip.hpp
src/targets/gpu/kernels/include/migraphx/kernels/hip.hpp
+1
-1
src/targets/gpu/kernels/include/migraphx/kernels/types.hpp
src/targets/gpu/kernels/include/migraphx/kernels/types.hpp
+3
-3
No files found.
src/targets/gpu/compile_hip.cpp
View file @
3411649c
...
@@ -199,7 +199,7 @@ std::vector<std::vector<char>> compile_hip_src_with_hiprtc(std::vector<hiprtc_sr
...
@@ -199,7 +199,7 @@ std::vector<std::vector<char>> compile_hip_src_with_hiprtc(std::vector<hiprtc_sr
{
{
hiprtc_program
prog
(
std
::
move
(
srcs
));
hiprtc_program
prog
(
std
::
move
(
srcs
));
auto
options
=
split_string
(
params
,
' '
);
auto
options
=
split_string
(
params
,
' '
);
options
.
push_back
(
"-DMIGRAPHX_
JIT_
USE_HIPRTC=1"
);
options
.
push_back
(
"-DMIGRAPHX_USE_HIPRTC=1"
);
// remove following three compilation flags for HIPRTC once fixes from hipRTC are available in
// remove following three compilation flags for HIPRTC once fixes from hipRTC are available in
if
(
enabled
(
MIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS
{}))
if
(
enabled
(
MIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS
{}))
{
{
...
...
src/targets/gpu/compile_hip_code_object.cpp
View file @
3411649c
...
@@ -197,7 +197,6 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
...
@@ -197,7 +197,6 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
options
.
params
+=
" -DMIGRAPHX_NGLOBAL="
+
std
::
to_string
(
options
.
global
);
options
.
params
+=
" -DMIGRAPHX_NGLOBAL="
+
std
::
to_string
(
options
.
global
);
options
.
params
+=
" -DMIGRAPHX_NLOCAL="
+
std
::
to_string
(
options
.
local
);
options
.
params
+=
" -DMIGRAPHX_NLOCAL="
+
std
::
to_string
(
options
.
local
);
options
.
params
+=
" -D__HIP_NO_F8_CONVERSIONS__=1"
;
options
.
params
+=
" "
+
join_strings
(
compiler_warnings
(),
" "
);
options
.
params
+=
" "
+
join_strings
(
compiler_warnings
(),
" "
);
options
.
params
+=
" -ftemplate-backtrace-limit=0"
;
options
.
params
+=
" -ftemplate-backtrace-limit=0"
;
options
.
params
+=
" -Werror"
;
options
.
params
+=
" -Werror"
;
...
...
src/targets/gpu/kernels/include/migraphx/kernels/float8.hpp
View file @
3411649c
...
@@ -30,34 +30,17 @@
...
@@ -30,34 +30,17 @@
#pragma clang diagnostic ignored "-Wc++20-extensions"
#pragma clang diagnostic ignored "-Wc++20-extensions"
#endif // __clang__
#endif // __clang__
// need to include hip_runtime.h otherwise it complains about __host__ and __device__
#if defined(MIGRAPHX_JIT_USE_HIPRTC)
#include <migraphx/kernels/hip.hpp>
#include <migraphx/kernels/hip.hpp>
#else
#include <hip/hip_runtime.h>
#endif
#define MIGRAPHX_HIP_DEVICE __device__
#define MIGRAPHX_HIP_DEVICE __device__
// We are clipping in down conversion by default
// We are clipping in down conversion by default
#define MIGRAPHX_F8_DOWNCAST_CLIPPING 1
#define MIGRAPHX_F8_DOWNCAST_CLIPPING 1
#if defined(MIGRAPHX_JIT_USE_HIPRTC)
#include <migraphx/kernels/types.hpp>
#include <migraphx/kernels/types.hpp>
using
uint8_t
=
migraphx
::
uint8_t
;
using
uint8_t
=
migraphx
::
uint8_t
;
using
uint16_t
=
migraphx
::
uint16_t
;
using
uint16_t
=
migraphx
::
uint16_t
;
using
uint32_t
=
migraphx
::
uint32_t
;
using
uint32_t
=
migraphx
::
uint32_t
;
#else
#include <cmath>
#include <cstdint>
#include <climits>
#include <cstring>
#include <iosfwd>
#include <limits>
#include <sstream>
#include <iostream>
#include <string>
#include <utility>
#endif
#include <migraphx/kernels/float8_impl.hpp>
#include <migraphx/kernels/float8_impl.hpp>
...
@@ -203,38 +186,6 @@ struct float8
...
@@ -203,38 +186,6 @@ struct float8
}
}
}
}
/*
// Constructor from half
explicit constexpr MIGRAPHX_HIP_DEVICE
float8(migraphx::half v,
migraphx::fp8::rounding_mode rm =
migraphx::fp8::rounding_mode::standard,
uint32_t rng = 0)
: float8((float)v, rm, rng)
{
}
// constructor from int
explicit constexpr MIGRAPHX_HIP_DEVICE
float8(int v,
migraphx::fp8::rounding_mode rm =
migraphx::fp8::rounding_mode::standard,
uint32_t rng = 0)
: float8((float)v, rm, rng)
{
}
// constructor from double
explicit constexpr MIGRAPHX_HIP_DEVICE
float8(double v,
migraphx::fp8::rounding_mode rm =
migraphx::fp8::rounding_mode::standard,
uint32_t rng = 0)
: float8((float)v, rm, rng)
{
}
*/
/**/
// convert to float
// convert to float
// #if defined(__gfx940__) || defined(__gfx941__) || defined(__gfx942__)
// #if defined(__gfx940__) || defined(__gfx941__) || defined(__gfx942__)
#if 0 // need constexpr operator(). This version can't be constexpr
#if 0 // need constexpr operator(). This version can't be constexpr
...
@@ -268,14 +219,6 @@ struct float8
...
@@ -268,14 +219,6 @@ struct float8
return
migraphx
::
fp8
::
impl
::
cast_from_f8
<
2
,
5
,
float
,
FNUZ
/*negative_zero_nan*/
>
(
data
);
return
migraphx
::
fp8
::
impl
::
cast_from_f8
<
2
,
5
,
float
,
FNUZ
/*negative_zero_nan*/
>
(
data
);
}
}
/*
// convert to half
explicit inline MIGRAPHX_HIP_DEVICE operator migraphx::half() const
{
return migraphx::half(float(*this)); // convert to float, then convert to f16
}
*/
// check for zero
// check for zero
inline
MIGRAPHX_HIP_DEVICE
constexpr
bool
is_zero
()
const
inline
MIGRAPHX_HIP_DEVICE
constexpr
bool
is_zero
()
const
{
{
...
@@ -300,15 +243,12 @@ struct float8
...
@@ -300,15 +243,12 @@ struct float8
{
{
if
(
T
==
migraphx
::
fp8
::
f8_type
::
bf8
)
if
(
T
==
migraphx
::
fp8
::
f8_type
::
bf8
)
{
{
return
(
data
==
0x7
d
)
||
(
data
==
0x7
e
)
||
(
data
==
0x7
f
)
||
(
data
==
0x
fd
)
||
return
(
data
==
0x7
D
)
or
(
data
==
0x7
E
)
or
(
data
==
0x7
F
)
or
(
data
==
0x
FD
)
or
(
data
==
0x
fe
)
||
(
data
==
0x
ff
);
(
data
==
0x
FE
)
or
(
data
==
0x
FF
);
}
}
else
else
{
{
return
(
data
==
0x79
)
||
(
data
==
0x7a
)
||
(
data
==
0x7b
)
||
(
data
==
0x7c
)
||
return
(
data
==
0x7F
)
or
(
data
==
0xFF
);
(
data
==
0x7d
)
||
(
data
==
0x7e
)
||
(
data
==
0x7f
)
||
(
data
==
0xf9
)
||
(
data
==
0xfa
)
||
(
data
==
0xfb
)
||
(
data
==
0xfc
)
||
(
data
==
0xfd
)
||
(
data
==
0xfe
)
||
(
data
==
0xff
);
}
}
}
}
}
}
...
@@ -324,11 +264,12 @@ struct float8
...
@@ -324,11 +264,12 @@ struct float8
{
{
if
(
T
==
migraphx
::
fp8
::
f8_type
::
bf8
)
if
(
T
==
migraphx
::
fp8
::
f8_type
::
bf8
)
{
{
return
(
data
==
0x7
c
)
||
(
data
==
0x
fc
);
return
(
data
==
0x7
C
)
or
(
data
==
0x
FC
);
}
}
else
else
{
{
return
(
data
==
0x78
)
||
(
data
==
0xf8
);
// no infinities in e4m3fn, represent them as NaNs
return
(
data
==
0x7F
)
or
(
data
==
0xFF
);
}
}
}
}
}
}
...
@@ -355,24 +296,12 @@ struct float8
...
@@ -355,24 +296,12 @@ struct float8
inline
MIGRAPHX_HIP_DEVICE
constexpr
float8
&
operator
=
(
const
float8
&
rhs
)
=
default
;
inline
MIGRAPHX_HIP_DEVICE
constexpr
float8
&
operator
=
(
const
float8
&
rhs
)
=
default
;
inline
MIGRAPHX_HIP_DEVICE
constexpr
float8
&
operator
=
(
float8
&&
rhs
)
=
default
;
inline
MIGRAPHX_HIP_DEVICE
constexpr
float8
&
operator
=
(
float8
&&
rhs
)
=
default
;
#if !defined(__HIP_NO_F8_CONVERSIONS__)
// for the device kernels, this needs to be disabled since implicit_conversion op can type cast
// any type to any other type and that results in conflicts in candidate overload resolutions.
inline
constexpr
float8
&
MIGRAPHX_HIP_DEVICE
operator
=
(
float
rhs
)
{
*
this
=
static_cast
<
float8
>
(
rhs
);
return
*
this
;
}
#endif
inline
MIGRAPHX_HIP_DEVICE
constexpr
bool
operator
==
(
const
float8
&
rhs
)
const
inline
MIGRAPHX_HIP_DEVICE
constexpr
bool
operator
==
(
const
float8
&
rhs
)
const
{
{
if
((
rhs
.
is_zero
()
&&
this
->
is_zero
())
||
if
(
rhs
.
is_nan
()
or
rhs
.
is_inf
()
or
this
->
is_nan
()
or
this
->
is_inf
())
(
fabs
(
rhs
-
*
this
)
<
migraphx
::
fp8
::
numeric_limits
<
float8
<
T
>>::
epsilon
()))
return
true
;
else
if
(
rhs
.
is_nan
()
||
rhs
.
is_inf
()
||
this
->
is_nan
()
||
this
->
is_inf
())
return
false
;
return
false
;
else
if
((
rhs
.
is_zero
()
and
this
->
is_zero
())
or
(
this
->
data
==
rhs
.
data
))
return
true
;
return
false
;
return
false
;
}
}
...
@@ -391,15 +320,6 @@ struct float8
...
@@ -391,15 +320,6 @@ struct float8
}
}
};
};
#ifndef MIGRAPHX_JIT_USE_HIPRTC
// Special operator overloading
template
<
migraphx
::
fp8
::
f8_type
T
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
migraphx
::
fp8
::
float8
<
T
>&
rhs
)
{
return
os
<<
static_cast
<
float
>
(
rhs
);
}
#endif
// NOLINTNEXTLINE
// NOLINTNEXTLINE
#define MIGRAPHX_FP8_BINARY_OP(binary_op, U) \
#define MIGRAPHX_FP8_BINARY_OP(binary_op, U) \
template <migraphx::fp8::f8_type T> \
template <migraphx::fp8::f8_type T> \
...
@@ -422,8 +342,32 @@ MIGRAPHX_FP8_BINARY_OP(>, bool)
...
@@ -422,8 +342,32 @@ MIGRAPHX_FP8_BINARY_OP(>, bool)
MIGRAPHX_FP8_BINARY_OP
(
<
,
bool
)
MIGRAPHX_FP8_BINARY_OP
(
<
,
bool
)
MIGRAPHX_FP8_BINARY_OP
(
!=
,
bool
)
MIGRAPHX_FP8_BINARY_OP
(
!=
,
bool
)
template
<
migraphx
::
fp8
::
f8_type
T
>
// https://onnx.ai/onnx/technical/float8.html
inline
MIGRAPHX_HIP_DEVICE
migraphx
::
fp8
::
float8
<
T
>
fabs
(
migraphx
::
fp8
::
float8
<
T
>
v
)
using
fp8e4m3fn
=
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
,
false
>
;
using
fp8e5m2
=
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
,
false
>
;
using
fp8e4m3fnuz
=
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
,
true
>
;
using
fp8e5m2fnuz
=
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
,
true
>
;
;
inline
MIGRAPHX_HIP_DEVICE
fp8e4m3fnuz
fabs
(
fp8e4m3fnuz
v
)
{
v
.
data
=
v
.
data
&
0x7f
;
return
v
;
}
inline
MIGRAPHX_HIP_DEVICE
fp8e4m3fn
fabs
(
fp8e4m3fn
v
)
{
v
.
data
=
v
.
data
&
0x7f
;
return
v
;
}
inline
MIGRAPHX_HIP_DEVICE
fp8e5m2fnuz
fabs
(
fp8e5m2fnuz
v
)
{
v
.
data
=
v
.
data
&
0x7f
;
return
v
;
}
inline
MIGRAPHX_HIP_DEVICE
fp8e5m2
fabs
(
fp8e5m2
v
)
{
{
v
.
data
=
v
.
data
&
0x7f
;
v
.
data
=
v
.
data
&
0x7f
;
return
v
;
return
v
;
...
@@ -441,11 +385,6 @@ MIGRAPHX_HIP_DEVICE constexpr T F8_Lowest()
...
@@ -441,11 +385,6 @@ MIGRAPHX_HIP_DEVICE constexpr T F8_Lowest()
return
T
{
0xFF
,
T
::
from_bits
()};
return
T
{
0xFF
,
T
::
from_bits
()};
}
}
// https://onnx.ai/onnx/technical/float8.html
using
fp8e4m3fn
=
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
,
false
>
;
using
fp8e5m2
=
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
,
false
>
;
using
fp8e4m3fnuz
=
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
,
true
>
;
using
fp8e5m2fnuz
=
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
,
true
>
;
template
<
>
template
<
>
class
numeric_limits
<
fp8e4m3fnuz
>
class
numeric_limits
<
fp8e4m3fnuz
>
{
{
...
@@ -624,59 +563,6 @@ inline __host__ __device__ T explicit_downcast(Ta a, uint32_t rng)
...
@@ -624,59 +563,6 @@ inline __host__ __device__ T explicit_downcast(Ta a, uint32_t rng)
*/
*/
}
// namespace fp8
}
// namespace fp8
}
// namespace migraphx
}
// namespace migraphx
// define numeric limits for the new data type
#ifndef MIGRAPHX_JIT_USE_HIPRTC
namespace
std
{
inline
bool
isfinite
(
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
>
x
)
// NOLINT
{
return
x
.
is_inf
();
}
inline
bool
isfinite
(
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
>
x
)
// NOLINT
{
return
x
.
is_inf
();
}
inline
bool
isnan
(
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
>
x
)
// NOLINT
{
return
x
.
is_nan
();
}
inline
bool
isnan
(
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
>
x
)
// NOLINT
{
return
x
.
is_nan
();
}
template
<
>
class
numeric_limits
<
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
>>
:
public
migraphx
::
fp8
::
numeric_limits
<
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
fp8
>>
{
};
template
<
>
class
numeric_limits
<
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
>>
:
public
migraphx
::
fp8
::
numeric_limits
<
migraphx
::
fp8
::
float8
<
migraphx
::
fp8
::
f8_type
::
bf8
>>
{
};
template
<
class
T
>
struct
common_type
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
T
>
:
std
::
common_type
<
float
,
T
>
// NOLINT
{
};
template
<
class
T
>
struct
common_type
<
T
,
migraphx
::
fp8
::
fp8e4m3fnuz
>
:
std
::
common_type
<
float
,
T
>
// NOLINT
{
};
template
<
>
struct
common_type
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
migraphx
::
fp8
::
fp8e4m3fnuz
>
{
using
type
=
float
;
};
}
// namespace std
#endif
// =================================================================================================
// =================================================================================================
#if defined(__clang__)
#if defined(__clang__)
#pragma clang diagnostic pop
#pragma clang diagnostic pop
...
...
src/targets/gpu/kernels/include/migraphx/kernels/hip.hpp
View file @
3411649c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#ifndef MIGRAPHX_GUARD_KERNELS_HIP_HPP
#ifndef MIGRAPHX_GUARD_KERNELS_HIP_HPP
#define MIGRAPHX_GUARD_KERNELS_HIP_HPP
#define MIGRAPHX_GUARD_KERNELS_HIP_HPP
#ifndef MIGRAPHX_
JIT_
USE_HIPRTC
#ifndef MIGRAPHX_USE_HIPRTC
#include <hip/hip_runtime.h>
#include <hip/hip_runtime.h>
#include <hip/hip_fp16.h>
#include <hip/hip_fp16.h>
#include <hip/math_functions.h>
#include <hip/math_functions.h>
...
...
src/targets/gpu/kernels/include/migraphx/kernels/types.hpp
View file @
3411649c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
namespace
migraphx
{
namespace
migraphx
{
#if defined(MIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS) and defined(MIGRAPHX_
JIT_
USE_HIPRTC)
#if defined(MIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS) and defined(MIGRAPHX_USE_HIPRTC)
using
int8_t
=
signed
char
;
using
int8_t
=
signed
char
;
using
uint8_t
=
unsigned
char
;
using
uint8_t
=
unsigned
char
;
using
int16_t
=
signed
short
;
using
int16_t
=
signed
short
;
...
@@ -36,7 +36,7 @@ using int32_t = signed int;
...
@@ -36,7 +36,7 @@ using int32_t = signed int;
using
uint32_t
=
unsigned
int
;
using
uint32_t
=
unsigned
int
;
using
int64_t
=
signed
long
long
;
using
int64_t
=
signed
long
long
;
using
uint64_t
=
unsigned
long
long
;
using
uint64_t
=
unsigned
long
long
;
#elif defined(MIGRAPHX_
JIT_
USE_HIPRTC)
#elif defined(MIGRAPHX_USE_HIPRTC)
using
int8_t
=
__hip_int8_t
;
using
int8_t
=
__hip_int8_t
;
using
uint8_t
=
__hip_uint8_t
;
using
uint8_t
=
__hip_uint8_t
;
using
int16_t
=
__hip_int16_t
;
using
int16_t
=
__hip_int16_t
;
...
@@ -54,7 +54,7 @@ using int32_t = std::int32_t;
...
@@ -54,7 +54,7 @@ using int32_t = std::int32_t;
using
uint32_t
=
std
::
uint32_t
;
using
uint32_t
=
std
::
uint32_t
;
using
int64_t
=
std
::
int64_t
;
using
int64_t
=
std
::
int64_t
;
using
uint64_t
=
std
::
uint64_t
;
using
uint64_t
=
std
::
uint64_t
;
#endif // MIGRAPHX_
JIT_
USE_HIPRTC
#endif // MIGRAPHX_USE_HIPRTC
using
index_int
=
uint32_t
;
using
index_int
=
uint32_t
;
using
diff_int
=
int32_t
;
using
diff_int
=
int32_t
;
...
...
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