Deprecate coordinate transform (#6425)
* Deprecate coordinate transform * Fix Windows build * Deprecated index
This commit is contained in:
parent
64cbdb9c22
commit
fea3ada931
@ -40,6 +40,7 @@ ngraph::pass::InitConstMask::InitConstMask(const ngraph::AxisSet & dims,
|
||||
end[dim] = value + 1;
|
||||
|
||||
bool skip_dim_value = false;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform iter(shape, begin, end);
|
||||
for (const Coordinate & coord : iter) {
|
||||
if (!condition(values.at(iter.index(coord)))) {
|
||||
@ -47,6 +48,7 @@ ngraph::pass::InitConstMask::InitConstMask(const ngraph::AxisSet & dims,
|
||||
break;
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
if (!skip_dim_value) {
|
||||
mask->at(dim).insert(value);
|
||||
}
|
||||
|
@ -35,10 +35,12 @@ Output<Node> create_constant_with_zeros(const Shape & shape, const Mask & mask)
|
||||
Coordinate coord_end(shape);
|
||||
coord_end[dim] = dim_value + 1;
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform iter(shape, coord_begin, coord_end);
|
||||
for (const Coordinate & coord : iter) {
|
||||
values[iter.index(coord)] = 0;
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
}
|
||||
return std::make_shared<opset5::Constant>(element::f32, shape, values);
|
||||
@ -57,10 +59,12 @@ TEST(TransformationTests, InitMasksOutputChannel) {
|
||||
Shape weights_shape{6, 3, 3, 3};
|
||||
|
||||
std::vector<double> values(shape_size(weights_shape), 1);
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform iter(weights_shape, {0, 1, 0, 0}, {6, 2, 3, 3});
|
||||
for (const Coordinate & coord : iter) {
|
||||
values[iter.index(coord)] = 0;
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
|
||||
auto weights = std::make_shared<opset5::Constant>(element::f32, weights_shape, values);
|
||||
pass::InitConstMask({1}).apply(weights);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ngraph/axis_vector.hpp"
|
||||
#include "ngraph/coordinate.hpp"
|
||||
#include "ngraph/coordinate_diff.hpp"
|
||||
#include "ngraph/deprecated.hpp"
|
||||
#include "ngraph/shape.hpp"
|
||||
#include "ngraph/strides.hpp"
|
||||
|
||||
@ -17,6 +18,7 @@ namespace ngraph
|
||||
/// produces the following coordinates:
|
||||
/// {0,0}, {0,1}, {0,2},
|
||||
/// {1,0}, {1,1}, {2,2}
|
||||
/// \deprecated
|
||||
class CoordinateIterator
|
||||
{
|
||||
/// \brief Coordinates iterator constructor
|
||||
@ -79,6 +81,8 @@ namespace ngraph
|
||||
|
||||
/// \brief The tensor element index calculation by given coordinate.
|
||||
/// \param c tensor element coordinate
|
||||
/// \deprecated
|
||||
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon.")
|
||||
size_t index(const Coordinate& c) const noexcept;
|
||||
|
||||
/// \brief Returns an iterator to the first coordinate of the tensor.
|
||||
@ -94,7 +98,9 @@ namespace ngraph
|
||||
/// \brief Class which allows to calculate item index with given coordinates in tensor
|
||||
/// and helps to iterate over the subset of coordinates.
|
||||
/// Tensor items should be placed in memory in row-major order.
|
||||
class CoordinateTransform : protected CoordinateTransformBasic
|
||||
/// \deprecated
|
||||
class NGRAPH_DEPRECATED("This class is deprecated and will be removed soon.")
|
||||
CoordinateTransform : protected CoordinateTransformBasic
|
||||
{
|
||||
public:
|
||||
using Iterator = CoordinateIterator;
|
||||
|
@ -315,6 +315,7 @@ namespace ngraph
|
||||
}
|
||||
}
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform arg0_transform(arg0_shape);
|
||||
CoordinateTransform arg1_transform(arg1_squeezed_shape);
|
||||
CoordinateTransform output_transform(arg0_shape);
|
||||
@ -326,6 +327,7 @@ namespace ngraph
|
||||
elementwise_functor(arg0[arg0_transform.index(output_coord)],
|
||||
arg1[arg1_transform.index(arg1_coord)]);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -437,6 +439,7 @@ namespace ngraph
|
||||
arg1_padded_shape[i]}));
|
||||
}
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform arg0_transform(arg0_squeezed_shape);
|
||||
CoordinateTransform arg1_transform(arg1_squeezed_shape);
|
||||
CoordinateTransform arg2_transform(arg2_squeezed_shape);
|
||||
@ -452,6 +455,7 @@ namespace ngraph
|
||||
arg1[arg1_transform.index(arg1_coord)],
|
||||
arg2[arg2_transform.index(arg2_coord)]);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
break;
|
||||
case op::AutoBroadcastType::PDPD:
|
||||
@ -521,6 +525,7 @@ namespace ngraph
|
||||
}
|
||||
}
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform arg0_transform(arg0_squeezed_shape);
|
||||
CoordinateTransform arg1_transform(arg1_shape);
|
||||
CoordinateTransform arg2_transform(arg2_squeezed_shape);
|
||||
@ -535,6 +540,7 @@ namespace ngraph
|
||||
arg1[arg1_transform.index(output_coord)],
|
||||
arg2[arg2_transform.index(arg2_coord)]);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ namespace ngraph
|
||||
const Shape& padding_above,
|
||||
bool include_padding_in_avg_computation)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform out_transform(out_shape);
|
||||
|
||||
for (const Coordinate& out_coord : out_transform)
|
||||
@ -107,6 +108,7 @@ namespace ngraph
|
||||
}
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -120,6 +122,7 @@ namespace ngraph
|
||||
const Shape& padding_above,
|
||||
bool include_padding_in_avg_computation)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
auto old_mode = std::fegetround();
|
||||
std::fesetround(FE_TONEAREST);
|
||||
// At the outermost level we will walk over every output coordinate O.
|
||||
@ -259,6 +262,7 @@ namespace ngraph
|
||||
}
|
||||
std::fesetround(old_mode);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -32,6 +32,7 @@ namespace ngraph
|
||||
T* out,
|
||||
const Shape& in_shape)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
auto eps_casted = static_cast<T>(eps);
|
||||
|
||||
size_t in_idx = 0;
|
||||
@ -48,6 +49,7 @@ namespace ngraph
|
||||
out[in_idx] = normalized * ch_gamma + ch_beta;
|
||||
in_idx++;
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -23,6 +23,7 @@ namespace ngraph
|
||||
const Shape& out_shape,
|
||||
const bool ctc_merge_repeated)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
const auto max_seq_len = data_shape[0];
|
||||
const auto batch_size = data_shape[1];
|
||||
const auto class_count = data_shape[2];
|
||||
@ -66,6 +67,7 @@ namespace ngraph
|
||||
}
|
||||
}
|
||||
std::copy(tmp_out.begin(), tmp_out.end(), out);
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -27,6 +27,7 @@ namespace ngraph
|
||||
const bool exclusive,
|
||||
const bool reverse)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform temp_transform(tensor_shape);
|
||||
for (const Coordinate& output_coord : temp_transform)
|
||||
{
|
||||
@ -126,6 +127,7 @@ namespace ngraph
|
||||
{
|
||||
cum_sum(it.second);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -389,6 +389,7 @@ namespace ngraph
|
||||
{
|
||||
auto info = helper.get_info_for_linear_mode();
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform output_transform(m_out_shape);
|
||||
CoordinateTransform input_transform(m_input_data_shape);
|
||||
|
||||
@ -424,6 +425,7 @@ namespace ngraph
|
||||
out[output_transform.index(output_coord)] = static_cast<T>(summa / wsum);
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -586,6 +588,7 @@ namespace ngraph
|
||||
size_t input_rank = m_input_data_shape.size();
|
||||
size_t num_of_axes = m_axes.size();
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform output_transform(m_out_shape);
|
||||
CoordinateTransform input_transform(m_input_data_shape);
|
||||
Shape indices_shape{std::vector<size_t>(num_of_axes, 4)};
|
||||
@ -631,11 +634,13 @@ namespace ngraph
|
||||
|
||||
out[output_transform.index(output_coord)] = static_cast<T>(summa);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void InterpolateEval<T>::nearest_func(const T* input_data, T* out)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform output_transform(m_out_shape);
|
||||
CoordinateTransform input_transform(m_input_data_shape);
|
||||
|
||||
@ -645,6 +650,7 @@ namespace ngraph
|
||||
out[output_transform.index(output_coord)] =
|
||||
input_data[input_transform.index(input_coord)];
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -19,6 +19,7 @@ namespace ngraph
|
||||
template <typename T>
|
||||
void log_softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
auto temp_shape = reduce(shape, axes, true);
|
||||
auto temp_elements = shape_size(temp_shape);
|
||||
auto temp_max = std::vector<T>(temp_elements, 0);
|
||||
@ -44,6 +45,7 @@ namespace ngraph
|
||||
(arg[transform.index(coord)] - temp_max[temp_transform.index(temp_coord)]) -
|
||||
std::log(temp_sum[temp_transform.index(temp_coord)]);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -73,6 +73,7 @@ namespace ngraph
|
||||
double dbias,
|
||||
size_t size)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
T alpha = static_cast<T>(dalpha);
|
||||
T beta = static_cast<T>(dbeta);
|
||||
T bias = static_cast<T>(dbias);
|
||||
@ -111,6 +112,7 @@ namespace ngraph
|
||||
T x = arg[index];
|
||||
out[index] = x / (std::pow(bias + scale * square_sum, beta));
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -24,6 +24,7 @@ namespace ngraph
|
||||
const Shape& padding_below,
|
||||
const Shape& padding_above)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
// At the outermost level we will walk over every output coordinate O.
|
||||
CoordinateTransform output_transform(out_shape);
|
||||
|
||||
@ -119,6 +120,7 @@ namespace ngraph
|
||||
|
||||
out[output_transform.index(out_coord)] = result;
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -24,6 +24,7 @@ namespace ngraph
|
||||
size_t sequence_axis,
|
||||
const U* sequence_lengths)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform input_transform(arg_shape);
|
||||
for (const Coordinate& in_coord : input_transform)
|
||||
{
|
||||
@ -51,6 +52,7 @@ namespace ngraph
|
||||
out_coord[sequence_axis] = sequence_index;
|
||||
out[input_transform.index(out_coord)] = arg[input_transform.index(in_coord)];
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -35,6 +35,7 @@ namespace ngraph
|
||||
auto feature_map_width = feature_maps_shape[3];
|
||||
auto num_rois = rois_shape[0];
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform feature_maps_transform(feature_maps_shape);
|
||||
CoordinateTransform rois_transform(rois_shape);
|
||||
CoordinateTransform out_transform(out_shape);
|
||||
@ -225,6 +226,7 @@ namespace ngraph
|
||||
tmp_out.clear();
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
return;
|
||||
}
|
||||
} // namespace reference
|
||||
|
@ -33,6 +33,7 @@ namespace ngraph
|
||||
// output[i][indices[i][j][k]][k] = updates[i][j][k] if axis = 1,
|
||||
// output[i][j][indices[i][j][k]] = updates[i][j][k] if axis = 2
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform indices_transform{indices_shape};
|
||||
CoordinateTransform data_transform{data_shape};
|
||||
|
||||
@ -47,6 +48,7 @@ namespace ngraph
|
||||
".");
|
||||
out_buf[data_transform.index(out_cord)] = updates[indices_idx];
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -41,6 +41,7 @@ namespace ngraph
|
||||
// u_coord in slice updates[..., i_coord, ...]
|
||||
// data[index(d_coord)] = updates[index(u_coord)]
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform indices_transform{indices_shape};
|
||||
CoordinateTransform data_transform{data_shape};
|
||||
|
||||
@ -106,6 +107,7 @@ namespace ngraph
|
||||
}
|
||||
updates_indices_coord_iter++;
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -25,6 +25,7 @@ namespace ngraph
|
||||
|
||||
max(arg, temp_ptr, shape, axes);
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform transform(shape);
|
||||
CoordinateTransform temp_transform(temp_shape);
|
||||
for (const Coordinate& coord : transform)
|
||||
@ -43,6 +44,7 @@ namespace ngraph
|
||||
}
|
||||
|
||||
delete[] temp_ptr;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -61,6 +61,7 @@ namespace ngraph
|
||||
bool compute_max,
|
||||
op::v1::TopK::SortType sort = op::v1::TopK::SortType::NONE)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
using namespace std;
|
||||
// reorder source axis visit order and make "axis" inner most
|
||||
size_t ndim = static_cast<size_t>(in_shape.size());
|
||||
@ -133,6 +134,7 @@ namespace ngraph
|
||||
out_index += out_axis_stride;
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "ngraph/util.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -83,6 +83,7 @@ void runtime::reference::gather_tree(const char* step_ids,
|
||||
throw ngraph_error("max_seq_len must have size of BATCH_SIZE");
|
||||
}
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
ngraph::CoordinateTransform cordinate_transform(step_ids_shape);
|
||||
|
||||
for (const auto& coord : cordinate_transform)
|
||||
@ -136,4 +137,5 @@ void runtime::reference::gather_tree(const char* step_ids,
|
||||
}
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
@ -137,6 +137,7 @@ InterpolateEvalHelper::InfoForLinearMode InterpolateEvalHelper::get_info_for_lin
|
||||
std::vector<float> a(num_of_axes);
|
||||
std::vector<int64_t> r(num_of_axes);
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform output_transform(m_out_shape);
|
||||
CoordinateTransform input_transform(m_input_data_shape);
|
||||
|
||||
@ -159,6 +160,7 @@ InterpolateEvalHelper::InfoForLinearMode InterpolateEvalHelper::get_info_for_lin
|
||||
result.r = r;
|
||||
result.prod_a = prod_a;
|
||||
result.shape_for_indeces = shape_for_indeces;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace ngraph
|
||||
const Shape& out_shape,
|
||||
size_t elem_size)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
const CoordinateTransform input_transform(
|
||||
arg_shape, lower_bounds, upper_bounds, strides);
|
||||
|
||||
@ -45,6 +46,7 @@ namespace ngraph
|
||||
std::advance(dst_mem, elem_size);
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace runtime
|
||||
|
@ -439,6 +439,7 @@ static void pad_input_data(const uint8_t* data_ptr,
|
||||
const Shape& padded_input_shape,
|
||||
const std::vector<size_t>& pads_begin)
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
CoordinateTransform input_transform(input_shape);
|
||||
CoordinateTransform padded_transform(padded_input_shape);
|
||||
|
||||
@ -455,6 +456,7 @@ static void pad_input_data(const uint8_t* data_ptr,
|
||||
const uint8_t* src_ptr = data_ptr + type_size * input_transform.index(input_coord);
|
||||
memcpy(dst_ptr, src_ptr, type_size);
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
bool op::v4::Interpolate::evaluate_interpolate(const HostTensorVector& outputs,
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
TEST(coordinate, shape0d)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user