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
e5a25712
Commit
e5a25712
authored
Aug 22, 2022
by
Paul
Browse files
Vector dot
parent
c4add749
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
src/targets/gpu/kernels/include/migraphx/kernels/array.hpp
src/targets/gpu/kernels/include/migraphx/kernels/array.hpp
+12
-8
No files found.
src/targets/gpu/kernels/include/migraphx/kernels/array.hpp
View file @
e5a25712
...
@@ -150,18 +150,13 @@ struct array
...
@@ -150,18 +150,13 @@ struct array
constexpr
T
dot
(
const
array
&
x
)
const
constexpr
T
dot
(
const
array
&
x
)
const
{
{
T
result
=
0
;
auto
r
=
x
*
(
*
this
);
for
(
index_int
i
=
0
;
i
<
N
;
i
++
)
return
r
.
reduce
([](
auto
a
,
auto
b
)
{
return
a
+
b
;
},
0
);
result
+=
x
[
i
]
*
d
[
i
];
return
result
;
}
}
constexpr
T
product
()
const
constexpr
T
product
()
const
{
{
T
result
=
1
;
return
reduce
([](
auto
x
,
auto
y
)
{
return
x
*
y
;
},
1
);
for
(
index_int
i
=
0
;
i
<
N
;
i
++
)
result
*=
d
[
i
];
return
result
;
}
}
constexpr
T
single
(
index_int
width
=
100
)
const
constexpr
T
single
(
index_int
width
=
100
)
const
...
@@ -185,6 +180,15 @@ struct array
...
@@ -185,6 +180,15 @@ struct array
return
result
;
return
result
;
}
}
template
<
class
F
>
constexpr
auto
reduce
(
F
f
,
T
init
)
const
{
T
result
=
init
;
for
(
index_int
i
=
0
;
i
<
N
;
i
++
)
result
=
f
(
result
,
d
[
i
]);
return
result
;
}
MIGRAPHX_DEVICE_ARRAY_OP
(
+=
,
+
)
MIGRAPHX_DEVICE_ARRAY_OP
(
+=
,
+
)
MIGRAPHX_DEVICE_ARRAY_OP
(
-=
,
-
)
MIGRAPHX_DEVICE_ARRAY_OP
(
-=
,
-
)
MIGRAPHX_DEVICE_ARRAY_OP
(
*=
,
*
)
MIGRAPHX_DEVICE_ARRAY_OP
(
*=
,
*
)
...
...
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