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
723d1f0b
Commit
723d1f0b
authored
Apr 16, 2019
by
Shucai Xiao
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/AMDMIGraphX
into ins_fp32_fp16
parents
ef7a14c9
ca69c190
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
454 additions
and
242 deletions
+454
-242
src/fwd_conv_batchnorm_rewrite.cpp
src/fwd_conv_batchnorm_rewrite.cpp
+1
-1
src/include/migraphx/op/broadcast.hpp
src/include/migraphx/op/broadcast.hpp
+11
-13
src/include/migraphx/op/common.hpp
src/include/migraphx/op/common.hpp
+2
-0
src/include/migraphx/op/gather.hpp
src/include/migraphx/op/gather.hpp
+7
-0
src/include/migraphx/op/gru.hpp
src/include/migraphx/op/gru.hpp
+10
-0
src/include/migraphx/op/logsoftmax.hpp
src/include/migraphx/op/logsoftmax.hpp
+7
-0
src/include/migraphx/op/lstm.hpp
src/include/migraphx/op/lstm.hpp
+9
-0
src/include/migraphx/op/rnn.hpp
src/include/migraphx/op/rnn.hpp
+9
-0
src/include/migraphx/op/scalar.hpp
src/include/migraphx/op/scalar.hpp
+9
-3
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+6
-6
src/rewrite_rnn.cpp
src/rewrite_rnn.cpp
+31
-19
src/tf/tf.cpp
src/tf/tf.cpp
+70
-1
test/auto_contiguous_test.cpp
test/auto_contiguous_test.cpp
+2
-2
test/cpu_dot_op_test.cpp
test/cpu_dot_op_test.cpp
+1
-1
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+4
-4
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+9
-9
test/onnx/onnx_gru_reverse.onnx
test/onnx/onnx_gru_reverse.onnx
+0
-0
test/onnx/onnx_rnn_3args.onnx
test/onnx/onnx_rnn_3args.onnx
+0
-0
test/onnx/onnx_rnn_test.cpp
test/onnx/onnx_rnn_test.cpp
+257
-174
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+9
-9
No files found.
src/fwd_conv_batchnorm_rewrite.cpp
View file @
723d1f0b
...
@@ -63,7 +63,7 @@ void fwd_conv_batchnorm_rewrite::apply(program& p) const
...
@@ -63,7 +63,7 @@ void fwd_conv_batchnorm_rewrite::apply(program& p) const
auto
l_weights
=
p
.
add_literal
({
weights
.
get_shape
(),
new_weights
.
data
()});
auto
l_weights
=
p
.
add_literal
({
weights
.
get_shape
(),
new_weights
.
data
()});
auto
l_bias
=
p
.
add_literal
({
new_bias
.
get_shape
(),
new_bias
.
data
()});
auto
l_bias
=
p
.
add_literal
({
new_bias
.
get_shape
(),
new_bias
.
data
()});
auto
c
=
p
.
replace_instruction
(
conv_ins
,
conv_op
,
{
conv_ins
->
inputs
()[
0
],
l_weights
});
auto
c
=
p
.
replace_instruction
(
conv_ins
,
conv_op
,
{
conv_ins
->
inputs
()[
0
],
l_weights
});
auto
b
=
p
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
c
->
get_shape
()},
l_bias
);
auto
b
=
p
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
c
->
get_shape
()
.
lens
()
},
l_bias
);
p
.
replace_instruction
(
ins
,
op
::
add
{},
{
c
,
b
});
p
.
replace_instruction
(
ins
,
op
::
add
{},
{
c
,
b
});
}
}
}
}
...
...
src/include/migraphx/op/broadcast.hpp
View file @
723d1f0b
...
@@ -27,38 +27,36 @@ namespace op {
...
@@ -27,38 +27,36 @@ namespace op {
struct
broadcast
struct
broadcast
{
{
uint64_t
axis
=
0
;
uint64_t
axis
=
0
;
std
::
vector
<
std
::
size_t
>
broadcast_lens
;
template
<
class
Self
,
class
F
>
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
static
auto
reflect
(
Self
&
self
,
F
f
)
{
{
return
pack
(
f
(
self
.
axis
,
"axis"
));
return
pack
(
f
(
self
.
axis
,
"axis"
)
,
f
(
self
.
broadcast_lens
,
"dims"
)
);
}
}
shape
broadcast_shape
;
std
::
string
name
()
const
{
return
"broadcast"
;
}
std
::
string
name
()
const
{
return
"broadcast"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
auto
t
=
inputs
.
at
(
0
).
type
();
auto
t
=
inputs
.
at
(
0
).
type
();
auto
input
=
inputs
.
at
(
0
);
auto
input
=
inputs
.
at
(
0
);
std
::
vector
<
size_t
>
bcast_strides
(
broadcast_
shape
.
lens
()
.
size
(),
0
);
std
::
vector
<
size_t
>
bcast_strides
(
broadcast_lens
.
size
(),
0
);
if
(
std
::
all_of
(
broadcast_shape
.
lens
().
cbegin
(),
broadcast_shape
.
lens
().
cend
(),
[
&
](
auto
x
)
{
if
(
std
::
all_of
(
return
x
==
1
;
broadcast_lens
.
cbegin
(),
broadcast_lens
.
cend
(),
[
&
](
auto
x
)
{
return
x
==
1
;
}))
}))
{
{
if
(
axis
!=
0
)
if
(
axis
!=
0
)
MIGRAPHX_THROW
(
"when broadcasting tensor of size 1, axis should be 0"
);
MIGRAPHX_THROW
(
"
BROADCAST:
when broadcasting tensor of size 1, axis should be 0"
);
return
{
t
,
broadcast_
shape
.
lens
()
,
std
::
move
(
bcast_strides
)};
return
{
t
,
broadcast_lens
,
std
::
move
(
bcast_strides
)};
}
}
else
else
{
{
assert
(
broadcast_shape
.
lens
().
size
()
-
axis
>=
input
.
lens
().
size
());
assert
(
broadcast_lens
.
size
()
-
axis
>=
input
.
lens
().
size
());
if
(
!
std
::
equal
(
if
(
!
std
::
equal
(
input
.
lens
().
begin
(),
input
.
lens
().
end
(),
broadcast_lens
.
begin
()
+
axis
))
input
.
lens
().
begin
(),
input
.
lens
().
end
(),
broadcast_shape
.
lens
().
begin
()
+
axis
))
MIGRAPHX_THROW
(
"BROADCAST: when broadcasting success sizes must match"
);
MIGRAPHX_THROW
(
"when broadcasting success sizes must match"
);
std
::
copy
(
input
.
strides
().
begin
(),
input
.
strides
().
end
(),
bcast_strides
.
begin
()
+
axis
);
std
::
copy
(
input
.
strides
().
begin
(),
input
.
strides
().
end
(),
bcast_strides
.
begin
()
+
axis
);
return
{
t
,
broadcast_
shape
.
lens
()
,
std
::
move
(
bcast_strides
)};
return
{
t
,
broadcast_lens
,
std
::
move
(
bcast_strides
)};
}
}
}
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
...
src/include/migraphx/op/common.hpp
View file @
723d1f0b
...
@@ -31,6 +31,8 @@ enum class rnn_direction
...
@@ -31,6 +31,8 @@ enum class rnn_direction
bidirectional
,
bidirectional
,
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
rnn_direction
v
);
}
// namespace op
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
}
// namespace migraphx
...
...
src/include/migraphx/op/gather.hpp
View file @
723d1f0b
...
@@ -19,6 +19,13 @@ namespace op {
...
@@ -19,6 +19,13 @@ namespace op {
struct
gather
struct
gather
{
{
int
axis
=
0
;
int
axis
=
0
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
axis
,
"axis"
));
}
std
::
string
name
()
const
{
return
"gather"
;
}
std
::
string
name
()
const
{
return
"gather"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
...
...
src/include/migraphx/op/gru.hpp
View file @
723d1f0b
...
@@ -27,6 +27,16 @@ struct gru
...
@@ -27,6 +27,16 @@ struct gru
float
clip
=
0.0
f
;
float
clip
=
0.0
f
;
int
linear_before_reset
=
0
;
int
linear_before_reset
=
0
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
hidden_size
,
"hidden_size"
),
f
(
self
.
actv_funcs
,
"actv_func"
),
f
(
self
.
direction
,
"direction"
),
f
(
self
.
clip
,
"clip"
),
f
(
self
.
linear_before_reset
,
"linear_before_reset"
));
}
std
::
string
name
()
const
{
return
"gru"
;
}
std
::
string
name
()
const
{
return
"gru"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
...
...
src/include/migraphx/op/logsoftmax.hpp
View file @
723d1f0b
...
@@ -19,6 +19,13 @@ namespace op {
...
@@ -19,6 +19,13 @@ namespace op {
struct
logsoftmax
struct
logsoftmax
{
{
int
axis
=
1
;
int
axis
=
1
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
axis
,
"axis"
));
}
std
::
string
name
()
const
{
return
"logsoftmax"
;
}
std
::
string
name
()
const
{
return
"logsoftmax"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
...
...
src/include/migraphx/op/lstm.hpp
View file @
723d1f0b
...
@@ -25,6 +25,15 @@ struct lstm
...
@@ -25,6 +25,15 @@ struct lstm
float
clip
=
0.0
f
;
float
clip
=
0.0
f
;
int
input_forget
=
0
;
int
input_forget
=
0
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
hidden_size
,
"hidden_size"
),
f
(
self
.
actv_funcs
,
"actv_func"
),
f
(
self
.
direction
,
"direction"
),
f
(
self
.
input_forget
,
"input_forget"
));
}
std
::
string
name
()
const
{
return
"lstm"
;
}
std
::
string
name
()
const
{
return
"lstm"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
...
...
src/include/migraphx/op/rnn.hpp
View file @
723d1f0b
...
@@ -25,6 +25,15 @@ struct rnn
...
@@ -25,6 +25,15 @@ struct rnn
rnn_direction
direction
=
rnn_direction
::
forward
;
rnn_direction
direction
=
rnn_direction
::
forward
;
float
clip
=
0.0
f
;
float
clip
=
0.0
f
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
hidden_size
,
"hidden_size"
),
f
(
self
.
actv_funcs
,
"actv_func"
),
f
(
self
.
direction
,
"direction"
),
f
(
self
.
clip
,
"clip"
));
}
std
::
string
name
()
const
{
return
"rnn"
;
}
std
::
string
name
()
const
{
return
"rnn"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
...
...
src/include/migraphx/op/scalar.hpp
View file @
723d1f0b
...
@@ -18,7 +18,13 @@ namespace op {
...
@@ -18,7 +18,13 @@ namespace op {
struct
scalar
struct
scalar
{
{
shape
scalar_bcast
;
std
::
vector
<
std
::
size_t
>
scalar_bcast_lens
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
scalar_bcast_lens
,
"scalar_bcst_dims"
));
}
std
::
string
name
()
const
{
return
"scalar"
;
}
std
::
string
name
()
const
{
return
"scalar"
;
}
...
@@ -26,8 +32,8 @@ struct scalar
...
@@ -26,8 +32,8 @@ struct scalar
{
{
assert
(
check_shapes
{
inputs
}.
has
(
1
).
only_dims
(
1
).
size
()
==
1
);
assert
(
check_shapes
{
inputs
}.
has
(
1
).
only_dims
(
1
).
size
()
==
1
);
auto
t
=
inputs
.
at
(
0
).
type
();
auto
t
=
inputs
.
at
(
0
).
type
();
std
::
vector
<
std
::
size_t
>
strides
(
scalar_bcast
.
lens
()
.
size
(),
0
);
std
::
vector
<
std
::
size_t
>
strides
(
scalar_bcast
_
lens
.
size
(),
0
);
return
{
t
,
scalar_bcast
.
lens
()
,
strides
};
return
{
t
,
scalar_bcast
_
lens
,
strides
};
}
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
...
src/onnx/onnx.cpp
View file @
723d1f0b
...
@@ -141,8 +141,8 @@ struct onnx_parser
...
@@ -141,8 +141,8 @@ struct onnx_parser
if
(
broadcasted
!=
0
)
if
(
broadcasted
!=
0
)
{
{
uint64_t
axis
=
parse_value
(
attributes
.
at
(
"axis"
)).
at
<
uint64_t
>
();
uint64_t
axis
=
parse_value
(
attributes
.
at
(
"axis"
)).
at
<
uint64_t
>
();
auto
l
=
auto
l
=
prog
.
add_instruction
(
op
::
broadcast
{
axis
,
args
[
0
]
->
get_shape
().
lens
()},
prog
.
add_instruction
(
op
::
broadcast
{
axis
,
args
[
0
]
->
get_shape
()},
args
[
1
]);
args
[
1
]);
return
prog
.
add_instruction
(
x
,
args
[
0
],
l
);
return
prog
.
add_instruction
(
x
,
args
[
0
],
l
);
}
}
return
prog
.
add_instruction
(
x
,
args
);
return
prog
.
add_instruction
(
x
,
args
);
...
@@ -306,7 +306,7 @@ struct onnx_parser
...
@@ -306,7 +306,7 @@ struct onnx_parser
{
{
uint64_t
axis
=
1
;
uint64_t
axis
=
1
;
auto
l1
=
prog
.
add_instruction
(
op
,
args
[
0
],
args
[
1
]);
auto
l1
=
prog
.
add_instruction
(
op
,
args
[
0
],
args
[
1
]);
auto
l2
=
prog
.
add_instruction
(
op
::
broadcast
{
axis
,
l1
->
get_shape
()},
args
[
2
]);
auto
l2
=
prog
.
add_instruction
(
op
::
broadcast
{
axis
,
l1
->
get_shape
()
.
lens
()
},
args
[
2
]);
return
prog
.
add_instruction
(
op
::
add
{},
l1
,
l2
);
return
prog
.
add_instruction
(
op
::
add
{},
l1
,
l2
);
}
}
return
prog
.
add_instruction
(
op
,
l0
,
args
[
1
]);
return
prog
.
add_instruction
(
op
,
l0
,
args
[
1
]);
...
@@ -671,15 +671,15 @@ struct onnx_parser
...
@@ -671,15 +671,15 @@ struct onnx_parser
auto
&&
bias_floats
=
attributes
[
"bias"
].
floats
();
auto
&&
bias_floats
=
attributes
[
"bias"
].
floats
();
bias
=
std
::
vector
<
float
>
(
bias_floats
.
begin
(),
bias_floats
.
end
());
bias
=
std
::
vector
<
float
>
(
bias_floats
.
begin
(),
bias_floats
.
end
());
}
}
auto
input_
shape
=
args
.
front
()
->
get_shape
();
auto
input_
lens
=
args
.
front
()
->
get_shape
()
.
lens
()
;
auto
scale_val
=
prog
.
add_literal
(
scale
);
auto
scale_val
=
prog
.
add_literal
(
scale
);
auto
bias_vals
=
prog
.
add_literal
(
auto
bias_vals
=
prog
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
bias
.
size
()}},
bias
});
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
bias
.
size
()}},
bias
});
auto
scale_tensor
=
prog
.
add_instruction
(
migraphx
::
op
::
scalar
{
input_
shape
},
scale_val
);
auto
scale_tensor
=
prog
.
add_instruction
(
migraphx
::
op
::
scalar
{
input_
lens
},
scale_val
);
auto
img_scaled
=
prog
.
add_instruction
(
migraphx
::
op
::
mul
{},
args
.
front
(),
scale_tensor
);
auto
img_scaled
=
prog
.
add_instruction
(
migraphx
::
op
::
mul
{},
args
.
front
(),
scale_tensor
);
auto
bias_bcast
=
prog
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
input_
shape
},
bias_vals
);
auto
bias_bcast
=
prog
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
input_
lens
},
bias_vals
);
return
prog
.
add_instruction
(
migraphx
::
op
::
add
{},
img_scaled
,
bias_bcast
);
return
prog
.
add_instruction
(
migraphx
::
op
::
add
{},
img_scaled
,
bias_bcast
);
}
}
...
...
src/rewrite_rnn.cpp
View file @
723d1f0b
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <migraphx/operators.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/dfor.hpp>
#include <migraphx/dfor.hpp>
#include <migraphx/op/common.hpp>
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
...
@@ -213,7 +214,7 @@ std::vector<instruction_ref> rewrite_rnn::vanilla_rnn_cell(bool is_forward,
...
@@ -213,7 +214,7 @@ std::vector<instruction_ref> rewrite_rnn::vanilla_rnn_cell(bool is_forward,
auto
wb
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
sbias
);
auto
wb
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
sbias
);
auto
rb
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
sbias
);
auto
rb
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
sbias
);
auto
b
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wb
,
rb
);
auto
b
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wb
,
rb
);
bias
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()},
b
);
bias
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()
.
lens
()
},
b
);
}
}
instruction_ref
hidden_out
=
prog
.
end
();
instruction_ref
hidden_out
=
prog
.
end
();
...
@@ -520,25 +521,26 @@ std::vector<instruction_ref> rewrite_rnn::gru_cell(bool is_forward,
...
@@ -520,25 +521,26 @@ std::vector<instruction_ref> rewrite_rnn::gru_cell(bool is_forward,
instruction_ref
brcst_bh
{};
instruction_ref
brcst_bh
{};
if
(
bias
!=
prog
.
end
())
if
(
bias
!=
prog
.
end
())
{
{
auto
broadcast_lens
=
sih
->
get_shape
().
lens
();
auto
sbias
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
bias
);
auto
sbias
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
bias
);
auto
wbz
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
sbias
);
auto
wbz
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
sbias
);
auto
wbr
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
sbias
);
auto
wbr
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
sbias
);
auto
wbh
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
2
*
hs
},
{
3
*
hs
}},
sbias
);
auto
wbh
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
2
*
hs
},
{
3
*
hs
}},
sbias
);
brcst_wbh
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()
},
wbh
);
brcst_wbh
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
broadcast_lens
},
wbh
);
auto
rbz
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
3
*
hs
},
{
4
*
hs
}},
sbias
);
auto
rbz
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
3
*
hs
},
{
4
*
hs
}},
sbias
);
auto
rbr
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
4
*
hs
},
{
5
*
hs
}},
sbias
);
auto
rbr
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
4
*
hs
},
{
5
*
hs
}},
sbias
);
auto
rbh
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
5
*
hs
},
{
6
*
hs
}},
sbias
);
auto
rbh
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
5
*
hs
},
{
6
*
hs
}},
sbias
);
brcst_rbh
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()
},
rbh
);
brcst_rbh
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
broadcast_lens
},
rbh
);
auto
bz
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wbz
,
rbz
);
auto
bz
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wbz
,
rbz
);
brcst_bz
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()
},
bz
);
brcst_bz
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
broadcast_lens
},
bz
);
auto
br
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wbr
,
rbr
);
auto
br
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wbr
,
rbr
);
brcst_br
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()
},
br
);
brcst_br
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
broadcast_lens
},
br
);
auto
bh
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wbh
,
rbh
);
auto
bh
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
wbh
,
rbh
);
brcst_bh
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
sih
->
get_shape
()
},
bh
);
brcst_bh
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
broadcast_lens
},
bh
);
}
}
for
(
long
i
=
0
;
i
<
seq_len
;
i
++
)
for
(
long
i
=
0
;
i
<
seq_len
;
i
++
)
...
@@ -946,7 +948,7 @@ std::vector<instruction_ref> rewrite_rnn::lstm_cell(bool is_forward,
...
@@ -946,7 +948,7 @@ std::vector<instruction_ref> rewrite_rnn::lstm_cell(bool is_forward,
// initial cell state
// initial cell state
auto
sic
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
ic
);
auto
sic
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
ic
);
auto
ic_
shape
=
sic
->
get_shape
();
auto
ic_
lens
=
sic
->
get_shape
()
.
lens
()
;
// bias
// bias
instruction_ref
bi_brcst
{};
instruction_ref
bi_brcst
{};
...
@@ -955,26 +957,27 @@ std::vector<instruction_ref> rewrite_rnn::lstm_cell(bool is_forward,
...
@@ -955,26 +957,27 @@ std::vector<instruction_ref> rewrite_rnn::lstm_cell(bool is_forward,
instruction_ref
bc_brcst
{};
instruction_ref
bc_brcst
{};
if
(
bias
!=
prog
.
end
())
if
(
bias
!=
prog
.
end
())
{
{
auto
sbias
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
bias
);
auto
sbias
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
bias
);
auto
bxi
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
sbias
);
auto
bxi
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
sbias
);
auto
bhi
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
4
*
hs
},
{
5
*
hs
}},
sbias
);
auto
bhi
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
4
*
hs
},
{
5
*
hs
}},
sbias
);
auto
bi
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxi
,
bhi
);
auto
bi
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxi
,
bhi
);
bi_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
bi
);
bi_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
bi
);
auto
bxo
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
sbias
);
auto
bxo
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
sbias
);
auto
bho
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
5
*
hs
},
{
6
*
hs
}},
sbias
);
auto
bho
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
5
*
hs
},
{
6
*
hs
}},
sbias
);
auto
bo
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxo
,
bho
);
auto
bo
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxo
,
bho
);
bo_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
bo
);
bo_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
bo
);
auto
bxf
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
2
*
hs
},
{
3
*
hs
}},
sbias
);
auto
bxf
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
2
*
hs
},
{
3
*
hs
}},
sbias
);
auto
bhf
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
6
*
hs
},
{
7
*
hs
}},
sbias
);
auto
bhf
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
6
*
hs
},
{
7
*
hs
}},
sbias
);
auto
bf
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxf
,
bhf
);
auto
bf
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxf
,
bhf
);
bf_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
bf
);
bf_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
bf
);
auto
bxc
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
3
*
hs
},
{
4
*
hs
}},
sbias
);
auto
bxc
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
3
*
hs
},
{
4
*
hs
}},
sbias
);
auto
bhc
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
7
*
hs
},
{
8
*
hs
}},
sbias
);
auto
bhc
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
7
*
hs
},
{
8
*
hs
}},
sbias
);
auto
bc
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxc
,
bhc
);
auto
bc
=
prog
.
insert_instruction
(
ins
,
op
::
add
{},
bxc
,
bhc
);
bc_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
bc
);
bc_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
bc
);
}
}
// peep hole
// peep hole
...
@@ -986,13 +989,13 @@ std::vector<instruction_ref> rewrite_rnn::lstm_cell(bool is_forward,
...
@@ -986,13 +989,13 @@ std::vector<instruction_ref> rewrite_rnn::lstm_cell(bool is_forward,
{
{
auto
spph
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
pph
);
auto
spph
=
prog
.
insert_instruction
(
ins
,
op
::
squeeze
{{
0
}},
pph
);
auto
pphi
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
spph
);
auto
pphi
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
0
},
{
hs
}},
spph
);
pphi_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
pphi
);
pphi_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
pphi
);
auto
ppho
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
spph
);
auto
ppho
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
hs
},
{
2
*
hs
}},
spph
);
ppho_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
ppho
);
ppho_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
ppho
);
auto
pphf
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
2
*
hs
},
{
3
*
hs
}},
spph
);
auto
pphf
=
prog
.
insert_instruction
(
ins
,
op
::
slice
{{
0
},
{
2
*
hs
},
{
3
*
hs
}},
spph
);
pphf_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
shape
},
pphf
);
pphf_brcst
=
prog
.
insert_instruction
(
ins
,
op
::
broadcast
{
1
,
ic_
lens
},
pphf
);
}
}
for
(
long
i
=
0
;
i
<
seq_len
;
++
i
)
for
(
long
i
=
0
;
i
<
seq_len
;
++
i
)
...
@@ -1166,5 +1169,14 @@ std::vector<operation> rewrite_rnn::lstm_actv_funcs(instruction_ref ins) const
...
@@ -1166,5 +1169,14 @@ std::vector<operation> rewrite_rnn::lstm_actv_funcs(instruction_ref ins) const
}
}
}
}
namespace
op
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
rnn_direction
v
)
{
std
::
vector
<
std
::
string
>
rnn_direction_str
=
{
"forward"
,
"reverse"
,
"bidirectional"
};
os
<<
rnn_direction_str
[
static_cast
<
std
::
underlying_type
<
rnn_direction
>::
type
>
(
v
)];
return
os
;
}
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
}
// namespace migraphx
src/tf/tf.cpp
View file @
723d1f0b
...
@@ -110,6 +110,7 @@ struct tf_parser
...
@@ -110,6 +110,7 @@ struct tf_parser
add_generic_op
(
"Relu"
,
op
::
relu
{});
add_generic_op
(
"Relu"
,
op
::
relu
{});
add_binary_op
(
"Add"
,
op
::
add
{});
add_binary_op
(
"Add"
,
op
::
add
{});
add_binary_op
(
"Mul"
,
op
::
mul
{});
add_mem_op
(
"AvgPool"
,
&
tf_parser
::
parse_pooling
);
add_mem_op
(
"AvgPool"
,
&
tf_parser
::
parse_pooling
);
add_mem_op
(
"BiasAdd"
,
&
tf_parser
::
parse_biasadd
);
add_mem_op
(
"BiasAdd"
,
&
tf_parser
::
parse_biasadd
);
...
@@ -117,6 +118,7 @@ struct tf_parser
...
@@ -117,6 +118,7 @@ struct tf_parser
add_mem_op
(
"Const"
,
&
tf_parser
::
parse_constant
);
add_mem_op
(
"Const"
,
&
tf_parser
::
parse_constant
);
add_mem_op
(
"Conv2D"
,
&
tf_parser
::
parse_conv
);
add_mem_op
(
"Conv2D"
,
&
tf_parser
::
parse_conv
);
add_mem_op
(
"FusedBatchNorm"
,
&
tf_parser
::
parse_batchnorm
);
add_mem_op
(
"FusedBatchNorm"
,
&
tf_parser
::
parse_batchnorm
);
add_mem_op
(
"MatMul"
,
&
tf_parser
::
parse_matmul
);
add_mem_op
(
"MaxPool"
,
&
tf_parser
::
parse_pooling
);
add_mem_op
(
"MaxPool"
,
&
tf_parser
::
parse_pooling
);
add_mem_op
(
"Mean"
,
&
tf_parser
::
parse_mean
);
add_mem_op
(
"Mean"
,
&
tf_parser
::
parse_mean
);
add_mem_op
(
"Pack"
,
&
tf_parser
::
parse_pack
);
add_mem_op
(
"Pack"
,
&
tf_parser
::
parse_pack
);
...
@@ -124,6 +126,7 @@ struct tf_parser
...
@@ -124,6 +126,7 @@ struct tf_parser
add_mem_op
(
"Reshape"
,
&
tf_parser
::
parse_reshape
);
add_mem_op
(
"Reshape"
,
&
tf_parser
::
parse_reshape
);
add_mem_op
(
"Softmax"
,
&
tf_parser
::
parse_softmax
);
add_mem_op
(
"Softmax"
,
&
tf_parser
::
parse_softmax
);
add_mem_op
(
"Squeeze"
,
&
tf_parser
::
parse_squeeze
);
add_mem_op
(
"Squeeze"
,
&
tf_parser
::
parse_squeeze
);
add_mem_op
(
"StridedSlice"
,
&
tf_parser
::
parse_stridedslice
);
}
}
template
<
class
F
>
template
<
class
F
>
...
@@ -235,7 +238,7 @@ struct tf_parser
...
@@ -235,7 +238,7 @@ struct tf_parser
parse_biasadd
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
parse_biasadd
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
{
uint64_t
axis
=
1
;
// assume output of previous layer is in NCHW (broadcast on channel)
uint64_t
axis
=
1
;
// assume output of previous layer is in NCHW (broadcast on channel)
auto
l0
=
prog
.
add_instruction
(
op
::
broadcast
{
axis
,
args
[
0
]
->
get_shape
()},
args
[
1
]);
auto
l0
=
prog
.
add_instruction
(
op
::
broadcast
{
axis
,
args
[
0
]
->
get_shape
()
.
lens
()
},
args
[
1
]);
return
prog
.
add_instruction
(
op
::
add
{},
args
[
0
],
l0
);
return
prog
.
add_instruction
(
op
::
add
{},
args
[
0
],
l0
);
}
}
...
@@ -336,6 +339,32 @@ struct tf_parser
...
@@ -336,6 +339,32 @@ struct tf_parser
return
prog
.
add_instruction
(
op
,
{
args
[
0
],
weights
});
return
prog
.
add_instruction
(
op
,
{
args
[
0
],
weights
});
}
}
instruction_ref
parse_matmul
(
const
std
::
string
&
,
attribute_map
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
bool
transa
=
false
;
bool
transb
=
false
;
if
(
contains
(
attributes
,
"transpose_a"
))
{
transa
=
attributes
.
at
(
"transpose_a"
).
b
();
}
if
(
contains
(
attributes
,
"transpose_b"
))
{
transb
=
attributes
.
at
(
"transpose_a"
).
b
();
}
std
::
vector
<
int64_t
>
perm
(
args
[
0
]
->
get_shape
().
lens
().
size
());
std
::
iota
(
perm
.
begin
(),
perm
.
end
(),
int64_t
{
0
});
// swap the last two elements
std
::
iter_swap
(
perm
.
end
()
-
1
,
perm
.
end
()
-
2
);
auto
l1
=
(
transa
)
?
prog
.
add_instruction
(
op
::
transpose
{
perm
},
args
[
0
])
:
args
[
0
];
auto
l2
=
(
transb
)
?
prog
.
add_instruction
(
op
::
transpose
{
perm
},
args
[
1
])
:
args
[
1
];
return
prog
.
add_instruction
(
op
::
dot
{},
l1
,
l2
);
}
instruction_ref
instruction_ref
parse_mean
(
const
std
::
string
&
,
attribute_map
attributes
,
std
::
vector
<
instruction_ref
>
args
)
parse_mean
(
const
std
::
string
&
,
attribute_map
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
{
...
@@ -508,6 +537,46 @@ struct tf_parser
...
@@ -508,6 +537,46 @@ struct tf_parser
return
prog
.
add_instruction
(
op
,
args
[
0
]);
return
prog
.
add_instruction
(
op
,
args
[
0
]);
}
}
instruction_ref
parse_stridedslice
(
const
std
::
string
&
,
const
attribute_map
&
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
op
::
slice
op
;
auto
starts
=
args
[
1
]
->
eval
().
get
<
int32_t
>
().
to_vector
();
auto
ends
=
args
[
2
]
->
eval
().
get
<
int32_t
>
().
to_vector
();
size_t
num_axes
=
args
[
0
]
->
get_shape
().
lens
().
size
();
if
(
num_axes
>=
4
)
{
reorder_data
(
starts
);
reorder_data
(
ends
);
}
op
.
starts
=
std
::
vector
<
int64_t
>
(
starts
.
begin
(),
starts
.
end
());
op
.
ends
=
std
::
vector
<
int64_t
>
(
ends
.
begin
(),
ends
.
end
());
op
.
axes
=
std
::
vector
<
int64_t
>
(
num_axes
);
std
::
iota
(
op
.
axes
.
begin
(),
op
.
axes
.
end
(),
0
);
uint32_t
shrink_axis_mask
=
0
;
uint32_t
bitwise_compare
=
1
;
std
::
vector
<
int64_t
>
squeeze_axes
;
if
(
contains
(
attributes
,
"shrink_axis_mask"
))
shrink_axis_mask
=
static_cast
<
uint32_t
>
(
attributes
.
at
(
"shrink_axis_mask"
).
i
());
for
(
size_t
i
=
0
;
i
<
num_axes
;
i
++
)
{
// the LSB corresponds to axis 0 when determining which axes to squeeze
if
(((
shrink_axis_mask
>>
i
)
&
bitwise_compare
)
==
1
)
squeeze_axes
.
push_back
(
i
);
}
if
(
num_axes
>=
4
)
{
squeeze_axes
=
parse_axes
(
squeeze_axes
);
}
auto
l0
=
prog
.
add_instruction
(
op
,
args
[
0
]);
return
prog
.
add_instruction
(
op
::
squeeze
{
squeeze_axes
},
l0
);
}
void
parse_graph
(
const
tensorflow
::
GraphDef
&
graph
)
void
parse_graph
(
const
tensorflow
::
GraphDef
&
graph
)
{
{
nodes
=
get_nodes
(
graph
,
input_nodes
);
nodes
=
get_nodes
(
graph
,
input_nodes
);
...
...
test/auto_contiguous_test.cpp
View file @
723d1f0b
...
@@ -60,7 +60,7 @@ TEST_CASE(after_literal_broadcast)
...
@@ -60,7 +60,7 @@ TEST_CASE(after_literal_broadcast)
auto
l2
=
p
.
add_literal
(
get_2
());
auto
l2
=
p
.
add_literal
(
get_2
());
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
broadcasted
());
EXPECT
(
not
p
.
get_shape
().
broadcasted
());
auto
b
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
l1
->
get_shape
()},
l2
);
auto
b
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
l1
->
get_shape
()
.
lens
()
},
l2
);
p
.
add_instruction
(
pass_op
{},
b
);
p
.
add_instruction
(
pass_op
{},
b
);
EXPECT
(
not
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
broadcasted
());
EXPECT
(
p
.
get_shape
().
broadcasted
());
...
@@ -91,7 +91,7 @@ TEST_CASE(after_param_broadcast)
...
@@ -91,7 +91,7 @@ TEST_CASE(after_param_broadcast)
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
2
}});
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
2
}});
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
broadcasted
());
EXPECT
(
not
p
.
get_shape
().
broadcasted
());
auto
b
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
l1
->
get_shape
()},
l2
);
auto
b
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
l1
->
get_shape
()
.
lens
()
},
l2
);
p
.
add_instruction
(
pass_op
{},
b
);
p
.
add_instruction
(
pass_op
{},
b
);
EXPECT
(
not
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
broadcasted
());
EXPECT
(
p
.
get_shape
().
broadcasted
());
...
...
test/cpu_dot_op_test.cpp
View file @
723d1f0b
...
@@ -351,7 +351,7 @@ TEST_CASE(gemm_mutli_dim1_2_3)
...
@@ -351,7 +351,7 @@ TEST_CASE(gemm_mutli_dim1_2_3)
float
beta
=
0.41
;
float
beta
=
0.41
;
auto
m12_alpha
=
p
.
add_instruction
(
migraphx
::
op
::
dot
{
alpha
,
beta
},
l1
,
l2
);
auto
m12_alpha
=
p
.
add_instruction
(
migraphx
::
op
::
dot
{
alpha
,
beta
},
l1
,
l2
);
auto
l_beta
=
p
.
add_literal
(
beta
);
auto
l_beta
=
p
.
add_literal
(
beta
);
auto
b_beta
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
m12_alpha
->
get_shape
()},
l_beta
);
auto
b_beta
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
m12_alpha
->
get_shape
()
.
lens
()
},
l_beta
);
auto
m3_beta
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
b_beta
,
l3
);
auto
m3_beta
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
b_beta
,
l3
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
m3_beta
,
m12_alpha
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
m3_beta
,
m12_alpha
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
p
.
compile
(
migraphx
::
cpu
::
target
{});
...
...
test/cpu_ops_test.cpp
View file @
723d1f0b
...
@@ -651,7 +651,7 @@ TEST_CASE(broadcast_test)
...
@@ -651,7 +651,7 @@ TEST_CASE(broadcast_test)
uint64_t
axis
=
0
;
uint64_t
axis
=
0
;
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
a_shape
,
a_data
});
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
a_shape
,
a_data
});
auto
l2
=
p
.
add_literal
(
migraphx
::
literal
{
b_shape
,
b_data
});
auto
l2
=
p
.
add_literal
(
migraphx
::
literal
{
b_shape
,
b_data
});
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l1
->
get_shape
()},
l2
);
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l1
->
get_shape
()
.
lens
()
},
l2
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
auto
result
=
p
.
eval
({});
auto
output
=
result
.
get
<
int32_t
>
();
auto
output
=
result
.
get
<
int32_t
>
();
...
@@ -671,7 +671,7 @@ TEST_CASE(add_broadcast_test)
...
@@ -671,7 +671,7 @@ TEST_CASE(add_broadcast_test)
uint64_t
axis
=
0
;
uint64_t
axis
=
0
;
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
a_shape
,
a_data
});
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
a_shape
,
a_data
});
auto
l2
=
p
.
add_literal
(
migraphx
::
literal
{
b_shape
,
b_data
});
auto
l2
=
p
.
add_literal
(
migraphx
::
literal
{
b_shape
,
b_data
});
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l1
->
get_shape
()},
l2
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l1
->
get_shape
()
.
lens
()
},
l2
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l1
,
l3
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l1
,
l3
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
auto
result
=
p
.
eval
({});
...
@@ -809,11 +809,11 @@ TEST_CASE(imagescaler_test)
...
@@ -809,11 +809,11 @@ TEST_CASE(imagescaler_test)
0.35
,
0.35
,
0.45
}});
0.45
}});
auto
scale_val
=
p
.
add_literal
(
2.
f
);
auto
scale_val
=
p
.
add_literal
(
2.
f
);
auto
scaled_tensor
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
s
},
scale_val
);
auto
scaled_tensor
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
s
.
lens
()
},
scale_val
);
auto
img_scaled
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
img
,
scaled_tensor
);
auto
img_scaled
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
img
,
scaled_tensor
);
auto
bias_vals
=
p
.
add_literal
(
auto
bias_vals
=
p
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
auto
bias_bcast
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
},
bias_vals
);
auto
bias_bcast
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
.
lens
()
},
bias_vals
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
img_scaled
,
bias_bcast
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
img_scaled
,
bias_bcast
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
auto
result
=
p
.
eval
({});
...
...
test/gpu/miopen.cpp
View file @
723d1f0b
...
@@ -371,7 +371,7 @@ struct test_scale : verify_program<test_scale>
...
@@ -371,7 +371,7 @@ struct test_scale : verify_program<test_scale>
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
migraphx
::
shape
::
float_type
);
auto
y
=
p
.
add_parameter
(
"y"
,
migraphx
::
shape
::
float_type
);
auto
scale
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
s
},
y
);
auto
scale
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
s
.
lens
()
},
y
);
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
x
,
scale
);
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
x
,
scale
);
return
p
;
return
p
;
}
}
...
@@ -417,7 +417,7 @@ struct test_triadd2 : verify_program<test_triadd2>
...
@@ -417,7 +417,7 @@ struct test_triadd2 : verify_program<test_triadd2>
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
auto
z
=
p
.
add_parameter
(
"z"
,
b
);
auto
z
=
p
.
add_parameter
(
"z"
,
b
);
auto
zb
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
},
z
);
auto
zb
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
.
lens
()
},
z
);
auto
sum
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
y
);
auto
sum
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
y
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sum
,
zb
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sum
,
zb
);
return
p
;
return
p
;
...
@@ -432,7 +432,7 @@ struct test_add_broadcast : verify_program<test_add_broadcast>
...
@@ -432,7 +432,7 @@ struct test_add_broadcast : verify_program<test_add_broadcast>
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}});
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
x
->
get_shape
()},
y
);
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
x
->
get_shape
()
.
lens
()
},
y
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
return
p
;
return
p
;
}
}
...
@@ -446,7 +446,7 @@ struct test_add_broadcast2 : verify_program<test_add_broadcast2>
...
@@ -446,7 +446,7 @@ struct test_add_broadcast2 : verify_program<test_add_broadcast2>
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()},
y
);
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()
.
lens
()
},
y
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
return
p
;
return
p
;
}
}
...
@@ -460,7 +460,7 @@ struct test_add_broadcast3 : verify_program<test_add_broadcast3>
...
@@ -460,7 +460,7 @@ struct test_add_broadcast3 : verify_program<test_add_broadcast3>
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
5
}});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
5
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
4
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
4
}});
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()},
y
);
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()
.
lens
()
},
y
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
return
p
;
return
p
;
}
}
...
@@ -474,7 +474,7 @@ struct test_add_broadcast4 : verify_program<test_add_broadcast4>
...
@@ -474,7 +474,7 @@ struct test_add_broadcast4 : verify_program<test_add_broadcast4>
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
5
}});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
5
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()},
y
);
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()
.
lens
()
},
y
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
return
p
;
return
p
;
}
}
...
@@ -488,7 +488,7 @@ struct test_add_broadcast5 : verify_program<test_add_broadcast5>
...
@@ -488,7 +488,7 @@ struct test_add_broadcast5 : verify_program<test_add_broadcast5>
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
8
}});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
8
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
4
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
4
}});
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()},
y
);
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
x
->
get_shape
()
.
lens
()
},
y
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
return
p
;
return
p
;
}
}
...
@@ -503,7 +503,7 @@ struct test_triadd_broadcast : verify_program<test_triadd_broadcast>
...
@@ -503,7 +503,7 @@ struct test_triadd_broadcast : verify_program<test_triadd_broadcast>
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}});
auto
z
=
p
.
add_parameter
(
"z"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}});
auto
z
=
p
.
add_parameter
(
"z"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}});
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
x
->
get_shape
()},
y
);
auto
by
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
0
,
x
->
get_shape
()
.
lens
()
},
y
);
auto
sum
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
auto
sum
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
x
,
by
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sum
,
z
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sum
,
z
);
return
p
;
return
p
;
...
@@ -535,7 +535,7 @@ struct test_sub2 : verify_program<test_sub2>
...
@@ -535,7 +535,7 @@ struct test_sub2 : verify_program<test_sub2>
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
auto
z
=
p
.
add_parameter
(
"z"
,
b
);
auto
z
=
p
.
add_parameter
(
"z"
,
b
);
auto
zb
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
},
z
);
auto
zb
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
.
lens
()
},
z
);
auto
diff
=
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
x
,
y
);
auto
diff
=
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
x
,
y
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
diff
,
zb
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
diff
,
zb
);
return
p
;
return
p
;
...
...
test/onnx/onnx_gru_reverse.onnx
View file @
723d1f0b
No preview for this file type
test/onnx/onnx_rnn_3args.onnx
View file @
723d1f0b
No preview for this file type
test/onnx/onnx_rnn_test.cpp
View file @
723d1f0b
...
@@ -154,7 +154,7 @@ TEST_CASE(rnn_test_one_direction)
...
@@ -154,7 +154,7 @@ TEST_CASE(rnn_test_one_direction)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
rnn
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
rnn
{
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
clip
},
seq
,
seq
,
w
,
w
,
...
@@ -339,7 +339,7 @@ TEST_CASE(gru_test_args)
...
@@ -339,7 +339,7 @@ TEST_CASE(gru_test_args)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
{
migraphx
::
op
::
relu
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
migraphx
::
op
::
rnn_direction
::
reverse
,
clip
},
clip
},
seq
,
seq
,
...
@@ -373,7 +373,10 @@ TEST_CASE(gru_test_args)
...
@@ -373,7 +373,10 @@ TEST_CASE(gru_test_args)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
relu
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
clip
},
seq
,
seq
,
...
@@ -414,8 +417,14 @@ TEST_CASE(gru_test_actv_funcs)
...
@@ -414,8 +417,14 @@ TEST_CASE(gru_test_actv_funcs)
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
gru
{
hs
,
{},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -445,9 +454,14 @@ TEST_CASE(gru_test_actv_funcs)
...
@@ -445,9 +454,14 @@ TEST_CASE(gru_test_actv_funcs)
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
gru
{
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
hs
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -479,7 +493,10 @@ TEST_CASE(gru_test_actv_funcs)
...
@@ -479,7 +493,10 @@ TEST_CASE(gru_test_actv_funcs)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
clip
},
seq
,
seq
,
...
@@ -511,9 +528,12 @@ TEST_CASE(gru_test_actv_funcs)
...
@@ -511,9 +528,12 @@ TEST_CASE(gru_test_actv_funcs)
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
gru
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{}},
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
clip
},
seq
,
seq
,
...
@@ -546,7 +566,10 @@ TEST_CASE(gru_test_actv_funcs)
...
@@ -546,7 +566,10 @@ TEST_CASE(gru_test_actv_funcs)
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -576,9 +599,11 @@ TEST_CASE(gru_test_actv_funcs)
...
@@ -576,9 +599,11 @@ TEST_CASE(gru_test_actv_funcs)
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
p
.
add_parameter
(
"seq_len"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
ih
=
p
.
add_parameter
(
"h0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
bs
,
hs
}});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
gru
{
p
.
add_instruction
(
migraphx
::
op
::
gru
{
hs
,
hs
,
{
migraphx
::
op
::
relu
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
clip
},
{
migraphx
::
op
::
relu
{},
migraphx
::
op
::
relu
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
clip
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -826,7 +851,12 @@ TEST_CASE(lstm_forward_actv_func)
...
@@ -826,7 +851,12 @@ TEST_CASE(lstm_forward_actv_func)
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -851,8 +881,10 @@ TEST_CASE(lstm_forward_actv_func)
...
@@ -851,8 +881,10 @@ TEST_CASE(lstm_forward_actv_func)
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
auto
out_hs
=
p
.
add_instruction
(
{
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -881,9 +913,10 @@ TEST_CASE(lstm_forward_actv_func)
...
@@ -881,9 +913,10 @@ TEST_CASE(lstm_forward_actv_func)
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
migraphx
::
op
::
lstm
{
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -993,7 +1026,12 @@ TEST_CASE(lstm_reverse)
...
@@ -993,7 +1026,12 @@ TEST_CASE(lstm_reverse)
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
clip
,
input_forget
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -1037,10 +1075,14 @@ TEST_CASE(lstm_bidirectional)
...
@@ -1037,10 +1075,14 @@ TEST_CASE(lstm_bidirectional)
auto
ic
=
p
.
add_parameter
(
"c0"
,
ih_shape
);
auto
ic
=
p
.
add_parameter
(
"c0"
,
ih_shape
);
auto
pph
=
p
.
add_parameter
(
"pph"
,
pph_shape
);
auto
pph
=
p
.
add_parameter
(
"pph"
,
pph_shape
);
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1067,10 +1109,14 @@ TEST_CASE(lstm_bidirectional)
...
@@ -1067,10 +1109,14 @@ TEST_CASE(lstm_bidirectional)
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1098,10 +1144,14 @@ TEST_CASE(lstm_bidirectional)
...
@@ -1098,10 +1144,14 @@ TEST_CASE(lstm_bidirectional)
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1130,10 +1180,14 @@ TEST_CASE(lstm_bidirectional)
...
@@ -1130,10 +1180,14 @@ TEST_CASE(lstm_bidirectional)
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1163,10 +1217,14 @@ TEST_CASE(lstm_bidirectional)
...
@@ -1163,10 +1217,14 @@ TEST_CASE(lstm_bidirectional)
auto
ih
=
p
.
add_parameter
(
"h0"
,
ih_shape
);
auto
ih
=
p
.
add_parameter
(
"h0"
,
ih_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1197,10 +1255,14 @@ TEST_CASE(lstm_bidirectional)
...
@@ -1197,10 +1255,14 @@ TEST_CASE(lstm_bidirectional)
auto
ic
=
p
.
add_parameter
(
"c0"
,
ih_shape
);
auto
ic
=
p
.
add_parameter
(
"c0"
,
ih_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1244,9 +1306,17 @@ TEST_CASE(lstm_bi_actv_funcs)
...
@@ -1244,9 +1306,17 @@ TEST_CASE(lstm_bi_actv_funcs)
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
auto
out_hs
=
migraphx
::
op
::
lstm
{
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
hs
,
{},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
input_forget
},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
input_forget
},
seq
,
seq
,
w
,
w
,
r
,
r
,
...
@@ -1273,7 +1343,12 @@ TEST_CASE(lstm_bi_actv_funcs)
...
@@ -1273,7 +1343,12 @@ TEST_CASE(lstm_bi_actv_funcs)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{}},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1304,7 +1379,12 @@ TEST_CASE(lstm_bi_actv_funcs)
...
@@ -1304,7 +1379,12 @@ TEST_CASE(lstm_bi_actv_funcs)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{}},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
input_forget
},
input_forget
},
...
@@ -1337,6 +1417,8 @@ TEST_CASE(lstm_bi_actv_funcs)
...
@@ -1337,6 +1417,8 @@ TEST_CASE(lstm_bi_actv_funcs)
auto
out_hs
=
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
tanh
{}},
...
@@ -1376,6 +1458,7 @@ TEST_CASE(lstm_bi_actv_funcs)
...
@@ -1376,6 +1458,7 @@ TEST_CASE(lstm_bi_actv_funcs)
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
,
clip
,
...
...
test/onnx/onnx_test.cpp
View file @
723d1f0b
...
@@ -15,7 +15,7 @@ TEST_CASE(pytorch_conv_bias_test)
...
@@ -15,7 +15,7 @@ TEST_CASE(pytorch_conv_bias_test)
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
uint64_t
axis
=
1
;
uint64_t
axis
=
1
;
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()},
l2
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()
.
lens
()
},
l2
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
prog
=
migraphx
::
parse_onnx
(
"conv.onnx"
);
auto
prog
=
migraphx
::
parse_onnx
(
"conv.onnx"
);
...
@@ -30,7 +30,7 @@ TEST_CASE(pytorch_conv_relu_maxpool)
...
@@ -30,7 +30,7 @@ TEST_CASE(pytorch_conv_relu_maxpool)
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
uint64_t
axis
=
1
;
uint64_t
axis
=
1
;
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()},
l2
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()
.
lens
()
},
l2
);
auto
l5
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
l5
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
l6
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l5
);
auto
l6
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l5
);
p
.
add_instruction
(
migraphx
::
op
::
pooling
{
"max"
,
{{
0
,
0
}},
{{
2
,
2
}},
{{
2
,
2
}}},
l6
);
p
.
add_instruction
(
migraphx
::
op
::
pooling
{
"max"
,
{{
0
,
0
}},
{{
2
,
2
}},
{{
2
,
2
}}},
l6
);
...
@@ -52,7 +52,7 @@ TEST_CASE(pytorch_conv_bn_relu_maxpool)
...
@@ -52,7 +52,7 @@ TEST_CASE(pytorch_conv_bn_relu_maxpool)
auto
p6
=
p
.
add_parameter
(
"6"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
p6
=
p
.
add_parameter
(
"6"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
uint64_t
axis
=
1
;
uint64_t
axis
=
1
;
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()},
l2
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()
.
lens
()
},
l2
);
auto
l5
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
l5
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
l6
=
p
.
add_instruction
(
migraphx
::
op
::
batch_norm_inference
{
1.0e-5
f
},
l5
,
p3
,
p4
,
p5
,
p6
);
auto
l6
=
p
.
add_instruction
(
migraphx
::
op
::
batch_norm_inference
{
1.0e-5
f
},
l5
,
p3
,
p4
,
p5
,
p6
);
auto
l7
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l6
);
auto
l7
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l6
);
...
@@ -70,7 +70,7 @@ TEST_CASE(pytorch_conv_relu_maxpool_x2)
...
@@ -70,7 +70,7 @@ TEST_CASE(pytorch_conv_relu_maxpool_x2)
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
5
}});
auto
l2
=
p
.
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
5
}});
uint64_t
axis
=
1
;
uint64_t
axis
=
1
;
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l0
,
l1
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()},
l2
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l3
->
get_shape
()
.
lens
()
},
l2
);
auto
l5
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
l5
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l4
);
auto
l6
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l5
);
auto
l6
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l5
);
auto
l7
=
p
.
add_instruction
(
migraphx
::
op
::
pooling
{
"max"
,
{{
0
,
0
}},
{{
2
,
2
}},
{{
2
,
2
}}},
l6
);
auto
l7
=
p
.
add_instruction
(
migraphx
::
op
::
pooling
{
"max"
,
{{
0
,
0
}},
{{
2
,
2
}},
{{
2
,
2
}}},
l6
);
...
@@ -78,7 +78,7 @@ TEST_CASE(pytorch_conv_relu_maxpool_x2)
...
@@ -78,7 +78,7 @@ TEST_CASE(pytorch_conv_relu_maxpool_x2)
auto
l8
=
p
.
add_parameter
(
"3"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
5
,
5
}});
auto
l8
=
p
.
add_parameter
(
"3"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
5
,
5
}});
auto
l9
=
p
.
add_parameter
(
"4"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l9
=
p
.
add_parameter
(
"4"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l10
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l7
,
l8
);
auto
l10
=
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
l7
,
l8
);
auto
l11
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l10
->
get_shape
()},
l9
);
auto
l11
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
axis
,
l10
->
get_shape
()
.
lens
()
},
l9
);
auto
l12
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l10
,
l11
);
auto
l12
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l10
,
l11
);
auto
l13
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l12
);
auto
l13
=
p
.
add_instruction
(
migraphx
::
op
::
relu
{},
l12
);
p
.
add_instruction
(
migraphx
::
op
::
pooling
{
"max"
,
{{
0
,
0
}},
{{
2
,
2
}},
{{
2
,
2
}}},
l13
);
p
.
add_instruction
(
migraphx
::
op
::
pooling
{
"max"
,
{{
0
,
0
}},
{{
2
,
2
}},
{{
2
,
2
}}},
l13
);
...
@@ -108,9 +108,9 @@ TEST_CASE(imagescaler_test)
...
@@ -108,9 +108,9 @@ TEST_CASE(imagescaler_test)
auto
scale_val
=
p
.
add_literal
(
0.5
f
);
auto
scale_val
=
p
.
add_literal
(
0.5
f
);
auto
bias_vals
=
p
.
add_literal
(
auto
bias_vals
=
p
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
auto
scaled_tensor
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
s
},
scale_val
);
auto
scaled_tensor
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
s
.
lens
()
},
scale_val
);
auto
img_scaled
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
l0
,
scaled_tensor
);
auto
img_scaled
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
l0
,
scaled_tensor
);
auto
bias_bcast
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
},
bias_vals
);
auto
bias_bcast
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
.
lens
()
},
bias_vals
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
img_scaled
,
bias_bcast
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
img_scaled
,
bias_bcast
);
auto
prog
=
migraphx
::
parse_onnx
(
"imagescaler_test.onnx"
);
auto
prog
=
migraphx
::
parse_onnx
(
"imagescaler_test.onnx"
);
...
@@ -338,7 +338,7 @@ TEST_CASE(add_bcast_test)
...
@@ -338,7 +338,7 @@ TEST_CASE(add_bcast_test)
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
l0
->
get_shape
()},
l1
);
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
l0
->
get_shape
()
.
lens
()
},
l1
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
l2
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
l2
);
auto
prog
=
migraphx
::
parse_onnx
(
"add_bcast_test.onnx"
);
auto
prog
=
migraphx
::
parse_onnx
(
"add_bcast_test.onnx"
);
...
@@ -365,7 +365,7 @@ TEST_CASE(sub_bcast_test)
...
@@ -365,7 +365,7 @@ TEST_CASE(sub_bcast_test)
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
l0
->
get_shape
()},
l1
);
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
l0
->
get_shape
()
.
lens
()
},
l1
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
l0
,
l2
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
l0
,
l2
);
auto
prog
=
migraphx
::
parse_onnx
(
"sub_bcast_test.onnx"
);
auto
prog
=
migraphx
::
parse_onnx
(
"sub_bcast_test.onnx"
);
...
...
Prev
1
2
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