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
870a396b
Commit
870a396b
authored
Jan 23, 2023
by
Khalique Ahmed
Browse files
manual merge
parents
228b665c
d309e02f
Changes
473
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
333 additions
and
49 deletions
+333
-49
test/verify/test_sin_half.cpp
test/verify/test_sin_half.cpp
+4
-3
test/verify/test_slice_concat_add.cpp
test/verify/test_slice_concat_add.cpp
+47
-0
test/verify/test_softmax_large3.cpp
test/verify/test_softmax_large3.cpp
+43
-0
test/verify/test_trans_slice.cpp
test/verify/test_trans_slice.cpp
+17
-15
tools/accuracy/accuracy_checker.py
tools/accuracy/accuracy_checker.py
+3
-0
tools/accuracy/requirements.txt
tools/accuracy/requirements.txt
+1
-1
tools/api.py
tools/api.py
+51
-13
tools/api/api.cpp
tools/api/api.cpp
+32
-0
tools/api/migraphx.h
tools/api/migraphx.h
+0
-1
tools/convert_onnx_version.py
tools/convert_onnx_version.py
+88
-0
tools/include/context.hpp
tools/include/context.hpp
+9
-0
tools/include/operation.hpp
tools/include/operation.hpp
+37
-15
tools/install_prereqs.sh
tools/install_prereqs.sh
+1
-1
No files found.
test/verify/test_
elu
.cpp
→
test/verify/test_
sin_half
.cpp
View file @
870a396b
...
...
@@ -27,14 +27,15 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_
elu
:
verify_program
<
test_
elu
>
struct
test_
sin_half
:
verify_program
<
test_
sin_half
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"leaky_relu"
,
{{
"alpha"
,
1.0
}}),
x
);
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
10
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sin"
),
x
);
return
p
;
}
};
test/verify/test_slice_concat_add.cpp
0 → 100644
View file @
870a396b
/*
* 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.
*/
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_slice_concat_add
:
verify_program
<
test_slice_concat_add
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s0
{
migraphx
::
shape
::
float_type
,
{
1
,
24
,
2
,
2
}};
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
1
,
8
,
2
,
2
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s0
);
auto
y
=
mm
->
add_parameter
(
"y"
,
s1
);
auto
z
=
mm
->
add_parameter
(
"z"
,
s0
);
auto
slice
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
1
}},
{
"starts"
,
{
0
}},
{
"ends"
,
{
8
}}}),
x
);
auto
concat
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
1
}}),
slice
,
y
,
y
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
concat
,
z
);
return
p
;
}
};
test/verify/test_softmax_large3.cpp
0 → 100644
View file @
870a396b
/*
* 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.
*/
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/common.hpp>
struct
test_softmax_large3
:
verify_program
<
test_softmax_large3
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
4
}});
auto
large
=
mm
->
add_literal
({
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
{
100
}});
auto
add
=
migraphx
::
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
x
,
large
});
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
-
1
}}),
add
);
return
p
;
}
};
test/verify/test_
batchnorm_inferen
ce.cpp
→
test/verify/test_
trans_sli
ce.cpp
View file @
870a396b
...
...
@@ -27,27 +27,29 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_
batchnorm_inferen
ce
:
verify_program
<
test_
batchnorm_inferen
ce
>
struct
test_
trans_sli
ce
:
verify_program
<
test_
trans_sli
ce
>
{
const
size_t
width
=
3
;
const
size_t
height
=
3
;
const
size_t
channels
=
3
;
const
size_t
batches
=
4
;
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
batches
,
channels
,
height
,
width
}};
migraphx
::
shape
vars
{
migraphx
::
shape
::
float_type
,
{
channels
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
scale
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
1
)));
auto
bias
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
2
)));
auto
mean
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
3
)));
auto
variance
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
4
)));
mm
->
add_instruction
(
migraphx
::
make_op
(
"batch_norm_inference"
),
x
,
scale
,
bias
,
mean
,
variance
);
auto
x
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
384
,
36
,
64
}});
auto
transpose
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
2
,
1
,
3
}}}),
x
);
auto
slice1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
1
}},
{
"starts"
,
{
0
}},
{
"ends"
,
{
12
}}}),
transpose
);
auto
slice2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
1
}},
{
"starts"
,
{
12
}},
{
"ends"
,
{
24
}}}),
transpose
);
auto
transpose2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
slice2
);
auto
slice3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
1
}},
{
"starts"
,
{
24
}},
{
"ends"
,
{
36
}}}),
transpose
);
mm
->
add_return
({
slice1
,
transpose2
,
slice3
});
return
p
;
}
};
tools/accuracy/accuracy_checker.py
View file @
870a396b
...
...
@@ -116,6 +116,9 @@ def main():
model
=
migraphx
.
parse_onnx
(
model_name
,
default_dim_value
=
batch
)
if
args
.
verbose
:
print
(
model
)
model
.
compile
(
migraphx
.
get_target
(
'gpu'
),
offload_copy
=
False
)
params
=
{}
...
...
tools/accuracy/requirements.txt
View file @
870a396b
...
...
@@ -21,5 +21,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
numpy==1.
18.5
numpy==1.
21.6
onnxruntime==1.10.0
tools/api.py
View file @
870a396b
...
...
@@ -21,7 +21,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
import
string
,
sys
,
re
,
runpy
import
string
import
sys
import
re
import
runpy
from
functools
import
wraps
from
typing
import
Any
,
Callable
,
Dict
,
List
,
Optional
,
Tuple
,
Union
...
...
@@ -308,18 +311,39 @@ class Parameter:
return
self
.
substitute
(
'${type} ${name}'
,
prefix
=
prefix
)
def
virtual_output_args
(
self
,
prefix
:
Optional
[
str
]
=
None
)
->
List
[
str
]:
return
[
'&{prefix}{n}'
.
format
(
prefix
=
prefix
or
''
,
n
=
n
)
for
t
,
n
in
self
.
cparams
]
container_type
=
self
.
type
.
remove_generic
().
basic
().
str
()
decl_list
:
List
[
str
]
=
[]
container
=
(
container_type
==
"std::vector"
or
container_type
==
"vector"
)
for
t
,
n
,
in
self
.
cparams
:
if
not
decl_list
and
container
:
decl_list
.
append
(
'{prefix}{n}.data()'
.
format
(
prefix
=
prefix
or
''
,
n
=
n
))
else
:
decl_list
.
append
(
'&{prefix}{n}'
.
format
(
prefix
=
prefix
or
''
,
n
=
n
))
return
decl_list
def
virtual_output_declarations
(
self
,
prefix
:
Optional
[
str
]
=
None
)
->
List
[
str
]:
return
[
'std::remove_pointer_t<{type}> {prefix}{n};'
.
format
(
type
=
Type
(
t
).
str
(),
prefix
=
prefix
or
''
,
n
=
n
)
for
t
,
n
in
self
.
cparams
]
container_type
=
self
.
type
.
remove_generic
().
basic
().
str
()
container
=
(
container_type
==
"std::vector"
or
container_type
==
"vector"
)
decl_list
:
List
[
str
]
=
[]
for
t
,
n
,
in
self
.
cparams
:
if
not
decl_list
and
container
:
inner_t
=
self
.
type
.
inner_type
()
if
inner_t
:
decl_list
.
append
(
'std::array<{inner_t}, 1024> {prefix}{n};'
.
format
(
inner_t
=
inner_t
.
str
(),
prefix
=
prefix
or
''
,
n
=
n
))
else
:
decl_list
.
append
(
'std::remove_pointer_t<{type}> {prefix}{n}'
.
format
(
type
=
Type
(
t
).
str
(),
prefix
=
prefix
or
''
,
n
=
n
))
decl_list
[
-
1
]
+=
'=1024;'
if
container
else
';'
return
decl_list
def
virtual_output
(
self
,
prefix
:
Optional
[
str
]
=
None
)
->
str
:
write
=
self
.
virtual_write
...
...
@@ -694,9 +718,14 @@ def generate_cpp_header() -> str:
[
c
.
generate
()
for
c
in
cpp_classes
])
def
cwrap
(
name
:
str
)
->
Callable
:
c_type_map
:
Dict
[
str
,
Type
]
=
{}
def
cwrap
(
name
:
str
,
c_type
:
Optional
[
str
]
=
None
)
->
Callable
:
def
with_cwrap
(
f
):
type_map
[
name
]
=
f
if
c_type
:
c_type_map
[
name
]
=
Type
(
c_type
)
@
wraps
(
f
)
def
decorated
(
*
args
,
**
kwargs
):
...
...
@@ -917,6 +946,9 @@ def vector_c_wrap(p: Parameter) -> None:
# Not a generic type
if
not
inner
:
return
if
inner
.
str
()
in
c_type_map
:
inner
=
c_type_map
[
inner
.
str
()]
t
=
inner
.
add_pointer
()
if
p
.
type
.
is_reference
():
if
p
.
type
.
is_const
():
...
...
@@ -927,6 +959,12 @@ def vector_c_wrap(p: Parameter) -> None:
p
.
add_size_param
()
p
.
bad_param
(
'${name} == nullptr or ${size} == nullptr'
,
'Null pointer'
)
elif
p
.
virtual
:
p
.
add_param
(
t
)
p
.
add_size_param
()
p
.
bad_param
(
'${name} == nullptr or ${size} == nullptr'
,
'Null pointer'
)
p
.
virtual_write
=
'{${name}.begin(), ${name}.begin()+${size}}; // cppcheck-suppress returnDanglingLifetime'
else
:
p
.
add_param
(
t
)
p
.
bad_param
(
'${name} == nullptr'
,
'Null pointer'
)
...
...
@@ -946,7 +984,7 @@ def vector_c_wrap(p: Parameter) -> None:
p
.
write
=
[
'std::copy(${result}.begin(), ${result}.end(), ${name})'
]
@
cwrap
(
'std::string'
)
@
cwrap
(
'std::string'
,
'char*'
)
def
string_c_wrap
(
p
:
Parameter
)
->
None
:
t
=
Type
(
'char*'
)
if
p
.
returns
:
...
...
@@ -1061,9 +1099,9 @@ struct ${ctype} {
c_api_virtual_impl
=
Template
(
'''
${return_type} ${name}(${params}) const
{
${output_decls}
if (${fname} == nullptr)
throw std::runtime_error("${name} function is missing.");
${output_decls}
std::array<char, 256> exception_msg;
exception_msg.front() = '
\\
0';
auto api_error_result = ${fname}(${args});
...
...
tools/api/api.cpp
View file @
870a396b
...
...
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/execution_environment.hpp>
#include <migraphx/migraphx.h>
#include <migraphx/rank.hpp>
#include <migraphx/shape.hpp>
...
...
@@ -166,6 +167,13 @@ void set_output_names(tf_options& options, std::vector<const char*> names)
options
.
output_node_names
=
std
::
vector
<
std
::
string
>
(
names
.
begin
(),
names
.
end
());
}
std
::
vector
<
argument
>
run_async
(
program
&
p
,
const
parameter_map
&
params
,
void
*
s
,
std
::
string_view
name
)
{
execution_environment
exec_env
{
any_ptr
(
s
,
name
),
true
};
return
p
.
eval
(
params
,
exec_env
);
}
template
<
class
Value
>
std
::
vector
<
const
char
*>
get_names
(
const
std
::
unordered_map
<
std
::
string
,
Value
>&
m
)
{
...
...
@@ -265,11 +273,18 @@ struct experimental_custom_op
template
<
class
CustomOp
>
struct
custom_operation
{
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
,
F
)
{
return
pack
();
}
value
attributes
()
const
{
return
{{
"custom_op"
,
true
},
{
"target"
,
op
.
runs_on_offload_target
()
?
"gpu"
:
"cpu"
}};
}
CustomOp
op
;
std
::
string
name
()
const
{
return
op
.
xobject
.
name
;
}
...
...
@@ -284,6 +299,23 @@ struct custom_operation
{
return
op
.
compute
(
std
::
move
(
ctx
),
std
::
move
(
output_shape
),
std
::
move
(
inputs
));
}
std
::
ptrdiff_t
output_alias
(
std
::
vector
<
shape
>
inputs
)
const
{
auto
alias_vec
=
op
.
output_alias
(
std
::
move
(
inputs
));
// TODO: For now, only support one output alias
if
(
alias_vec
.
empty
())
{
return
-
1
;
}
if
(
alias_vec
.
size
()
>
1
)
{
MIGRAPHX_THROW
(
"Currently, CustomOps in MIGraphX only supports one output_alias"
);
}
return
alias_vec
.
front
();
}
bool
runs_on_offload_target
()
const
{
return
op
.
runs_on_offload_target
();
}
};
template
<
class
CustomOp
>
...
...
tools/api/migraphx.h
View file @
870a396b
...
...
@@ -26,7 +26,6 @@
#include <stdlib.h>
#include <stdbool.h>
// Add new types here
// clang-format off
#define MIGRAPHX_SHAPE_VISIT_TYPES(m) \
...
...
tools/convert_onnx_version.py
0 → 100644
View file @
870a396b
#####################################################################################
# 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.
#####################################################################################
import
argparse
import
onnx
from
onnx
import
version_converter
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
'MIGraphX Onnx Model Convertion. Use to convert the opset of the input model to MIGraphX
\'
s'
)
req_args
=
parser
.
add_argument_group
(
title
=
'required arguments'
)
req_args
.
add_argument
(
'--model'
,
type
=
str
,
required
=
True
,
help
=
'path to onnx file'
)
req_args
.
add_argument
(
'--output'
,
type
=
str
,
required
=
True
,
help
=
'path to output onnx file'
)
req_args
.
add_argument
(
'--opset'
,
type
=
int
,
required
=
True
,
help
=
'The output opset'
)
req_args
.
add_argument
(
'--infer_shapes'
,
action
=
'store_true'
,
help
=
'Infer shapes for output model'
)
parser
.
add_argument
(
'--verbose'
,
action
=
'store_true'
,
help
=
'show verbose information (for debugging)'
)
args
=
parser
.
parse_args
()
return
args
def
main
():
args
=
parse_args
()
model_path
=
args
.
model
out_model_path
=
args
.
output
target_opset
=
args
.
opset
verbose
=
args
.
verbose
infer_shapes
=
args
.
infer_shapes
original_model
=
onnx
.
load
(
model_path
)
if
verbose
:
print
(
f
"The model before conversion:
\n
{
original_model
}
"
)
# A full list of supported adapters can be found here:
# https://github.com/onnx/onnx/blob/main/onnx/version_converter.py#L21
# Apply the version conversion on the original model
converted_model
=
version_converter
.
convert_version
(
original_model
,
target_opset
)
if
infer_shapes
:
converted_model
=
onnx
.
shape_inference
.
infer_shapes
(
converted_model
)
if
verbose
:
print
(
f
"The model after conversion:
\n
{
converted_model
}
"
)
# Save the ONNX model
onnx
.
save
(
converted_model
,
out_model_path
)
if
__name__
==
'__main__'
:
main
()
tools/include/context.hpp
View file @
870a396b
...
...
@@ -66,12 +66,21 @@ any_ptr get_queue_context(T&)
{
return
{};
}
template
<
class
T
>
void
wait_for_context
(
T
&
,
any_ptr
)
{
}
template
<
class
T
>
void
finish_on_context
(
T
&
,
any_ptr
){}
<%
interface
(
'
context
'
,
virtual
(
'
to_value
'
,
returns
=
'
value
'
,
const
=
True
,
default
=
'
to_value_context
'
),
virtual
(
'
from_value
'
,
v
=
'
const
value
&
'
,
default
=
'
from_value_context
'
),
virtual
(
'
get_queue
'
,
returns
=
'
any_ptr
'
,
default
=
'
get_queue_context
'
),
virtual
(
'
wait_for
'
,
queue
=
'
any_ptr
'
,
returns
=
'
void
'
,
default
=
'
wait_for_context
'
),
virtual
(
'
finish_on
'
,
queue
=
'
any_ptr
'
,
returns
=
'
void
'
,
default
=
'
finish_on_context
'
),
virtual
(
'
finish
'
,
returns
=
'
void
'
,
const
=
True
))
%>
inline
void
migraphx_to_value
(
value
&
v
,
const
context
&
ctx
)
...
...
tools/include/operation.hpp
View file @
870a396b
...
...
@@ -32,6 +32,8 @@
#include <utility>
#include <unordered_map>
#include <migraphx/reflect.hpp>
#include <migraphx/dyn_output.hpp>
#include <migraphx/functional.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/normalize_attributes.hpp>
#include <migraphx/argument.hpp>
...
...
@@ -199,9 +201,12 @@ auto compute_op(rank<1>,
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
output_shape
,
input
))
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
make_compute_output_shape
(
pack
(
x
,
output_shape
,
input
)),
input
))
{
return
x
.
compute
(
auto_any_cast
(
ctx
),
output_shape
,
input
);
return
x
.
compute
(
auto_any_cast
(
ctx
),
make_compute_output_shape
(
pack
(
x
,
output_shape
,
input
)),
input
);
}
template
<
class
T
>
...
...
@@ -220,9 +225,9 @@ compute_op(const T& x, context& ctx, const shape& output_shape, const std::vecto
template
<
class
T
>
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
->
decltype
(
x
.
compute
(
output_shape
,
input
))
->
decltype
(
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output_shape
,
input
))
,
input
))
{
return
x
.
compute
(
output_shape
,
input
);
return
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output_shape
,
input
))
,
input
);
}
template
<
class
T
>
...
...
@@ -244,9 +249,11 @@ auto compute_op(rank<1>,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
->
decltype
(
x
.
compute
(
output
,
inputs
,
module_args
,
f
))
F
f
)
->
decltype
(
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
,
module_args
,
f
))
{
return
x
.
compute
(
output
,
inputs
,
module_args
,
f
);
return
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
))
,
inputs
,
module_args
,
f
);
}
template
<
class
T
,
class
F
>
...
...
@@ -278,9 +285,17 @@ auto compute_op(rank<4>,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
output
,
inputs
,
module_args
,
f
))
F
f
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
,
module_args
,
f
))
{
return
x
.
compute
(
auto_any_cast
(
ctx
),
output
,
inputs
,
module_args
,
f
);
return
x
.
compute
(
auto_any_cast
(
ctx
),
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
,
module_args
,
f
);
}
template
<
class
T
,
class
F
>
...
...
@@ -290,9 +305,11 @@ auto compute_op(rank<3>,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
->
decltype
(
x
.
compute
(
output
,
inputs
,
module_args
,
f
))
F
f
)
->
decltype
(
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
,
module_args
,
f
))
{
return
x
.
compute
(
output
,
inputs
,
module_args
,
f
);
return
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
))
,
inputs
,
module_args
,
f
);
}
template
<
class
T
,
class
F
>
...
...
@@ -302,9 +319,10 @@ auto compute_op(rank<2>,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
,
F
)
->
decltype
(
x
.
compute
(
output
,
inputs
))
F
)
->
decltype
(
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
))
{
return
x
.
compute
(
output
,
inputs
);
return
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
))
,
inputs
);
}
template
<
class
T
,
class
F
>
...
...
@@ -314,9 +332,12 @@ auto compute_op(rank<1>,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
,
F
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
output
,
inputs
))
F
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
))
{
return
x
.
compute
(
auto_any_cast
(
ctx
),
output
,
inputs
);
return
x
.
compute
(
auto_any_cast
(
ctx
),
make_compute_output_shape
(
pack
(
x
,
output
,
inputs
)),
inputs
);
}
template
<
class
T
,
class
F
>
...
...
@@ -348,7 +369,8 @@ auto is_context_free_op(rank<1>,
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
->
decltype
(
x
.
compute
(
output_shape
,
input
),
std
::
true_type
{});
->
decltype
(
x
.
compute
(
make_compute_output_shape
(
pack
(
x
,
output_shape
,
input
)),
input
),
std
::
true_type
{});
template
<
class
T
>
auto
is_context_free_op
(
rank
<
0
>
,
const
T
&
,
const
shape
&
,
const
std
::
vector
<
argument
>&
)
...
...
tools/install_prereqs.sh
View file @
870a396b
...
...
@@ -57,7 +57,7 @@ echo "Dependencies are installed at $PREFIX"
rbuild prepare
-d
$PREFIX
-s
develop
# install onnx package for unit tests
pip3
install
onnx
==
1.
8.1
numpy
==
1.
18.5
typing
==
3.7.4
pytest
==
6.0.1
packaging
==
16.8
pip3
install
onnx
==
1.
10.0
numpy
==
1.
21.6
typing
==
3.7.4
pytest
==
6.0.1
packaging
==
16.8
# pin version of protobuf in Python for onnx runtime unit tests
pip3
install
protobuf
==
3.20.0
Prev
1
…
20
21
22
23
24
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