Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
aml
Commits
deb43b19
Commit
deb43b19
authored
Aug 06, 2019
by
Swann Perarnau
Browse files
[fix] quality
parent
aa29e096
Pipeline
#8170
passed with stages
in 26 minutes and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Sidebyside
AUTHORS
View file @
deb43b19
...
...
@@ 4,3 +4,4 @@ Brian Suchy <briansuchy2022@u.northwestern.edu>
Valentin Reis <fre@freux.fr>
Nicolas Denoyelle <ndenoyelle@anl.gov>
Clement Foyer <cfoyer@cray.com>
Brice Videau <bvideau@anl.gov>
src/layout/dense.c
View file @
deb43b19
...
...
@@ 63,7 +63,7 @@ void aml_layout_dense_init_cpitch(struct aml_layout *layout,
memcpy
(
data
>
dims
,
dims
,
ndims
*
sizeof
(
size_t
));
memcpy
(
data
>
stride
,
stride
,
ndims
*
sizeof
(
size_t
));
memcpy
(
data
>
cpitch
,
cpitch
,
(
ndims
+
1
)
*
sizeof
(
size_t
));
for
(
size_t
i
=
0
;
i
<
ndims
;
i
++
)
for
(
size_t
i
=
0
;
i
<
ndims
;
i
++
)
data
>
pitch
[
i
]
=
cpitch
[
i
+
1
]
/
cpitch
[
i
];
}
...
...
@@ 208,21 +208,21 @@ static void merge_dims(const size_t ndims,
size_t
dim_index
=
0
;
size_t
new_dim_index
=
0
;
/* Greedy algorithm that tries to merge dimensions starting with the
first */
/* Greedy algorithm that tries to merge dimensions starting with the
*
first */
new_dims
[
new_dim_index
]
=
dims
[
dim_index
];
new_cpitch
[
new_dim_index
]
=
cpitch
[
dim_index
];
new_stride
[
new_dim_index
]
=
stride
[
dim_index
];
/* While we haven't consumed all dimensions */
while
(
dim_index
<
ndims

1
)
{
/* Check if current dimension can be merged with the next.
ie: current dimension is not padded && next dimension has
no stride */
*
ie: current dimension is not padded && next dimension has
*
no stride */
if
(
dims
[
dim_index
]
*
stride
[
dim_index
]
*
cpitch
[
dim_index
]
==
cpitch
[
dim_index
+
1
]
&&
stride
[
dim_index
+
1
]
==
1
)
{
new_dims
[
new_dim_index
]
*=
dims
[
dim_index
+
1
];
/* Else add a new dimension with the same characteristic
as the
dimensions we were trying to merge */
/* Else add a new dimension with the same characteristic
* as the
dimensions we were trying to merge */
}
else
{
new_dim_index
++
;
new_dims
[
new_dim_index
]
=
dims
[
dim_index
+
1
];
...
...
@@ 254,30 +254,30 @@ static int reshape_dims(const struct aml_layout_dense *d,
size_t
m_cpitch
[
d
>
ndims
+
1
];
/* First obtain a canonical representation of the layout
that uses the least amount of dimensions. */
*
that uses the least amount of dimensions. */
merge_dims
(
d
>
ndims
,
d
>
dims
,
d
>
stride
,
d
>
cpitch
,
&
m_ndims
,
m_dims
,
m_stride
,
m_cpitch
);
size_t
m_dim_index
=
0
;
/* Greedy algorithm that tries to split the canonical
representation into the given new dimensions starting from the
first. The canonical representation is destroyed in the process. */
*
representation into the given new dimensions starting from the
*
first. The canonical representation is destroyed in the process. */
n_cpitch
[
0
]
=
m_cpitch
[
m_dim_index
];
for
(
size_t
i
=
0
;
i
<
ndims
;
i
++
)
{
/* If the new dimension perfectly fits in the current merged
dimensions, then the new stride and cumulative pitch are
copied from the current merged dimension. The next merged
dimension becomes current. */
/* If the new dimension perfectly fits in the current merged
*
dimensions, then the new stride and cumulative pitch are
*
copied from the current merged dimension. The next merged
*
dimension becomes current. */
if
(
m_dims
[
m_dim_index
]
==
dims
[
i
])
{
n_stride
[
i
]
=
m_stride
[
m_dim_index
];
n_cpitch
[
i
+
1
]
=
m_cpitch
[
m_dim_index
+
1
];
m_dim_index
++
;
/* Else if the current merged dimension can be evenly split by
the new dimension, we divide the current merged dimension by
the new dimension, merged stride is consumed and becomes 1
and cumulative pitch is computed from the new stride and
dimensions. */
*
the new dimension, we divide the current merged dimension by
*
the new dimension, merged stride is consumed and becomes 1
*
and cumulative pitch is computed from the new stride and
*
dimensions. */
}
else
if
(
m_dims
[
m_dim_index
]
%
dims
[
i
]
==
0
)
{
m_dims
[
m_dim_index
]
/=
dims
[
i
];
n_stride
[
i
]
=
m_stride
[
m_dim_index
];
...
...
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