Commit 7133540a authored by Adam Procter's avatar Adam Procter Committed by Scott Cyphers

Update clang-format rules for runtime/reference (#3479)

parent 79041d19
#
# 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
......@@ -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;
......
......@@ -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;
......
......@@ -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.
......
......@@ -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>
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
......
......@@ -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++)
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment