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
a67e6327
Commit
a67e6327
authored
Oct 17, 2022
by
charlie
Browse files
fixed-fixed test and fix strides bug
parent
bb7c3a25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
7 deletions
+53
-7
src/include/migraphx/op/multibroadcast.hpp
src/include/migraphx/op/multibroadcast.hpp
+6
-6
test/op_shape_test.cpp
test/op_shape_test.cpp
+47
-1
No files found.
src/include/migraphx/op/multibroadcast.hpp
View file @
a67e6327
...
...
@@ -64,11 +64,11 @@ struct multibroadcast
MIGRAPHX_THROW
(
"MULTIBROADCAST: inputs dimensions should be > 0"
);
}
auto
make_bcast_strides
=
[
&
](
std
::
size_t
out_num_dim
s
,
std
::
size_t
offset
)
{
std
::
vector
<
size_t
>
bcast_strides
(
out_num_dims
,
0
);
auto
make_bcast_strides
=
[
&
](
std
::
vector
<
std
::
size_t
>
bcast_len
s
,
std
::
size_t
offset
)
{
std
::
vector
<
size_t
>
bcast_strides
(
bcast_lens
.
size
()
,
0
);
for
(
std
::
ptrdiff_t
i
=
s0
.
lens
().
size
()
-
1
;
i
>=
0
;
i
--
)
{
if
(
outpu
t_lens
[
i
+
offset
]
==
s0
.
lens
()[
i
])
if
(
bcas
t_lens
[
i
+
offset
]
==
s0
.
lens
()[
i
])
{
bcast_strides
[
i
+
offset
]
=
s0
.
strides
()[
i
];
}
...
...
@@ -94,7 +94,7 @@ struct multibroadcast
}
}
auto
bcast_strides
=
make_bcast_strides
(
output_lens
.
size
()
,
offset
);
auto
bcast_strides
=
make_bcast_strides
(
output_lens
,
offset
);
return
{
t
,
output_lens
,
std
::
move
(
bcast_strides
)};
}
else
...
...
@@ -119,8 +119,8 @@ struct multibroadcast
else
{
auto
bcast_lens
=
compute_broadcasted_lens
(
s0
.
lens
(),
s1
.
lens
());
auto
offset
=
s1
.
lens
()
.
size
()
-
s0
.
lens
().
size
();
auto
bcast_strides
=
make_bcast_strides
(
s1
.
lens
().
size
()
,
offset
);
auto
offset
=
bcast_
lens
.
size
()
-
s0
.
lens
().
size
();
auto
bcast_strides
=
make_bcast_strides
(
bcast_lens
,
offset
);
return
{
t
,
std
::
move
(
bcast_lens
),
std
::
move
(
bcast_strides
)};
}
}
...
...
test/op_shape_test.cpp
View file @
a67e6327
...
...
@@ -1216,7 +1216,53 @@ TEST_CASE(multibroadcast_2in)
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
// both inputs are fixed
// fixed-fixed
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
8
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
},
{
0
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
8
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
8
},
{
0
,
0
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
},
{
16
,
4
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
1
,
4
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
},
{
4
,
0
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
}};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
}
}
TEST_CASE
(
multinomial
)
...
...
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