Commit f04503b6 authored by Adam Procter's avatar Adam Procter Committed by Robert Kimball

Add asserts to reference to make sure we don't overshoot iterators (#1757)

* Add some asserts to make sure we don't overshoot certain iterators in the reference kernels

* Add missing assertion.hpp include
parent d9dfaeb8
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <cmath> #include <cmath>
#include "ngraph/assertion.hpp"
#include "ngraph/coordinate_transform.hpp" #include "ngraph/coordinate_transform.hpp"
namespace ngraph namespace ngraph
...@@ -60,6 +61,9 @@ namespace ngraph ...@@ -60,6 +61,9 @@ namespace ngraph
CoordinateTransform output_chunk_transform( CoordinateTransform output_chunk_transform(
out_shape, out_start_coord, out_end_coord); out_shape, out_start_coord, out_end_coord);
NGRAPH_ASSERT(shape_size(input_transform.get_target_shape()) ==
shape_size(output_chunk_transform.get_target_shape()));
CoordinateTransform::Iterator output_chunk_it = output_chunk_transform.begin(); CoordinateTransform::Iterator output_chunk_it = output_chunk_transform.begin();
for (const Coordinate& input_coord : input_transform) for (const Coordinate& input_coord : input_transform)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <cmath> #include <cmath>
#include "ngraph/assertion.hpp"
#include "ngraph/axis_vector.hpp" #include "ngraph/axis_vector.hpp"
#include "ngraph/coordinate_transform.hpp" #include "ngraph/coordinate_transform.hpp"
...@@ -77,6 +78,9 @@ namespace ngraph ...@@ -77,6 +78,9 @@ namespace ngraph
CoordinateTransform::Iterator output_it = output_transform.begin(); CoordinateTransform::Iterator output_it = output_transform.begin();
NGRAPH_ASSERT(shape_size(input_transform.get_target_shape()) ==
shape_size(output_transform.get_target_shape()));
for (const Coordinate& in_coord : input_transform) for (const Coordinate& in_coord : input_transform)
{ {
const Coordinate& out_coord = *output_it; const Coordinate& out_coord = *output_it;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <cmath> #include <cmath>
#include "ngraph/assertion.hpp"
#include "ngraph/coordinate_transform.hpp" #include "ngraph/coordinate_transform.hpp"
namespace ngraph namespace ngraph
...@@ -49,6 +50,9 @@ namespace ngraph ...@@ -49,6 +50,9 @@ namespace ngraph
CoordinateTransform output_transform( CoordinateTransform output_transform(
out_shape, lower_bounds, upper_bounds, strides); out_shape, lower_bounds, upper_bounds, strides);
NGRAPH_ASSERT(shape_size(input_transform.get_target_shape()) ==
shape_size(output_transform.get_target_shape()));
CoordinateTransform::Iterator output_it = output_transform.begin(); CoordinateTransform::Iterator output_it = output_transform.begin();
for (const Coordinate& input_coord : input_transform) for (const Coordinate& input_coord : input_transform)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <cmath> #include <cmath>
#include "ngraph/assertion.hpp"
#include "ngraph/axis_vector.hpp" #include "ngraph/axis_vector.hpp"
#include "ngraph/coordinate_transform.hpp" #include "ngraph/coordinate_transform.hpp"
...@@ -41,8 +42,11 @@ namespace ngraph ...@@ -41,8 +42,11 @@ namespace ngraph
CoordinateTransform input_transform( CoordinateTransform input_transform(
in_shape, in_start_corner, in_shape, in_strides, in_axis_order); in_shape, in_start_corner, in_shape, in_strides, in_axis_order);
CoordinateTransform output_transform(out_shape); CoordinateTransform output_transform(out_shape);
NGRAPH_ASSERT(shape_size(input_transform.get_target_shape()) ==
shape_size(output_transform.get_target_shape()));
CoordinateTransform::Iterator output_it = output_transform.begin(); CoordinateTransform::Iterator output_it = output_transform.begin();
for (const Coordinate& input_coord : input_transform) for (const Coordinate& input_coord : input_transform)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <cmath> #include <cmath>
#include "ngraph/assertion.hpp"
#include "ngraph/coordinate_transform.hpp" #include "ngraph/coordinate_transform.hpp"
namespace ngraph namespace ngraph
...@@ -40,6 +41,9 @@ namespace ngraph ...@@ -40,6 +41,9 @@ namespace ngraph
CoordinateTransform::Iterator output_it = output_transform.begin(); CoordinateTransform::Iterator output_it = output_transform.begin();
NGRAPH_ASSERT(shape_size(input_transform.get_target_shape()) ==
shape_size(output_transform.get_target_shape()));
for (const Coordinate& in_coord : input_transform) for (const Coordinate& in_coord : input_transform)
{ {
const Coordinate& out_coord = *output_it; const Coordinate& out_coord = *output_it;
......
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