namespace ov::op::slice

Overview

namespace slice {

// typedefs

typedef std::pair<int64_t, int64_t> Bounds;

// structs

struct AxesMap;

// global variables

constexpr std::array<char const  \*, 4> shape_names {"start", "stop", "step", "axes"};

// global functions

int64_t get_sliced_value(
    const int64_t dim,
    const int64_t start,
    const int64_t stop,
    const int64_t step
    );

element::Type get_input_const_element_type(
    const ov::Node \* op,
    size_t idx,
    const std::map<size_t, HostTensorPtr>& constant_data = {}
    );

constexpr bool is_bounds_zero_crossing(const Bounds b);

template <class TDim>
constexpr bool is_lb_within_dim(
    const int64_t lb,
    const TDim& dim
    );

template <class TDim>
constexpr bool is_ub_within_dim(
    const int64_t ub,
    const TDim& dim
    );

template <class TShape, class TResult = std::vector<Bounds>>
std::unique_ptr<TResult> get_input_bounds(
    const ov::Node \* op,
    size_t idx,
    const std::map<size_t, HostTensorPtr>& constant_data
    );

template <class TDim>
TDim make_dim(
    const TDim& dim,
    const Bounds& start,
    const Bounds& stop,
    int64_t step
    );

} // namespace slice

Detailed Documentation

Typedefs

typedef std::pair<int64_t, int64_t> Bounds

Alias to dimension bounds for slice.

Global Functions

int64_t get_sliced_value(
    const int64_t dim,
    const int64_t start,
    const int64_t stop,
    const int64_t step
    )

Get sliced value in step for given dimension value and start, stop, step.

This function cannot be use for step 0 (division by 0)

Parameters:

dim

Dimension value.

start

Start of slice.

stop

Stop of slice.

step

Step of slice.

Returns:

-1 for infinite number otherwise [0..int64_max] for finit step.

constexpr bool is_bounds_zero_crossing(const Bounds b)

Check if bounds can cross 0 value (rising edge).

Parameters:

b

Input interval bounds for check.

Returns:

True if lower bound is negative and upper is not negative, otherwise false.

template <class TDim>
constexpr bool is_lb_within_dim(
    const int64_t lb,
    const TDim& dim
    )

Check if lower bound is within dimension.

Check valid only if bounds can cross zero value (lb is negative).

Parameters:

lb

Lower bound for check.

dim

Dimension used to check lower bound.

Returns:

True if lower bound is within dimension length, otherwise false.

template <class TDim>
constexpr bool is_ub_within_dim(
    const int64_t ub,
    const TDim& dim
    )

Check if upper bound is within dimension.

Check valid only if bounds can cross zero value (up is not negative).

Parameters:

ub

Upper bound for check.

dim

Dimension used to check upper bound.

Returns:

True if upper bound is within dimension length, otherwise false.

template <class TShape, class TResult = std::vector<Bounds>>
std::unique_ptr<TResult> get_input_bounds(
    const ov::Node \* op,
    size_t idx,
    const std::map<size_t, HostTensorPtr>& constant_data
    )

Get the input bounds from constant input (constant map) or evaluate bunds and return them as vector of pairs (lower, upper).

Parameters:

TShape

Shape type.

op

Operator pointer.

idx

Input index.

constant_data

Map with constant data.

Returns:

Return vector of slice::Bounds.

template <class TDim>
TDim make_dim(
    const TDim& dim,
    const Bounds& start,
    const Bounds& stop,
    int64_t step
    )

Make sliced dimension for input dimension by step from start to stop bounds.

Parameters:

TDim

Type of in/out dimension.

dim

Input Dimension to slice.

start

Slice start bounds.

stop

Slice stop bounds.

step

Slice step.

Returns:

Dimension with upper/lower values set according slice inputs.