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
84af2e9e
Commit
84af2e9e
authored
Jun 25, 2018
by
Paul
Browse files
Formatting
parent
5f04935f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
28 deletions
+41
-28
src/shape.cpp
src/shape.cpp
+4
-2
src/targets/miopen/miopen_target.cpp
src/targets/miopen/miopen_target.cpp
+25
-21
test/include/test.hpp
test/include/test.hpp
+12
-5
No files found.
src/shape.cpp
View file @
84af2e9e
...
@@ -84,8 +84,10 @@ bool shape::packed() const { return this->m_packed; }
...
@@ -84,8 +84,10 @@ bool shape::packed() const { return this->m_packed; }
bool
shape
::
broadcasted
()
const
bool
shape
::
broadcasted
()
const
{
{
assert
(
this
->
lens
().
size
()
==
this
->
strides
().
size
());
assert
(
this
->
lens
().
size
()
==
this
->
strides
().
size
());
return
std
::
accumulate
(
return
std
::
accumulate
(
this
->
strides
().
begin
(),
this
->
strides
().
begin
(),
this
->
strides
().
end
(),
std
::
size_t
{
1
},
std
::
multiplies
<
std
::
size_t
>
())
==
0
;
this
->
strides
().
end
(),
std
::
size_t
{
1
},
std
::
multiplies
<
std
::
size_t
>
())
==
0
;
}
}
std
::
size_t
shape
::
element_space
()
const
std
::
size_t
shape
::
element_space
()
const
...
...
src/targets/miopen/miopen_target.cpp
View file @
84af2e9e
...
@@ -105,17 +105,21 @@ struct miopen_add
...
@@ -105,17 +105,21 @@ struct miopen_add
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
if
(
args
[
2
].
get_shape
().
broadcasted
())
{
if
(
args
[
2
].
get_shape
().
broadcasted
())
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
visit_all
(
result
,
from_gpu
(
args
[
1
]),
from_gpu
(
args
[
2
]))([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
visit_all
(
result
,
from_gpu
(
args
[
1
]),
from_gpu
(
args
[
2
]))(
[
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
shape_for_each
(
output
.
get_shape
(),
[
&
](
const
auto
&
idx
)
{
shape_for_each
(
output
.
get_shape
(),
[
&
](
const
auto
&
idx
)
{
output
(
idx
.
begin
(),
idx
.
end
())
=
output
(
idx
.
begin
(),
idx
.
end
())
=
input1
(
idx
.
begin
(),
idx
.
end
())
+
input2
(
idx
.
begin
(),
idx
.
end
());
input1
(
idx
.
begin
(),
idx
.
end
())
+
input2
(
idx
.
begin
(),
idx
.
end
());
});
});
});
});
return
to_gpu
(
result
);
return
to_gpu
(
result
);
}
else
{
}
else
{
float
alpha
=
1
,
beta
=
0
;
float
alpha
=
1
,
beta
=
0
;
auto
a_desc
=
make_tensor
(
args
[
1
].
get_shape
());
auto
a_desc
=
make_tensor
(
args
[
1
].
get_shape
());
auto
b_desc
=
make_tensor
(
args
[
2
].
get_shape
());
auto
b_desc
=
make_tensor
(
args
[
2
].
get_shape
());
...
...
test/include/test.hpp
View file @
84af2e9e
...
@@ -114,7 +114,7 @@ struct capture
...
@@ -114,7 +114,7 @@ struct capture
};
};
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
void
failed
(
T
x
,
const
char
*
msg
,
const
char
*
func
,
const
char
*
file
,
int
line
,
F
f
)
void
failed
(
T
x
,
const
char
*
msg
,
const
char
*
func
,
const
char
*
file
,
int
line
,
F
f
)
{
{
if
(
!
x
.
value
())
if
(
!
x
.
value
())
{
{
...
@@ -164,10 +164,17 @@ void run_test()
...
@@ -164,10 +164,17 @@ void run_test()
// NOLINTNEXTLINE
// NOLINTNEXTLINE
#define CHECK(...) \
#define CHECK(...) \
test::failed(test::capture{}->*__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, [] {})
test::failed( \
test::capture{}->*__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, [] { \
})
// NOLINTNEXTLINE
// NOLINTNEXTLINE
#define EXPECT(...) \
#define EXPECT(...) \
test::failed(test::capture{}->*__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, &std::abort)
test::failed(test::capture{}->*__VA_ARGS__, \
#__VA_ARGS__, \
__PRETTY_FUNCTION__, \
__FILE__, \
__LINE__, \
&std::abort)
// NOLINTNEXTLINE
// NOLINTNEXTLINE
#define STATUS(...) EXPECT((__VA_ARGS__) == 0)
#define STATUS(...) EXPECT((__VA_ARGS__) == 0)
...
...
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