Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
7133540a
Commit
7133540a
authored
Aug 20, 2019
by
Adam Procter
Committed by
Scott Cyphers
Aug 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update clang-format rules for runtime/reference (#3479)
parent
79041d19
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
111 additions
and
30 deletions
+111
-30
.clang-format
src/ngraph/runtime/reference/.clang-format
+56
-0
avg_pool.hpp
src/ngraph/runtime/reference/avg_pool.hpp
+2
-1
concat.hpp
src/ngraph/runtime/reference/concat.hpp
+6
-5
convolution.hpp
src/ngraph/runtime/reference/convolution.hpp
+16
-5
divide.hpp
src/ngraph/runtime/reference/divide.hpp
+2
-2
dot.hpp
src/ngraph/runtime/reference/dot.hpp
+7
-5
gather.hpp
src/ngraph/runtime/reference/gather.hpp
+2
-1
gather_nd.hpp
src/ngraph/runtime/reference/gather_nd.hpp
+4
-2
max_pool.hpp
src/ngraph/runtime/reference/max_pool.hpp
+2
-1
one_hot.hpp
src/ngraph/runtime/reference/one_hot.hpp
+2
-2
pad.hpp
src/ngraph/runtime/reference/pad.hpp
+4
-2
reshape.hpp
src/ngraph/runtime/reference/reshape.hpp
+2
-1
reverse.hpp
src/ngraph/runtime/reference/reverse.hpp
+2
-1
scatter_nd_add.hpp
src/ngraph/runtime/reference/scatter_nd_add.hpp
+4
-2
No files found.
src/ngraph/runtime/reference/.clang-format
0 → 100644
View file @
7133540a
#
# OVERRIDE TO STYLE: Comments wrap.
#
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Never
Language: Cpp
Standard: Cpp11
AccessModifierOffset: -4
AlignConsecutiveDeclarations: false
AlignConsecutiveAssignments: false
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Allman
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 100
#CommentPragmas: '.*'
IndentCaseLabels: false
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: All
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SortIncludes: false
ReflowComments: true
IncludeCategories:
- Regex: '^".*'
Priority: 3
- Regex: '^<.*'
Priority: 2
SortIncludes: true
src/ngraph/runtime/reference/avg_pool.hpp
View file @
7133540a
...
...
@@ -158,7 +158,8 @@ namespace ngraph
//
// with unit stride.
//
// We iterate this over the *padded* data, so below we will need to check for coordinates that fall in the padding area.
// We iterate this over the *padded* data, so below we will need to check for
// coordinates that fall in the padding area.
size_t
n_spatial_dimensions
=
arg_shape
.
size
()
-
2
;
...
...
src/ngraph/runtime/reference/concat.hpp
View file @
7133540a
...
...
@@ -34,20 +34,21 @@ namespace ngraph
const
Shape
&
out_shape
,
size_t
concatenation_axis
)
{
// We will copy the inputs to the output one at a time. As we go, we will move out
along the
// concatenation axis, starting at 0.
// We will copy the inputs to the output one at a time. As we go, we will move out
//
along the
concatenation axis, starting at 0.
size_t
concatenation_pos
=
0
;
for
(
size_t
i
=
0
;
i
<
args
.
size
();
i
++
)
{
// CoordinateTransform gets confused when the last input has a zero-size dim, so
we will
// just skip for zero-element tensors.
// CoordinateTransform gets confused when the last input has a zero-size dim, so
//
we will
just skip for zero-element tensors.
if
(
shape_size
(
in_shapes
[
i
])
==
0
)
{
continue
;
}
// The start coordinate for the copy is (0,...,0) except at the concatenation axis.
// The start coordinate for the copy is (0,...,0) except at the concatenation
// axis.
Coordinate
out_start_coord
(
out_shape
.
size
(),
0
);
out_start_coord
[
concatenation_axis
]
=
concatenation_pos
;
...
...
src/ngraph/runtime/reference/convolution.hpp
View file @
7133540a
...
...
@@ -116,14 +116,19 @@ namespace ngraph
//
// (N,0,s_1*i_1,s_2*i_2,...,s_n*i_n) ->
//
// (N+1,chans_in_count,s_1*i_1 + l_1*filter_dims_1,...,s_n*i_n + l_n*filter_dims_n)
// (N+1,
// chans_in_count,
// s_1*i_1+ l_1*filter_dims_1,
/// ...,
/// s_n*i_n +l_n*filter_dims_n)
//
// with strides:
//
// (1,l_1,...,l_n).
//
// Note that we are iterating within the *padded* and *dilated* in batch, so further
// down we must check the current coordinate is in the pad or dilation gap.
// Note that we are iterating within the *padded* and *dilated* in batch, so
// further down we must check the current coordinate is in the pad or dilation
// gap.
size_t
n_spatial_dimensions
=
in_shape
.
size
()
-
2
;
size_t
n_in_channels
=
in_shape
[
in_channel_axis
];
...
...
@@ -171,13 +176,19 @@ namespace ngraph
in_transform_pad_above
,
in_transform_dilation_strides
);
// Simultaneously with iterating I, for the filter we need to iterate the coordinate:
// Simultaneously with iterating I, for the filter we need to iterate the
// coordinate:
//
// F
//
// over the range (noninclusive on the right):
//
// (chan_out,0,0,...,0) -> (chan_out+1,chans_in_count,filter_dims_1,...,filter_dims_n)
// (chan_out,0,0,...,0) ->
// (chan_out+1,
// chans_in_count,
// filter_dims_1,
// ...,
// filter_dims_n)
//
// with unit stride.
...
...
src/ngraph/runtime/reference/divide.hpp
View file @
7133540a
...
...
@@ -26,8 +26,8 @@ namespace ngraph
{
namespace
reference
{
// NOTE: Execution throws `std::domain_error` if either a non-integral value or an
out-of-bounds
// value is detected in the input tensor.
// NOTE: Execution throws `std::domain_error` if either a non-integral value or an
//
out-of-bounds
value is detected in the input tensor.
// In English: return type is void and T must be an integral type.
template
<
typename
T
>
...
...
src/ngraph/runtime/reference/dot.hpp
View file @
7133540a
...
...
@@ -58,8 +58,8 @@ namespace ngraph
auto
old_mode
=
std
::
fegetround
();
std
::
fesetround
(
FE_TONEAREST
);
// Get the sizes of the dot axes. It's easiest to pull them from arg1 because
they're
// right up front.
// Get the sizes of the dot axes. It's easiest to pull them from arg1 because
//
they're
right up front.
Shape
dot_axis_sizes
(
reduction_axes_count
);
std
::
copy
(
arg1_shape
.
begin
(),
arg1_shape
.
begin
()
+
reduction_axes_count
,
...
...
@@ -94,7 +94,8 @@ namespace ngraph
{
for
(
const
Coordinate
&
arg1_projected_coord
:
arg1_projected_transform
)
{
// The output coordinate is just the concatenation of the projected coordinates.
// The output coordinate is just the concatenation of the projected
// coordinates.
Coordinate
out_coord
(
arg0_projected_coord
.
size
()
+
arg1_projected_coord
.
size
());
...
...
@@ -117,8 +118,9 @@ namespace ngraph
arg0_coord
.
begin
());
for
(
const
Coordinate
&
dot_axis_positions
:
dot_axes_transform
)
{
// In order to find the points to multiply together, we need to inject our current
// positions along the dotted axes back into the projected arg0 and arg1 coordinates.
// In order to find the points to multiply together, we need to inject
// our current positions along the dotted axes back into the projected
// arg0 and arg1 coordinates.
std
::
copy
(
dot_axis_positions
.
begin
(),
dot_axis_positions
.
end
(),
arg0_it
);
...
...
src/ngraph/runtime/reference/gather.hpp
View file @
7133540a
...
...
@@ -106,7 +106,8 @@ namespace ngraph
params_outer_strides
,
params_outer_axis_order
);
// Create a CoordinateTransform for "indices" that visits only the first element along inner most axis
// Create a CoordinateTransform for "indices" that visits only the first element
// along inner most axis
Coordinate
indices_outer_start_corner
(
indices_ndim
,
0
);
Coordinate
indices_outer_end_corner
(
indices_shape
);
if
(
indices_ndim
>
0
)
...
...
src/ngraph/runtime/reference/gather_nd.hpp
View file @
7133540a
...
...
@@ -38,7 +38,8 @@ namespace ngraph
const
Shape
&
out_shape
)
{
using
namespace
std
;
// Create a CoordinateTransform for "indices" that visits only the first element along inner most axis
// Create a CoordinateTransform for "indices" that visits only the first element
// along inner most axis
size_t
indices_ndim
=
static_cast
<
size_t
>
(
indices_shape
.
size
());
Coordinate
indices_outer_start_corner
(
indices_ndim
,
0
);
Coordinate
indices_outer_end_corner
(
indices_shape
);
...
...
@@ -53,7 +54,8 @@ namespace ngraph
indices_strides
,
indices_axis_order
);
// Create a matching CoordinateTransform for "out" that visits the same outer coordinates
// Create a matching CoordinateTransform for "out" that visits the same outer
// coordinates
size_t
out_ndim
=
static_cast
<
size_t
>
(
out_shape
.
size
());
Coordinate
out_start_corner
(
out_ndim
,
0
);
Coordinate
out_end_corner
(
out_shape
);
...
...
src/ngraph/runtime/reference/max_pool.hpp
View file @
7133540a
...
...
@@ -155,7 +155,8 @@ namespace ngraph
//
// with unit stride.
//
// We iterate this over the *padded* data, so below we will need to check for coordinates that fall in the padding area.
// We iterate this over the *padded* data, so below we will need to check for
// coordinates that fall in the padding area.
size_t
n_spatial_dimensions
=
arg_shape
.
size
()
-
2
;
...
...
src/ngraph/runtime/reference/one_hot.hpp
View file @
7133540a
...
...
@@ -42,8 +42,8 @@ namespace ngraph
out
[
output_transform
.
index
(
output_coord
)]
=
0
;
}
// Step 2: Write ones at needed positions, throwing exceptions when invalid
conditions
// are encountered.
// Step 2: Write ones at needed positions, throwing exceptions when invalid
//
conditions
are encountered.
CoordinateTransform
input_transform
(
in_shape
);
for
(
const
Coordinate
&
input_coord
:
input_transform
)
...
...
src/ngraph/runtime/reference/pad.hpp
View file @
7133540a
...
...
@@ -40,8 +40,8 @@ namespace ngraph
op
::
PadMode
pad_mode
)
{
Coordinate
input_start
(
arg0_shape
.
size
(),
0
);
// start at (0,0,...,0)
Coordinate
input_end
=
out_shape
;
// end at (d'0,d'1,...,d'n), the outer corner of
the post-padding shape
Coordinate
input_end
=
out_shape
;
// end at (d'0,d'1,...,d'n), the outer corner of
//
the post-padding shape
Strides
input_strides
(
arg0_shape
.
size
(),
1
);
...
...
@@ -103,6 +103,7 @@ namespace ngraph
}
case
op
:
:
PadMode
::
REFLECT
:
{
// clang-format off
// The algorithm here is a bit complicated because if the padding is
// bigger than the tensor, we may reflect multiple times.
//
...
...
@@ -127,6 +128,7 @@ namespace ngraph
//
// Note that this algorithm works because REFLECT padding only makes sense
// if each dim is >= 2.
// clang-format on
Coordinate
c
=
in_coord
;
// have to copy because in_coord is const
for
(
size_t
i
=
0
;
i
<
c
.
size
();
i
++
)
...
...
src/ngraph/runtime/reference/reshape.hpp
View file @
7133540a
...
...
@@ -35,7 +35,8 @@ namespace ngraph
const
AxisVector
&
in_axis_order
,
const
Shape
&
out_shape
)
{
// Unfortunately we don't yet have a constructor for CoordinateTransform that lets us pass only source_space_shape
// Unfortunately we don't yet have a constructor for CoordinateTransform that lets
// us pass only source_space_shape
// and source_axis_order so we have to construct the defaults here.
Shape
in_start_corner
(
in_shape
.
size
(),
0
);
// (0,...0)
Strides
in_strides
(
in_shape
.
size
(),
1
);
// (1,...,1)
...
...
src/ngraph/runtime/reference/reverse.hpp
View file @
7133540a
...
...
@@ -33,7 +33,8 @@ namespace ngraph
const
Shape
&
out_shape
,
const
AxisSet
&
reversed_axes
)
{
// In fact arg_shape == out_shape, but we'll use both for stylistic consistency with other kernels.
// In fact arg_shape == out_shape, but we'll use both for stylistic consistency with
// other kernels.
CoordinateTransform
arg_transform
(
arg_shape
);
CoordinateTransform
output_transform
(
out_shape
);
...
...
src/ngraph/runtime/reference/scatter_nd_add.hpp
View file @
7133540a
...
...
@@ -40,7 +40,8 @@ namespace ngraph
using
namespace
std
;
// Copy inputs to out
memcpy
(
out
,
inputs
,
sizeof
(
T
)
*
shape_size
(
inputs_shape
));
// Create a CoordinateTransform for "indices" that visits only the first element along inner most axis
// Create a CoordinateTransform for "indices" that visits only the first element
// along inner most axis
size_t
indices_ndim
=
static_cast
<
size_t
>
(
indices_shape
.
size
());
Coordinate
indices_outer_start_corner
(
indices_ndim
,
0
);
Coordinate
indices_outer_end_corner
(
indices_shape
);
...
...
@@ -55,7 +56,8 @@ namespace ngraph
indices_strides
,
indices_axis_order
);
// Create a matching CoordinateTransform for "updates" that visits the same outer coordinates
// Create a matching CoordinateTransform for "updates" that visits the same outer
// coordinates
size_t
updates_ndim
=
static_cast
<
size_t
>
(
updates_shape
.
size
());
Strides
updates_strides
(
updates_ndim
,
1
);
AxisVector
updates_axis_order
(
updates_ndim
);
...
...
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