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
30c8ff61
Commit
30c8ff61
authored
Aug 14, 2023
by
Khalique Ahmed
Browse files
integrating auto_cont changes
parents
4ff8a292
7aee6388
Changes
48
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
13 deletions
+101
-13
test/module_test.cpp
test/module_test.cpp
+10
-1
test/onnx/.onnxrt-commit
test/onnx/.onnxrt-commit
+1
-1
test/op_shape_test.cpp
test/op_shape_test.cpp
+33
-3
test/py/CMakeLists.txt
test/py/CMakeLists.txt
+3
-5
test/verify/test_reduce_mean_nhwc.cpp
test/verify/test_reduce_mean_nhwc.cpp
+46
-0
tools/api.py
tools/api.py
+4
-2
tools/api/api.cpp
tools/api/api.cpp
+1
-1
tools/api/migraphx.h
tools/api/migraphx.h
+3
-0
No files found.
test/module_test.cpp
View file @
30c8ff61
...
...
@@ -83,7 +83,7 @@ TEST_CASE(calc_implict_deps)
auto
*
else_mod
=
p
.
create_module
(
"If_5_else"
);
auto
l2
=
else_mod
->
add_literal
(
migraphx
::
literal
(
ys
,
datay
));
auto
a2
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod1
,
else_mod1
});
auto
a3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
a2
);
auto
a3
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
a2
);
else_mod
->
add_return
({
a3
,
l2
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
...
...
@@ -95,6 +95,15 @@ TEST_CASE(calc_implict_deps)
EXPECT
(
migraphx
::
contains
(
implicit_deps
.
at
(
ret
),
x1
));
EXPECT
(
migraphx
::
contains
(
implicit_deps
.
at
(
ret
),
x2
));
EXPECT
(
migraphx
::
contains
(
implicit_deps
.
at
(
ret
),
y2
));
EXPECT
(
migraphx
::
contains
(
implicit_deps
.
at
(
ret
),
lx
));
EXPECT
(
migraphx
::
contains
(
implicit_deps
.
at
(
ret
),
ly
));
// test for sorting
p
.
sort
();
auto
ret_inputs
=
ret
->
inputs
();
ret_inputs
.
insert
(
ret_inputs
.
end
(),
implicit_deps
.
at
(
ret
).
begin
(),
implicit_deps
.
at
(
ret
).
end
());
EXPECT
(
std
::
all_of
(
ret_inputs
.
begin
(),
ret_inputs
.
end
(),
[
&
](
const
auto
i
)
{
return
std
::
distance
(
mm
->
begin
(),
i
)
<
std
::
distance
(
mm
->
begin
(),
ret
);
}));
}
TEST_CASE
(
module_annotate
)
...
...
test/onnx/.onnxrt-commit
View file @
30c8ff61
d3295f4329d744fe1f8419e1220e123807282b99
21a71d52bd2074b770807b209939ec11e2c64fa7
test/op_shape_test.cpp
View file @
30c8ff61
...
...
@@ -323,7 +323,7 @@ TEST_CASE(conv_dyn_batch)
TEST_CASE
(
conv_dyn_img
)
{
migraphx
::
shape
input_dyn_shape
=
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
},
{
3
,
3
},
{
5
,
20
},
{
5
,
20
}}};
{{
1
,
1
},
{
3
,
3
},
{
5
,
20
},
{
5
,
20
}}};
migraphx
::
shape
weights_shape
=
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
3
,
3
}};
migraphx
::
shape
output_dyn_shape
=
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
},
{
1
,
1
},
{
3
,
18
},
{
3
,
18
}}};
...
...
@@ -376,7 +376,7 @@ TEST_CASE(conv_autopad_dyn_batch)
{
// auto_pad dynamic batch
migraphx
::
shape
input_dyn_shape
=
{
migraphx
::
shape
::
float_type
,
{{
1
,
10
},
{
3
,
3
},
{
5
,
5
},
{
5
,
5
}}};
{{
1
,
10
},
{
3
,
3
},
{
5
,
5
},
{
5
,
5
}}};
migraphx
::
shape
weights_shape
=
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
3
,
3
}};
migraphx
::
shape
output_dyn_shape
=
{
migraphx
::
shape
::
float_type
,
{{
1
,
10
},
{
1
,
1
},
{
5
,
5
},
{
5
,
5
}}};
...
...
@@ -393,7 +393,7 @@ TEST_CASE(conv_autopad_dyn_img)
{
// auto_pad dynamic img
migraphx
::
shape
input_dyn_shape
=
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
},
{
3
,
3
},
{
5
,
10
},
{
5
,
10
}}};
{{
1
,
1
},
{
3
,
3
},
{
5
,
10
},
{
5
,
10
}}};
migraphx
::
shape
weights_shape
=
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
3
,
3
}};
migraphx
::
shape
output_dyn_shape
=
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
},
{
1
,
1
},
{
5
,
10
},
{
5
,
10
}}};
...
...
@@ -2597,6 +2597,36 @@ TEST_CASE(reshape_non_fixed_not_matching_error)
throws_shape
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
new_shape
}}),
input
);
}
TEST_CASE
(
return_shape_tuple
)
{
using
migraphx
::
shape
;
auto
op
=
migraphx
::
make_op
(
"@return"
);
shape
s0
{
shape
::
bool_type
,
{
1
,
1
}};
shape
s1
{
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
shape
>
s
{
s0
,
s1
};
auto
s_out
=
op
.
compute_shape
(
s
);
EXPECT
(
s_out
.
type
()
==
shape
::
tuple_type
);
EXPECT
(
s0
==
s_out
.
sub_shapes
()[
0
]);
EXPECT
(
s1
==
s_out
.
sub_shapes
()[
1
]);
}
TEST_CASE
(
return_shape_half
)
{
using
migraphx
::
shape
;
auto
op
=
migraphx
::
make_op
(
"@return"
);
std
::
vector
<
shape
>
s
{{
shape
::
half_type
}};
EXPECT
(
op
.
compute_shape
(
s
)
==
shape
{
shape
::
half_type
});
}
TEST_CASE
(
return_shape_empty
)
{
using
migraphx
::
shape
;
auto
op
=
migraphx
::
make_op
(
"@return"
);
std
::
vector
<
shape
>
s
;
EXPECT
(
op
.
compute_shape
(
s
)
==
shape
{});
}
TEST_CASE
(
rnn
)
{
{
...
...
test/py/CMakeLists.txt
View file @
30c8ff61
...
...
@@ -27,7 +27,7 @@ include(PythonModules)
function
(
add_py_test NAME SCRIPT
)
foreach
(
PYTHON_VERSION
${
PYTHON_VERSIONS
}
)
set
(
ENV_COMMAND
${
CMAKE_COMMAND
}
-E env
"PYTHONPATH=$<TARGET_FILE_DIR:migraphx_py_
${
PYTHON_VERSION
}
>"
"PYTHONPATH=$<TARGET_FILE_DIR:migraphx_py
bind
_
${
PYTHON_VERSION
}
>"
"PYTHONMALLOC=debug"
"MALLOC_CHECK_=3"
)
...
...
@@ -41,10 +41,8 @@ function(add_py_test NAME SCRIPT)
endforeach
()
endfunction
()
foreach
(
PYTHON_VERSION
${
PYTHON_VERSIONS
}
)
add_dependencies
(
tests migraphx_py_
${
PYTHON_VERSION
}
)
add_dependencies
(
check migraphx_py_
${
PYTHON_VERSION
}
)
endforeach
()
add_dependencies
(
tests migraphx_py
)
add_dependencies
(
check migraphx_py
)
add_py_test
(
ref test_cpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
save_load test_save_load.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
...
...
test/verify/test_reduce_mean_nhwc.cpp
0 → 100644
View file @
30c8ff61
/*
* 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/instruction.hpp>
struct
test_reduce_mean_nhwc
:
verify_program
<
test_reduce_mean_nhwc
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
::
from_permutation
(
migraphx
::
shape
::
float_type
,
{
4
,
256
,
2
,
2
},
{
0
,
2
,
3
,
1
});
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
reduce
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
1
}}}),
x
);
auto
abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
reduce
);
auto
sqrt
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sqrt"
),
abs
);
mm
->
add_return
({
sqrt
});
return
p
;
};
};
tools/api.py
View file @
30c8ff61
...
...
@@ -36,6 +36,8 @@ error_type = ''
success_type
=
''
try_wrap
=
''
export_c_macro
=
'MIGRAPHX_C_EXPORT'
c_header_preamble
:
List
[
str
]
=
[]
c_api_body_preamble
:
List
[
str
]
=
[]
cpp_header_preamble
:
List
[
str
]
=
[]
...
...
@@ -125,7 +127,7 @@ class Type:
header_function
=
Template
(
'''
${error_type} ${name}(${params});
${export_c_macro}
${error_type} ${name}(${params});
'''
)
function_pointer_typedef
=
Template
(
'''
...
...
@@ -177,7 +179,7 @@ class CFunction:
**
kwargs
)
def
generate_header
(
self
)
->
str
:
return
self
.
substitute
(
header_function
)
return
self
.
substitute
(
header_function
,
export_c_macro
=
export_c_macro
)
def
generate_function_pointer
(
self
,
name
:
Optional
[
str
]
=
None
)
->
str
:
return
self
.
substitute
(
function_pointer_typedef
,
...
...
tools/api/api.cpp
View file @
30c8ff61
...
...
@@ -44,7 +44,7 @@ namespace migraphx {
static
thread_local
bool
disable_exception_catch
=
false
;
// NOLINT
extern
"C"
void
migraphx_test_private_disable_exception_catch
(
bool
b
)
extern
"C"
MIGRAPHX_C_EXPORT
void
migraphx_test_private_disable_exception_catch
(
bool
b
)
{
disable_exception_catch
=
b
;
}
...
...
tools/api/migraphx.h
View file @
30c8ff61
...
...
@@ -26,6 +26,9 @@
#include <stdlib.h>
#include <stdbool.h>
#include <migraphx/api/export.h>
// Add new types here
// clang-format off
#define MIGRAPHX_SHAPE_VISIT_TYPES(m) \
...
...
Prev
1
2
3
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