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
9e284b7c
Commit
9e284b7c
authored
Jun 20, 2018
by
Paul
Browse files
Formatting
parent
570db377
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
src/include/rtg/shape_for_each.hpp
src/include/rtg/shape_for_each.hpp
+4
-1
src/shape.cpp
src/shape.cpp
+11
-8
No files found.
src/include/rtg/shape_for_each.hpp
View file @
9e284b7c
...
@@ -18,7 +18,10 @@ void shape_for_each(const rtg::shape& s, F f)
...
@@ -18,7 +18,10 @@ void shape_for_each(const rtg::shape& s, F f)
s
.
strides
().
end
(),
s
.
strides
().
end
(),
s
.
lens
().
begin
(),
s
.
lens
().
begin
(),
indices
.
begin
(),
indices
.
begin
(),
[
&
](
std
::
size_t
stride
,
std
::
size_t
len
)
{
assert
(
len
>
0
and
stride
>
0
);
return
(
i
/
stride
)
%
len
;
});
[
&
](
std
::
size_t
stride
,
std
::
size_t
len
)
{
assert
(
len
>
0
and
stride
>
0
);
return
(
i
/
stride
)
%
len
;
});
call
(
indices
);
call
(
indices
);
}
}
}
}
...
...
src/shape.cpp
View file @
9e284b7c
...
@@ -20,7 +20,8 @@ shape::shape(type_t t, std::vector<std::size_t> l, std::vector<std::size_t> s)
...
@@ -20,7 +20,8 @@ shape::shape(type_t t, std::vector<std::size_t> l, std::vector<std::size_t> s)
:
m_type
(
t
),
m_lens
(
std
::
move
(
l
)),
m_strides
(
std
::
move
(
s
))
:
m_type
(
t
),
m_lens
(
std
::
move
(
l
)),
m_strides
(
std
::
move
(
s
))
{
{
assert
(
m_lens
.
size
()
==
m_strides
.
size
());
assert
(
m_lens
.
size
()
==
m_strides
.
size
());
assert
(
std
::
any_of
(
m_strides
.
begin
(),
m_strides
.
end
(),
[](
auto
x
)
{
return
x
>
0
;
})
and
"At least one stride must be non-zero"
);
assert
(
std
::
any_of
(
m_strides
.
begin
(),
m_strides
.
end
(),
[](
auto
x
)
{
return
x
>
0
;
})
and
"At least one stride must be non-zero"
);
m_packed
=
this
->
elements
()
==
this
->
element_space
();
m_packed
=
this
->
elements
()
==
this
->
element_space
();
}
}
...
@@ -68,13 +69,15 @@ std::size_t shape::index(std::size_t i) const
...
@@ -68,13 +69,15 @@ std::size_t shape::index(std::size_t i) const
if
(
this
->
packed
())
if
(
this
->
packed
())
return
i
;
return
i
;
else
else
return
std
::
inner_product
(
return
std
::
inner_product
(
this
->
lens
().
begin
(),
this
->
lens
().
begin
(),
this
->
lens
().
end
(),
this
->
lens
().
end
(),
this
->
strides
().
begin
(),
this
->
strides
().
begin
(),
std
::
size_t
{
0
},
std
::
size_t
{
0
},
std
::
plus
<
std
::
size_t
>
{},
std
::
plus
<
std
::
size_t
>
{},
[
&
](
std
::
size_t
len
,
std
::
size_t
stride
)
{
[
&
](
std
::
size_t
len
,
std
::
size_t
stride
)
{
assert
(
stride
>
0
and
len
>
0
);
return
((
i
/
stride
)
%
len
)
*
stride
;
});
assert
(
stride
>
0
and
len
>
0
);
return
((
i
/
stride
)
%
len
)
*
stride
;
});
}
}
bool
shape
::
packed
()
const
{
return
this
->
m_packed
;
}
bool
shape
::
packed
()
const
{
return
this
->
m_packed
;
}
std
::
size_t
shape
::
element_space
()
const
std
::
size_t
shape
::
element_space
()
const
...
...
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