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
4ea39116
"...lm-evaluation-harness.git" did not exist on "20c10dfe2729c99d86eb94cd35ea05e9634aa417"
Commit
4ea39116
authored
Nov 10, 2023
by
Khalique Ahmed
Browse files
manual merge
parents
20128cae
d8011adf
Changes
315
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
237 additions
and
42 deletions
+237
-42
src/api/include/migraphx/migraphx.hpp
src/api/include/migraphx/migraphx.hpp
+7
-1
src/api/migraphx.py
src/api/migraphx.py
+5
-0
src/compile_src.cpp
src/compile_src.cpp
+1
-1
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+6
-1
src/driver/argument_parser.hpp
src/driver/argument_parser.hpp
+7
-0
src/driver/main.cpp
src/driver/main.cpp
+42
-26
src/driver/verify.cpp
src/driver/verify.cpp
+36
-0
src/driver/verify.hpp
src/driver/verify.hpp
+6
-0
src/dynamic_loader.cpp
src/dynamic_loader.cpp
+58
-0
src/include/migraphx/argument.hpp
src/include/migraphx/argument.hpp
+1
-1
src/include/migraphx/auto_register.hpp
src/include/migraphx/auto_register.hpp
+3
-4
src/include/migraphx/compile_src.hpp
src/include/migraphx/compile_src.hpp
+12
-2
src/include/migraphx/config.hpp
src/include/migraphx/config.hpp
+1
-0
src/include/migraphx/dynamic_loader.hpp
src/include/migraphx/dynamic_loader.hpp
+2
-0
src/include/migraphx/filesystem.hpp
src/include/migraphx/filesystem.hpp
+11
-0
src/include/migraphx/float_equal.hpp
src/include/migraphx/float_equal.hpp
+0
-3
src/include/migraphx/generate.hpp
src/include/migraphx/generate.hpp
+2
-2
src/include/migraphx/instruction_ref.hpp
src/include/migraphx/instruction_ref.hpp
+35
-1
src/include/migraphx/matcher.hpp
src/include/migraphx/matcher.hpp
+1
-0
src/include/migraphx/module.hpp
src/include/migraphx/module.hpp
+1
-0
No files found.
src/api/include/migraphx/migraphx.hpp
View file @
4ea39116
...
...
@@ -66,7 +66,7 @@ template <class PrivateMigraphTypeNameProbe>
std
::
string
compute_type_name
()
{
std
::
string
name
;
#ifdef
_MSC_VER
#if
def
ined(
_MSC_VER
) && !defined(__clang__)
name
=
typeid
(
PrivateMigraphTypeNameProbe
).
name
();
name
=
name
.
substr
(
7
);
#else
...
...
@@ -1321,6 +1321,12 @@ struct onnx_options : MIGRAPHX_HANDLE_BASE(onnx_options)
{
call
(
&
migraphx_onnx_options_set_default_loop_iterations
,
this
->
get_handle_ptr
(),
value
);
}
/// Set max iteration limit for the loop operator
void
set_limit_loop_iterations
(
int64_t
value
)
{
call
(
&
migraphx_onnx_options_set_limit_loop_iterations
,
this
->
get_handle_ptr
(),
value
);
}
};
/// Parse an onnx file into a migraphx program
...
...
src/api/migraphx.py
View file @
4ea39116
...
...
@@ -349,6 +349,11 @@ def onnx_options(h):
api
.
params
(
value
=
'int64_t'
),
invoke
=
'migraphx::set_default_loop_iterations($@)'
,
)
h
.
method
(
'set_limit_loop_iterations'
,
api
.
params
(
value
=
'int64_t'
),
invoke
=
'migraphx::set_limit_loop_iterations($@)'
,
)
@
auto_handle
()
...
...
src/compile_src.cpp
View file @
4ea39116
...
...
@@ -46,7 +46,7 @@ std::vector<char> src_compiler::compile(const std::vector<src_file>& srcs) const
fs
::
path
full_path
=
td
.
path
/
src
.
path
;
fs
::
path
parent_path
=
full_path
.
parent_path
();
fs
::
create_directories
(
parent_path
);
write_buffer
(
full_path
.
string
(),
src
.
content
.
first
,
src
.
len
());
write_buffer
(
full_path
.
string
(),
src
.
content
.
data
(),
src
.
content
.
size
());
if
(
src
.
path
.
extension
().
string
()
==
".cpp"
)
{
params
+=
" "
+
src
.
path
.
filename
().
string
();
...
...
src/driver/CMakeLists.txt
View file @
4ea39116
...
...
@@ -48,7 +48,12 @@ rocm_clang_tidy_check(driver)
file
(
STRINGS
"
${
CMAKE_SOURCE_DIR
}
/test/onnx/.onnxrt-commit"
String_output
)
target_compile_definitions
(
driver PUBLIC MIGRAPHX_ORT_SHA1=
"
${
String_output
}
"
)
target_link_libraries
(
driver migraphx_all_targets migraphx_onnx migraphx_tf migraphx_py
)
target_link_libraries
(
driver migraphx_all_targets migraphx_onnx migraphx_tf
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
target_link_libraries
(
driver migraphx_py
)
target_compile_definitions
(
driver PRIVATE MIGRAPHX_ENABLE_PYTHON
)
endif
()
rocm_install_targets
(
TARGETS driver
...
...
src/driver/argument_parser.hpp
View file @
4ea39116
...
...
@@ -187,6 +187,13 @@ struct value_parser
}
};
// version for std::optional object
template
<
class
T
>
struct
value_parser
<
std
::
optional
<
T
>>
{
static
T
apply
(
const
std
::
string
&
x
)
{
return
value_parser
<
T
>::
apply
(
x
);
}
};
struct
argument_parser
{
struct
argument
...
...
src/driver/main.cpp
View file @
4ea39116
...
...
@@ -32,7 +32,9 @@
#include <migraphx/tf.hpp>
#include <migraphx/onnx.hpp>
#ifdef MIGRAPHX_ENABLE_PYTHON
#include <migraphx/py.hpp>
#endif
#include <migraphx/stringutils.hpp>
#include <migraphx/convert_to_json.hpp>
#include <migraphx/load_save.hpp>
...
...
@@ -57,6 +59,13 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
std
::
string
get_version
()
{
return
"MIGraphX Version: "
+
std
::
to_string
(
MIGRAPHX_VERSION_MAJOR
)
+
"."
+
std
::
to_string
(
MIGRAPHX_VERSION_MINOR
)
+
"."
+
std
::
to_string
(
MIGRAPHX_VERSION_PATCH
)
+
"."
MIGRAPHX_VERSION_TWEAK
;
}
struct
loader
{
std
::
string
model
;
...
...
@@ -281,10 +290,12 @@ struct loader
options
.
format
=
"json"
;
p
=
migraphx
::
load
(
file
,
options
);
}
#ifdef MIGRAPHX_ENABLE_PYTHON
else
if
(
file_type
==
"py"
)
{
p
=
migraphx
::
load_py
(
file
);
}
#endif
else
if
(
file_type
==
"migraphx"
)
{
p
=
migraphx
::
load
(
file
);
...
...
@@ -536,19 +547,17 @@ struct params : command<params>
struct
verify
:
command
<
verify
>
{
compiler
c
;
migraphx
::
verify
::
tolerance
tols
;
std
::
optional
<
double
>
rms_tol
;
std
::
optional
<
double
>
atol
;
std
::
optional
<
double
>
rtol
;
bool
per_instruction
=
false
;
bool
reduce
=
false
;
void
parse
(
argument_parser
&
ap
)
{
c
.
parse
(
ap
);
ap
(
tols
.
rms_tol
,
{
"--rms-tol"
},
ap
.
help
(
"Tolerance for the RMS error (Default: 0.001)"
));
ap
(
tols
.
atol
,
{
"--atol"
},
ap
.
help
(
"Tolerance for the elementwise absolute difference (Default: 0.001)"
));
ap
(
tols
.
rtol
,
{
"--rtol"
},
ap
.
help
(
"Tolerance for the elementwise relative difference (Default: 0.001)"
));
ap
(
rms_tol
,
{
"--rms-tol"
},
ap
.
help
(
"Tolerance for the RMS error"
));
ap
(
atol
,
{
"--atol"
},
ap
.
help
(
"Tolerance for the elementwise absolute difference"
));
ap
(
rtol
,
{
"--rtol"
},
ap
.
help
(
"Tolerance for the elementwise relative difference"
));
ap
(
per_instruction
,
{
"-i"
,
"--per-instruction"
},
ap
.
help
(
"Verify each instruction"
),
...
...
@@ -567,9 +576,18 @@ struct verify : command<verify>
auto
quantize
=
precision
::
fp32
;
if
(
c
.
to_fp16
)
{
quantize
=
precision
::
fp16
;
}
if
(
c
.
to_int8
)
{
quantize
=
precision
::
int8
;
}
auto
tols
=
get_tolerances
(
p
,
quantize
,
rms_tol
,
atol
,
rtol
);
std
::
cout
<<
"rms_tol: "
<<
tols
.
rms_tol
<<
std
::
endl
;
std
::
cout
<<
"atol: "
<<
tols
.
atol
<<
std
::
endl
;
std
::
cout
<<
"rtol: "
<<
tols
.
rtol
<<
std
::
endl
;
if
(
per_instruction
)
{
...
...
@@ -586,17 +604,6 @@ struct verify : command<verify>
}
};
struct
version
:
command
<
version
>
{
void
parse
(
const
argument_parser
&
)
{}
void
run
()
const
{
std
::
cout
<<
"MIGraphX Version: "
<<
MIGRAPHX_VERSION_MAJOR
<<
"."
<<
MIGRAPHX_VERSION_MINOR
<<
"."
<<
MIGRAPHX_VERSION_PATCH
<<
"."
<<
MIGRAPHX_STRINGIZE
(
MIGRAPHX_VERSION_TWEAK
)
<<
std
::
endl
;
}
};
struct
compile
:
command
<
compile
>
{
compiler
c
;
...
...
@@ -749,16 +756,14 @@ struct main_command
}
void
parse
(
argument_parser
&
ap
)
{
std
::
string
version_str
=
"MIGraphX Version: "
+
std
::
to_string
(
MIGRAPHX_VERSION_MAJOR
)
+
"."
+
std
::
to_string
(
MIGRAPHX_VERSION_MINOR
)
+
"."
+
std
::
to_string
(
MIGRAPHX_VERSION_PATCH
)
+
"."
+
MIGRAPHX_STRINGIZE
(
MIGRAPHX_VERSION_TWEAK
);
std
::
string
version_str
=
get_version
();
ap
(
wrong_commands
,
{},
ap
.
metavar
(
"<command>"
),
ap
.
append
());
ap
(
nullptr
,
{
"-h"
,
"--help"
},
ap
.
help
(
"Show help"
),
ap
.
show_help
(
get_command_help
()));
ap
(
nullptr
,
{
"-v"
,
"--version"
},
ap
.
help
(
"Show MIGraphX version"
),
ap
.
show_help
(
version_str
));
ap
(
nullptr
,
{
"--ort-sha"
},
ap
.
help
(
"Show MIGraphX onnx runtime SHA"
));
// Trim command off of exe name
ap
.
set_exe_name
(
ap
.
get_exe_name
().
substr
(
0
,
ap
.
get_exe_name
().
size
()
-
5
));
...
...
@@ -801,7 +806,6 @@ using namespace migraphx::driver; // NOLINT
int
main
(
int
argc
,
const
char
*
argv
[])
{
std
::
vector
<
std
::
string
>
args
(
argv
+
1
,
argv
+
argc
);
// no argument, print the help infomration by default
if
(
args
.
empty
())
{
...
...
@@ -811,15 +815,27 @@ int main(int argc, const char* argv[])
auto
&&
m
=
get_commands
();
auto
cmd
=
args
.
front
();
if
(
cmd
==
"ort-sha"
)
if
(
cmd
==
"
--
ort-sha"
)
{
std
::
cout
<<
MIGRAPHX_ORT_SHA1
<<
std
::
endl
;
return
0
;
}
if
(
cmd
==
"-v"
or
cmd
==
"--version"
)
{
std
::
cout
<<
get_version
()
<<
std
::
endl
;
return
0
;
}
if
(
m
.
count
(
cmd
)
>
0
)
{
m
.
at
(
cmd
)(
argv
[
0
],
{
args
.
begin
()
+
1
,
args
.
end
()});
std
::
string
driver_invocation
=
std
::
string
(
argv
[
0
])
+
" "
+
migraphx
::
to_string_range
(
args
,
" "
);
std
::
cout
<<
"Running [ "
<<
get_version
()
<<
" ]: "
<<
driver_invocation
<<
std
::
endl
;
m
.
at
(
cmd
)(
argv
[
0
],
{
args
.
begin
()
+
1
,
args
.
end
()});
// run driver command found in commands map
std
::
cout
<<
"[ "
<<
get_version
()
<<
" ] Complete: "
<<
driver_invocation
<<
std
::
endl
;
}
else
{
...
...
src/driver/verify.cpp
View file @
4ea39116
...
...
@@ -36,6 +36,42 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
/**
* Gives tolerances based on user input (`rms_tol`, `atol`, `rtol` parameters) and defaults.
* Sets to fp16 tolerances if `quantize` input is fp16 or any fp16 instruction in found in the
* model.
*/
verify
::
tolerance
get_tolerances
(
const
program
&
p
,
precision
quantize
,
std
::
optional
<
double
>
rms_tol
,
std
::
optional
<
double
>
atol
,
std
::
optional
<
double
>
rtol
)
{
bool
has_fp16
=
any_of
(
p
.
get_modules
(),
[](
auto
&&
m
)
{
return
any_of
(
*
m
,
[](
auto
&&
ins
)
{
return
(
ins
.
get_shape
().
type
()
==
shape
::
half_type
);
});
});
migraphx
::
verify
::
tolerance
result
{};
if
(
has_fp16
or
quantize
==
precision
::
fp16
)
{
result
.
rms_tol
=
8e-2
;
result
.
atol
=
4e-2
;
result
.
rtol
=
4e-2
;
}
if
(
rms_tol
)
{
result
.
rms_tol
=
*
rms_tol
;
}
if
(
atol
)
{
result
.
atol
=
*
atol
;
}
if
(
rtol
)
{
result
.
rtol
=
*
rtol
;
}
return
result
;
}
std
::
vector
<
argument
>
run_ref
(
program
p
,
const
parameter_map
&
inputs
)
{
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
...
...
src/driver/verify.hpp
View file @
4ea39116
...
...
@@ -32,6 +32,12 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
verify
::
tolerance
get_tolerances
(
const
program
&
p
,
precision
quantize
,
std
::
optional
<
double
>
rms_tol
,
std
::
optional
<
double
>
atol
,
std
::
optional
<
double
>
rtol
);
void
verify_program
(
const
std
::
string
&
name
,
const
program
&
p
,
const
target
&
t
,
...
...
src/dynamic_loader.cpp
View file @
4ea39116
...
...
@@ -27,11 +27,20 @@
#include <migraphx/file_buffer.hpp>
#include <migraphx/tmp_dir.hpp>
#include <utility>
#ifdef _WIN32
// cppcheck-suppress definePrefix
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#include <dlfcn.h>
#endif
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
#ifndef _WIN32
void
check_load_error
(
bool
flush
=
false
)
{
char
*
error_msg
=
dlerror
();
...
...
@@ -81,6 +90,48 @@ fs::path dynamic_loader::path(void* address)
return
p
;
}
#else
struct
dynamic_loader_impl
{
dynamic_loader_impl
()
=
default
;
dynamic_loader_impl
(
const
fs
::
path
&
p
,
tmp_dir
t
=
{})
:
handle
{
LoadLibrary
(
p
.
string
().
c_str
())},
temp
{
std
::
move
(
t
)}
{
if
(
handle
==
nullptr
)
{
MIGRAPHX_THROW
(
"Error loading DLL: "
+
p
.
string
()
+
" ("
+
std
::
to_string
(
GetLastError
())
+
")"
);
}
}
dynamic_loader_impl
(
const
dynamic_loader_impl
&
)
=
delete
;
dynamic_loader_impl
&
operator
=
(
const
dynamic_loader_impl
&
)
=
delete
;
dynamic_loader_impl
(
dynamic_loader_impl
&&
)
=
default
;
~
dynamic_loader_impl
()
{
if
(
handle
!=
nullptr
)
{
FreeLibrary
(
handle
);
}
}
static
std
::
shared_ptr
<
dynamic_loader_impl
>
from_buffer
(
const
char
*
image
,
std
::
size_t
size
)
{
auto
t
=
tmp_dir
{
"migx-dynload"
};
auto
f
=
t
.
path
/
"tmp.dll"
;
write_buffer
(
f
.
string
(),
image
,
size
);
return
std
::
make_shared
<
dynamic_loader_impl
>
(
f
,
std
::
move
(
t
));
}
HMODULE
handle
=
nullptr
;
tmp_dir
temp
;
};
#endif
optional
<
dynamic_loader
>
dynamic_loader
::
try_load
(
const
fs
::
path
&
p
)
{
try
...
...
@@ -109,12 +160,19 @@ dynamic_loader::dynamic_loader(const std::vector<char>& buffer)
std
::
shared_ptr
<
void
>
dynamic_loader
::
get_symbol
(
const
std
::
string
&
name
)
const
{
#ifndef _WIN32
// flush any previous error messages
check_load_error
(
true
);
void
*
symbol
=
dlsym
(
impl
->
handle
.
get
(),
name
.
c_str
());
if
(
symbol
==
nullptr
)
check_load_error
();
return
{
impl
,
symbol
};
#else
FARPROC
addr
=
GetProcAddress
(
impl
->
handle
,
name
.
c_str
());
if
(
addr
==
nullptr
)
MIGRAPHX_THROW
(
"Symbol not found: "
+
name
+
" ("
+
std
::
to_string
(
GetLastError
())
+
")"
);
return
{
impl
,
reinterpret_cast
<
void
*>
(
addr
)};
#endif
}
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/include/migraphx/argument.hpp
View file @
4ea39116
...
...
@@ -46,7 +46,7 @@ struct MIGRAPHX_EXPORT argument : raw_data<argument>
{
argument
()
=
default
;
argument
(
const
shape
&
s
);
explicit
argument
(
const
shape
&
s
);
template
<
class
F
,
MIGRAPHX_REQUIRES
(
std
::
is_pointer
<
decltype
(
std
::
declval
<
F
>()())
>
{})
>
argument
(
shape
s
,
F
d
)
...
...
src/include/migraphx/auto_register.hpp
View file @
4ea39116
...
...
@@ -62,10 +62,9 @@ const int auto_register<Action, T>::static_register = auto_register_action<Actio
#define MIGRAPHX_AUTO_REGISTER_NAME_DETAIL(x) migraphx_auto_register_##x
#define MIGRAPHX_AUTO_REGISTER_NAME(x) MIGRAPHX_AUTO_REGISTER_NAME_DETAIL(x)
// NOLINTNEXTLINE
#define MIGRAPHX_AUTO_REGISTER(...) \
void MIGRAPHX_AUTO_REGISTER_NAME(__LINE__)(migraphx::auto_register<__VA_ARGS__> x = \
migraphx::auto_register<__VA_ARGS__>{}) \
__attribute__((unused));
#define MIGRAPHX_AUTO_REGISTER(...) \
[[maybe_unused]] void MIGRAPHX_AUTO_REGISTER_NAME(__LINE__)( \
migraphx::auto_register<__VA_ARGS__> x = migraphx::auto_register<__VA_ARGS__>{});
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/compile_src.hpp
View file @
4ea39116
...
...
@@ -37,8 +37,18 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
src_file
{
fs
::
path
path
;
std
::
pair
<
const
char
*
,
const
char
*>
content
;
std
::
size_t
len
()
const
{
return
content
.
second
-
content
.
first
;
}
std
::
string_view
content
;
src_file
()
=
default
;
src_file
(
fs
::
path
file_path
,
std
::
string_view
file_content
)
:
path
{
std
::
move
(
file_path
)},
content
{
file_content
}
{
}
explicit
src_file
(
const
std
::
pair
<
std
::
string_view
,
std
::
string_view
>&
pair
)
:
path
{
pair
.
first
},
content
{
pair
.
second
}
{
}
};
struct
MIGRAPHX_EXPORT
src_compiler
...
...
src/include/migraphx/config.hpp
View file @
4ea39116
...
...
@@ -25,6 +25,7 @@
#define MIGRAPHX_GUARD_CONFIG_HPP
#include <migraphx/export.h>
#include <ciso646>
#if !defined(MIGRAPHX_USE_CLANG_TIDY) && !defined(DOXYGEN)
...
...
src/include/migraphx/dynamic_loader.hpp
View file @
4ea39116
...
...
@@ -38,12 +38,14 @@ struct dynamic_loader_impl;
struct
MIGRAPHX_EXPORT
dynamic_loader
{
#ifndef _WIN32
template
<
class
T
>
static
fs
::
path
path
(
T
*
address
)
{
return
path
(
reinterpret_cast
<
void
*>
(
address
));
}
static
fs
::
path
path
(
void
*
address
);
#endif
static
optional
<
dynamic_loader
>
try_load
(
const
fs
::
path
&
p
);
...
...
src/include/migraphx/filesystem.hpp
View file @
4ea39116
...
...
@@ -29,6 +29,17 @@
#if defined(CPPCHECK)
#define MIGRAPHX_HAS_FILESYSTEM 1
#define MIGRAPHX_HAS_FILESYSTEM_TS 1
#elif defined(_WIN32)
#if _MSC_VER >= 1920
#define MIGRAPHX_HAS_FILESYSTEM 1
#define MIGRAPHX_HAS_FILESYSTEM_TS 0
#elif _MSC_VER >= 1900
#define MIGRAPHX_HAS_FILESYSTEM 0
#define MIGRAPHX_HAS_FILESYSTEM_TS 1
#else
#define MIGRAPHX_HAS_FILESYSTEM 0
#define MIGRAPHX_HAS_FILESYSTEM_TS 0
#endif
#elif defined(__has_include)
#if __has_include(<filesystem>) && __cplusplus >= 201703L
#define MIGRAPHX_HAS_FILESYSTEM 1
...
...
src/include/migraphx/float_equal.hpp
View file @
4ea39116
...
...
@@ -27,9 +27,6 @@
#include <algorithm>
#include <cmath>
#include <numeric>
#ifdef _MSC_VER
#include <iso646.h>
#endif
#include <migraphx/requires.hpp>
#include <migraphx/config.hpp>
...
...
src/include/migraphx/generate.hpp
View file @
4ea39116
...
...
@@ -48,7 +48,7 @@ constexpr T normalize(unsigned long z)
template
<
class
T
,
MIGRAPHX_REQUIRES
(
is_signed
<
T
>{}
and
not
is_floating_point
<
T
>
{})
>
constexpr
T
normalize
(
unsigned
long
z
)
{
const
auto
max
=
1UL
<<
(
sizeof
(
T
)
*
5
);
const
auto
max
=
1UL
L
<<
(
sizeof
(
T
)
*
5
);
const
auto
half_max
=
max
/
2
;
return
half_max
-
(
z
%
max
);
}
...
...
@@ -58,7 +58,7 @@ template <class T,
not
std
::
is_same
<
T
,
bool
>
{})
>
constexpr
T
normalize
(
unsigned
long
z
)
{
const
auto
max
=
1UL
<<
(
sizeof
(
T
)
*
5
);
const
auto
max
=
1UL
L
<<
(
sizeof
(
T
)
*
5
);
return
z
%
max
;
}
...
...
src/include/migraphx/instruction_ref.hpp
View file @
4ea39116
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-202
2
Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-202
3
Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -27,12 +27,42 @@
#include <list>
#include <functional>
#include <migraphx/config.hpp>
#include <migraphx/requires.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
instruction
;
#if defined(_WIN32) && !defined(NDEBUG)
struct
instruction_ref
:
std
::
list
<
instruction
>::
iterator
{
using
instruction_iter
=
std
::
list
<
instruction
>::
iterator
;
using
instruction_const_iter
=
std
::
list
<
instruction
>::
const_iterator
;
instruction_ref
()
=
default
;
instruction_ref
(
const
instruction_iter
&
other
)
:
instruction_iter
(
other
)
{}
template
<
class
T
,
class
U
,
MIGRAPHX_REQUIRES
(
std
::
is_same
<
T
,
instruction_ref
>{}
or
std
::
is_same
<
U
,
instruction_ref
>
{})
>
friend
bool
operator
==
(
const
T
&
x
,
const
U
&
y
)
{
return
x
.
_Unwrapped
().
_Ptr
==
y
.
_Unwrapped
().
_Ptr
;
}
template
<
class
T
,
class
U
,
MIGRAPHX_REQUIRES
(
std
::
is_same
<
T
,
instruction_ref
>{}
or
std
::
is_same
<
U
,
instruction_ref
>
{})
>
friend
bool
operator
!=
(
const
T
&
x
,
const
U
&
y
)
{
return
not
(
x
==
y
);
}
};
#else
using
instruction_ref
=
std
::
list
<
instruction
>::
iterator
;
#endif
MIGRAPHX_EXPORT
migraphx
::
instruction
*
as_address
(
const
instruction_ref
&
ins
)
noexcept
;
...
...
@@ -65,4 +95,8 @@ struct equal_to<migraphx::instruction_ref> // NOLINT
}
// namespace std
#ifdef _MSC_VER
#include <migraphx/instruction.hpp>
#endif
#endif
src/include/migraphx/matcher.hpp
View file @
4ea39116
...
...
@@ -33,6 +33,7 @@
#include <migraphx/type_name.hpp>
#include <migraphx/source_location.hpp>
#include <migraphx/config.hpp>
#include <array>
#include <unordered_map>
#include <unordered_set>
...
...
src/include/migraphx/module.hpp
View file @
4ea39116
...
...
@@ -42,6 +42,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
MIGRAPHX_EXPORT
const
operation
&
get_operation
(
instruction_ref
ins
);
struct
module_impl
;
...
...
Prev
1
2
3
4
5
6
…
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