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
a4383620
Commit
a4383620
authored
Aug 02, 2018
by
Paul
Browse files
Speed up element_space
parent
35d1f093
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
8 deletions
+3
-8
src/shape.cpp
src/shape.cpp
+3
-8
No files found.
src/shape.cpp
View file @
a4383620
...
...
@@ -93,16 +93,11 @@ bool shape::broadcasted() const
std
::
size_t
shape
::
element_space
()
const
{
// TODO: Get rid of intermediate vector
assert
(
this
->
lens
().
size
()
==
this
->
strides
().
size
());
std
::
vector
<
std
::
size_t
>
max_indices
(
this
->
lens
().
size
());
std
::
transform
(
this
->
lens
().
begin
(),
this
->
lens
().
end
(),
std
::
vector
<
std
::
size_t
>
(
this
->
lens
().
size
(),
1
).
begin
(),
max_indices
.
begin
(),
std
::
minus
<
std
::
size_t
>
());
return
std
::
inner_product
(
max_indices
.
begin
(),
max_indices
.
end
(),
this
->
strides
().
begin
(),
std
::
size_t
{
0
})
+
this
->
lens
().
begin
(),
this
->
lens
().
end
(),
this
->
strides
().
begin
(),
std
::
size_t
{
0
},
std
::
plus
<
std
::
size_t
>
{},
[](
std
::
size_t
l
,
std
::
size_t
s
)
{
return
(
l
-
1
)
*
s
;
})
+
1
;
}
...
...
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