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
23cb7917
Unverified
Commit
23cb7917
authored
Aug 16, 2023
by
Brian Pickrell
Committed by
GitHub
Aug 16, 2023
Browse files
Merge branch 'develop' into blas_tuning
parents
b5fcc0bc
ea32ca70
Changes
458
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
113 additions
and
55 deletions
+113
-55
src/include/migraphx/eliminate_contiguous.hpp
src/include/migraphx/eliminate_contiguous.hpp
+1
-1
src/include/migraphx/eliminate_data_type.hpp
src/include/migraphx/eliminate_data_type.hpp
+1
-1
src/include/migraphx/eliminate_identity.hpp
src/include/migraphx/eliminate_identity.hpp
+1
-1
src/include/migraphx/eliminate_pad.hpp
src/include/migraphx/eliminate_pad.hpp
+1
-1
src/include/migraphx/env.hpp
src/include/migraphx/env.hpp
+5
-5
src/include/migraphx/file_buffer.hpp
src/include/migraphx/file_buffer.hpp
+6
-4
src/include/migraphx/fuse_pointwise.hpp
src/include/migraphx/fuse_pointwise.hpp
+1
-1
src/include/migraphx/fuse_reduce.hpp
src/include/migraphx/fuse_reduce.hpp
+1
-1
src/include/migraphx/generate.hpp
src/include/migraphx/generate.hpp
+5
-5
src/include/migraphx/hash.hpp
src/include/migraphx/hash.hpp
+47
-0
src/include/migraphx/inline_module.hpp
src/include/migraphx/inline_module.hpp
+1
-1
src/include/migraphx/insert_pad.hpp
src/include/migraphx/insert_pad.hpp
+1
-1
src/include/migraphx/instruction.hpp
src/include/migraphx/instruction.hpp
+15
-9
src/include/migraphx/instruction_ref.hpp
src/include/migraphx/instruction_ref.hpp
+1
-1
src/include/migraphx/json.hpp
src/include/migraphx/json.hpp
+4
-4
src/include/migraphx/layout_nhwc.hpp
src/include/migraphx/layout_nhwc.hpp
+1
-1
src/include/migraphx/literal.hpp
src/include/migraphx/literal.hpp
+2
-2
src/include/migraphx/load_save.hpp
src/include/migraphx/load_save.hpp
+11
-8
src/include/migraphx/make_op.hpp
src/include/migraphx/make_op.hpp
+5
-5
src/include/migraphx/marker.hpp
src/include/migraphx/marker.hpp
+3
-3
No files found.
src/include/migraphx/eliminate_contiguous.hpp
View file @
23cb7917
...
...
@@ -36,7 +36,7 @@ struct module;
/**
* Remove contiguous instructions by checking if the operator can use non-standard shapes.
*/
struct
eliminate_contiguous
struct
MIGRAPHX_EXPORT
eliminate_contiguous
{
std
::
string
op_name
;
std
::
string
name
()
const
{
return
"eliminate_contiguous"
;
}
...
...
src/include/migraphx/eliminate_data_type.hpp
View file @
23cb7917
...
...
@@ -38,7 +38,7 @@ struct module;
* Remove data types. This will instert convert operators so the data type
* is not used by any operator.
*/
struct
eliminate_data_type
struct
MIGRAPHX_EXPORT
eliminate_data_type
{
std
::
set
<
shape
::
type_t
>
types
;
shape
::
type_t
target_type
;
...
...
src/include/migraphx/eliminate_identity.hpp
View file @
23cb7917
...
...
@@ -38,7 +38,7 @@ struct module;
* preserve the semantics of previous program state, therefore dead code elimination
* should not be used afterwards.
*/
struct
eliminate_identity
struct
MIGRAPHX_EXPORT
eliminate_identity
{
std
::
string
name
()
const
{
return
"eliminate_identity"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/eliminate_pad.hpp
View file @
23cb7917
...
...
@@ -39,7 +39,7 @@ struct module;
* Remove pads if they can be written as an
* attribute to another op (im2col, convolution, pooling)
*/
struct
eliminate_pad
struct
MIGRAPHX_EXPORT
eliminate_pad
{
std
::
string
name
()
const
{
return
"eliminate_pad"
;
}
...
...
src/include/migraphx/env.hpp
View file @
23cb7917
...
...
@@ -38,13 +38,13 @@ inline namespace MIGRAPHX_INLINE_NS {
static const char* value() { return #x; } \
}; // NOLINT
bool
enabled
(
const
char
*
name
);
bool
disabled
(
const
char
*
name
);
std
::
vector
<
std
::
string
>
env
(
const
char
*
name
);
MIGRAPHX_EXPORT
bool
enabled
(
const
char
*
name
);
MIGRAPHX_EXPORT
bool
disabled
(
const
char
*
name
);
MIGRAPHX_EXPORT
std
::
vector
<
std
::
string
>
env
(
const
char
*
name
);
std
::
size_t
value_of
(
const
char
*
name
,
std
::
size_t
fallback
=
0
);
MIGRAPHX_EXPORT
std
::
size_t
value_of
(
const
char
*
name
,
std
::
size_t
fallback
=
0
);
std
::
string
string_value_of
(
const
char
*
name
,
std
::
string
fallback
=
""
);
MIGRAPHX_EXPORT
std
::
string
string_value_of
(
const
char
*
name
,
std
::
string
fallback
=
""
);
template
<
class
T
>
bool
enabled
(
T
)
...
...
src/include/migraphx/file_buffer.hpp
View file @
23cb7917
...
...
@@ -31,11 +31,13 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
std
::
vector
<
char
>
read_buffer
(
const
std
::
string
&
filename
,
size_t
offset
=
0
,
size_t
nbytes
=
0
);
std
::
string
read_string
(
const
std
::
string
&
filename
);
MIGRAPHX_EXPORT
std
::
vector
<
char
>
read_buffer
(
const
std
::
string
&
filename
,
size_t
offset
=
0
,
size_t
nbytes
=
0
);
MIGRAPHX_EXPORT
std
::
string
read_string
(
const
std
::
string
&
filename
);
void
write_buffer
(
const
std
::
string
&
filename
,
const
char
*
buffer
,
std
::
size_t
size
);
void
write_buffer
(
const
std
::
string
&
filename
,
const
std
::
vector
<
char
>&
buffer
);
MIGRAPHX_EXPORT
void
write_buffer
(
const
std
::
string
&
filename
,
const
char
*
buffer
,
std
::
size_t
size
);
MIGRAPHX_EXPORT
void
write_buffer
(
const
std
::
string
&
filename
,
const
std
::
vector
<
char
>&
buffer
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/fuse_pointwise.hpp
View file @
23cb7917
...
...
@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
module_pass_manager
;
struct
fuse_pointwise
struct
MIGRAPHX_EXPORT
fuse_pointwise
{
std
::
string
name
()
const
{
return
"fuse_pointwise"
;
}
void
apply
(
module_pass_manager
&
mpm
)
const
;
...
...
src/include/migraphx/fuse_reduce.hpp
View file @
23cb7917
...
...
@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
module_pass_manager
;
struct
fuse_reduce
struct
MIGRAPHX_EXPORT
fuse_reduce
{
std
::
string
name
()
const
{
return
"fuse_reduce"
;
}
void
apply
(
module_pass_manager
&
mpm
)
const
;
...
...
src/include/migraphx/generate.hpp
View file @
23cb7917
...
...
@@ -117,20 +117,20 @@ auto generate_tensor_data(const migraphx::shape& s, unsigned long seed = 0)
}
template
<
class
T
>
auto
fill_tensor_data
(
const
migraphx
::
shape
&
s
,
unsigned
long
value
=
0
)
auto
fill_tensor_data
(
const
migraphx
::
shape
&
s
,
double
value
=
0
)
{
auto
result
=
make_shared_array
<
T
>
(
s
.
element_space
());
std
::
generate
(
result
.
get
(),
result
.
get
()
+
s
.
element_space
(),
[
=
]
{
return
value
;
});
return
result
;
}
argument
fill_argument
(
shape
s
,
unsigned
long
value
=
0
);
MIGRAPHX_EXPORT
argument
fill_argument
(
shape
s
,
double
value
=
0
);
argument
generate_argument
(
shape
s
,
unsigned
long
seed
=
0
);
MIGRAPHX_EXPORT
argument
generate_argument
(
shape
s
,
unsigned
long
seed
=
0
);
literal
generate_literal
(
shape
s
,
unsigned
long
seed
=
0
);
MIGRAPHX_EXPORT
literal
generate_literal
(
shape
s
,
unsigned
long
seed
=
0
);
literal
abs
(
literal
l
);
MIGRAPHX_EXPORT
literal
abs
(
literal
l
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/hash.hpp
0 → 100644
View file @
23cb7917
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MIGRAPHX_GUARD_MIGRAPHX_HASH_HPP
#define MIGRAPHX_GUARD_MIGRAPHX_HASH_HPP
#include <migraphx/config.hpp>
#include <functional>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
template
<
class
T
>
std
::
size_t
hash_value
(
const
T
&
v
)
{
return
std
::
hash
<
T
>
{}(
v
);
}
template
<
class
T
>
void
hash_combine
(
std
::
size_t
&
seed
,
const
T
&
v
)
{
seed
^=
hash_value
(
v
)
+
0x9e3779b9
+
(
seed
<<
6u
)
+
(
seed
>>
2u
);
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif // MIGRAPHX_GUARD_MIGRAPHX_HASH_HPP
src/include/migraphx/inline_module.hpp
View file @
23cb7917
...
...
@@ -33,7 +33,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
module
;
struct
inline_module
struct
MIGRAPHX_EXPORT
inline_module
{
std
::
string
name
()
const
{
return
"inline_module"
;
}
void
apply
(
module
&
m
)
const
;
...
...
src/include/migraphx/insert_pad.hpp
View file @
23cb7917
...
...
@@ -38,7 +38,7 @@ struct module;
/**
* insert pads if attribute of padding is asymmetrical
*/
struct
insert_pad
struct
MIGRAPHX_EXPORT
insert_pad
{
std
::
string
name
()
const
{
return
"insert_pad"
;
}
...
...
src/include/migraphx/instruction.hpp
View file @
23cb7917
...
...
@@ -37,14 +37,15 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
shape
compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
instruction_ref
>&
args
);
shape
compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
instruction_ref
>&
args
,
const
std
::
vector
<
module_ref
>&
mods
);
std
::
vector
<
shape
>
to_shapes
(
const
std
::
vector
<
instruction_ref
>&
args
);
std
::
vector
<
shape
>
try_compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
shape
>&
inputs
);
struct
instruction
MIGRAPHX_EXPORT
shape
compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
instruction_ref
>&
args
);
MIGRAPHX_EXPORT
shape
compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
instruction_ref
>&
args
,
const
std
::
vector
<
module_ref
>&
mods
);
MIGRAPHX_EXPORT
std
::
vector
<
shape
>
to_shapes
(
const
std
::
vector
<
instruction_ref
>&
args
);
MIGRAPHX_EXPORT
std
::
vector
<
shape
>
try_compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
shape
>&
inputs
);
struct
MIGRAPHX_EXPORT
instruction
{
instruction
()
{}
...
...
@@ -136,6 +137,10 @@ struct instruction
operation
normalized_operator
()
const
;
std
::
size_t
get_target_id
()
const
;
void
set_target_id
(
std
::
size_t
tid
);
void
debug_print
()
const
;
static
void
print
(
std
::
ostream
&
os
,
...
...
@@ -172,7 +177,8 @@ struct instruction
std
::
vector
<
instruction_ref
>
arguments
;
std
::
vector
<
module_ref
>
module_args
;
literal
lit
;
bool
normalized
=
false
;
bool
normalized
=
false
;
std
::
size_t
target_id
=
0
;
};
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/instruction_ref.hpp
View file @
23cb7917
...
...
@@ -34,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
instruction
;
using
instruction_ref
=
std
::
list
<
instruction
>::
iterator
;
migraphx
::
instruction
*
as_address
(
const
instruction_ref
&
ins
)
noexcept
;
MIGRAPHX_EXPORT
migraphx
::
instruction
*
as_address
(
const
instruction_ref
&
ins
)
noexcept
;
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/json.hpp
View file @
23cb7917
...
...
@@ -31,10 +31,10 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
std
::
string
to_pretty_json_string
(
const
value
&
val
,
std
::
size_t
indent
=
4
);
std
::
string
to_json_string
(
const
value
&
val
);
value
from_json_string
(
const
std
::
string
&
str
);
value
from_json_string
(
const
char
*
str
,
std
::
size_t
size
);
MIGRAPHX_EXPORT
std
::
string
to_pretty_json_string
(
const
value
&
val
,
std
::
size_t
indent
=
4
);
MIGRAPHX_EXPORT
std
::
string
to_json_string
(
const
value
&
val
);
MIGRAPHX_EXPORT
value
from_json_string
(
const
std
::
string
&
str
);
MIGRAPHX_EXPORT
value
from_json_string
(
const
char
*
str
,
std
::
size_t
size
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/layout_nhwc.hpp
View file @
23cb7917
...
...
@@ -36,7 +36,7 @@ struct module_pass_manager;
/**
* Transform convolutions to nhwc
*/
struct
layout_nhwc
struct
MIGRAPHX_EXPORT
layout_nhwc
{
std
::
string
name
()
const
{
return
"layout_nhwc"
;
}
void
apply
(
module_pass_manager
&
mpm
)
const
;
...
...
src/include/migraphx/literal.hpp
View file @
23cb7917
...
...
@@ -147,8 +147,8 @@ literal transform(literal l1, literal l2, F f)
return
result
;
}
void
migraphx_to_value
(
value
&
v
,
const
literal
&
l
);
void
migraphx_from_value
(
const
value
&
v
,
literal
&
l
);
MIGRAPHX_EXPORT
void
migraphx_to_value
(
value
&
v
,
const
literal
&
l
);
MIGRAPHX_EXPORT
void
migraphx_from_value
(
const
value
&
v
,
literal
&
l
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/load_save.hpp
View file @
23cb7917
...
...
@@ -36,15 +36,18 @@ struct file_options
std
::
string
format
=
"msgpack"
;
};
program
load
(
const
std
::
string
&
filename
,
const
file_options
&
options
=
file_options
{});
program
load_buffer
(
const
std
::
vector
<
char
>&
buffer
,
const
file_options
&
options
=
file_options
{});
program
load_buffer
(
const
char
*
buffer
,
std
::
size_t
size
,
const
file_options
&
options
=
file_options
{});
MIGRAPHX_EXPORT
program
load
(
const
std
::
string
&
filename
,
const
file_options
&
options
=
file_options
{});
MIGRAPHX_EXPORT
program
load_buffer
(
const
std
::
vector
<
char
>&
buffer
,
const
file_options
&
options
=
file_options
{});
MIGRAPHX_EXPORT
program
load_buffer
(
const
char
*
buffer
,
std
::
size_t
size
,
const
file_options
&
options
=
file_options
{});
void
save
(
const
program
&
p
,
const
std
::
string
&
filename
,
const
file_options
&
options
=
file_options
{});
std
::
vector
<
char
>
save_buffer
(
const
program
&
p
,
const
file_options
&
options
=
file_options
{});
MIGRAPHX_EXPORT
void
save
(
const
program
&
p
,
const
std
::
string
&
filename
,
const
file_options
&
options
=
file_options
{});
MIGRAPHX_EXPORT
std
::
vector
<
char
>
save_buffer
(
const
program
&
p
,
const
file_options
&
options
=
file_options
{});
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/make_op.hpp
View file @
23cb7917
...
...
@@ -33,10 +33,10 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
operation
make_op
(
const
std
::
string
&
name
);
operation
make_op
(
const
std
::
string
&
name
,
const
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
value
>>&
v
);
operation
make_op_from_value
(
const
std
::
string
&
name
,
const
value
&
v
);
MIGRAPHX_EXPORT
operation
make_op
(
const
std
::
string
&
name
);
MIGRAPHX_EXPORT
operation
make_op
(
const
std
::
string
&
name
,
const
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
value
>>&
v
);
MIGRAPHX_EXPORT
operation
make_op_from_value
(
const
std
::
string
&
name
,
const
value
&
v
);
// A template overload is added for migraphx::value so the initializer_list
// cannot be passed in directly. This is to enforce at compile-time that all
...
...
@@ -48,7 +48,7 @@ operation make_op(const std::string& name, const Value& v)
return
make_op_from_value
(
name
,
v
);
}
operation
make_json_op
(
const
std
::
string
&
name
,
const
std
::
string
&
s
);
MIGRAPHX_EXPORT
operation
make_json_op
(
const
std
::
string
&
name
,
const
std
::
string
&
s
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/marker.hpp
View file @
23cb7917
...
...
@@ -46,7 +46,7 @@ inline namespace MIGRAPHX_INLINE_NS {
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct
marker
struct
MIGRAPHX_EXPORT
marker
{
//
void
mark_start
(
instruction_ref
ins_ref
);
...
...
@@ -80,7 +80,7 @@ struct marker
{
using
std
::
swap
;
auto
*
derived
=
this
->
any_cast
<
PrivateDetailTypeErasedT
>
();
if
(
derived
and
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
derived
and
private_detail_te_handle_mem_var
.
u
se_count
()
==
1
)
{
*
derived
=
std
::
forward
<
PrivateDetailTypeErasedT
>
(
value
);
}
...
...
@@ -233,7 +233,7 @@ struct marker
private_detail_te_handle_base_type
&
private_detail_te_get_handle
()
{
assert
(
private_detail_te_handle_mem_var
!=
nullptr
);
if
(
not
private_detail_te_handle_mem_var
.
u
nique
()
)
if
(
private_detail_te_handle_mem_var
.
u
se_count
()
>
1
)
private_detail_te_handle_mem_var
=
private_detail_te_handle_mem_var
->
clone
();
return
*
private_detail_te_handle_mem_var
;
}
...
...
Prev
1
2
3
4
5
6
7
8
9
10
…
23
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