[Core/Ref] Resolve coverity issues (#24874)
### Details: - Fixed coverity issues in src/core/reference ### Tickets: - CVS-143152
This commit is contained in:
parent
236e1062b2
commit
7f1ddd55ac
|
|
@ -18,9 +18,9 @@ T atanh(const T in) {
|
|||
return std::atanh(in);
|
||||
}
|
||||
|
||||
template <class T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
|
||||
// Integral types don't support NAN and INFINITY, use integral limits instead for special values.
|
||||
template <class T, typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value>::type* = nullptr>
|
||||
T atanh(const T in) {
|
||||
// Integral type not support NAN and INFINITY, use integral limits instead for special values.
|
||||
if (in > 0) {
|
||||
return std::numeric_limits<T>::max();
|
||||
} else if (in < 0) {
|
||||
|
|
@ -29,6 +29,11 @@ T atanh(const T in) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr>
|
||||
T atanh(const T in) {
|
||||
return in > 0 ? std::numeric_limits<T>::max() : 0;
|
||||
}
|
||||
} // namespace func
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ void matmul(const T* arg0,
|
|||
broadcast_axes,
|
||||
sizeof(T));
|
||||
|
||||
arg0_shape_tmp = arg0_br_target_shape;
|
||||
arg0_shape_tmp = std::move(arg0_br_target_shape);
|
||||
arg0_rank = arg0_shape_tmp.size();
|
||||
arg0_new_data.swap(tmp);
|
||||
arg0_data = arg0_new_data.data();
|
||||
|
|
@ -175,7 +175,7 @@ void matmul(const T* arg0,
|
|||
arg1_br_target_shape,
|
||||
broadcast_axes,
|
||||
sizeof(T));
|
||||
arg1_shape_tmp = arg1_br_target_shape;
|
||||
arg1_shape_tmp = std::move(arg1_br_target_shape);
|
||||
arg1_rank = arg1_shape_tmp.size();
|
||||
arg1_new_data.swap(tmp);
|
||||
arg1_data = arg1_new_data.data();
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ std::unordered_map<std::string, std::vector<size_t>> compute_label_dim_map(const
|
|||
for (size_t ind = 0; ind < num_broadcasted_dims; ++ind) {
|
||||
label_dims.push_back(static_cast<size_t>(current_dim + ind));
|
||||
}
|
||||
resulted_map[label] = label_dims;
|
||||
resulted_map[label] = std::move(label_dims);
|
||||
current_dim += num_broadcasted_dims;
|
||||
} else if (resulted_map.find(label) != resulted_map.end()) {
|
||||
resulted_map[label].push_back(static_cast<size_t>(current_dim));
|
||||
|
|
@ -132,7 +132,7 @@ std::unordered_map<std::string, std::vector<size_t>> compute_label_dim_map(const
|
|||
} else {
|
||||
std::vector<size_t> label_dims;
|
||||
label_dims.push_back(static_cast<size_t>(current_dim));
|
||||
resulted_map[label] = label_dims;
|
||||
resulted_map[label] = std::move(label_dims);
|
||||
++current_dim;
|
||||
}
|
||||
}
|
||||
|
|
@ -350,8 +350,8 @@ void reduce_input(ov::TensorVector& inputs,
|
|||
reference::reduce_sum(input_ptr.data<T>(), output_ptr.data<T>(), input_shape, reduced_axes);
|
||||
|
||||
// update a vector of inputs and input subscripts
|
||||
inputs[input_ind] = output_ptr;
|
||||
input_subscripts[input_ind] = new_input_subscript;
|
||||
inputs[input_ind] = std::move(output_ptr);
|
||||
input_subscripts[input_ind] = std::move(new_input_subscript);
|
||||
}
|
||||
|
||||
/// \brief Transpose input to layout specified through the required subscript
|
||||
|
|
@ -408,7 +408,7 @@ void transpose_input(ov::TensorVector& inputs,
|
|||
output_shape);
|
||||
|
||||
// update a vector of inputs and input subscripts
|
||||
inputs[input_ind] = output_ptr;
|
||||
inputs[input_ind] = std::move(output_ptr);
|
||||
input_subscripts[input_ind] = required_subscript;
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ void broadcast_input(ov::TensorVector& inputs,
|
|||
broadcast_axes,
|
||||
input.get_element_type().size());
|
||||
|
||||
input = output;
|
||||
input = std::move(output);
|
||||
}
|
||||
|
||||
/// \brief Build identity tensor that will be used to zero non-diagonal tensor
|
||||
|
|
@ -528,7 +528,7 @@ ov::Tensor build_multi_identity(const ov::Tensor& input,
|
|||
multi_identity.get_shape(),
|
||||
identity.get_shape(),
|
||||
ov::op::AutoBroadcastType::NUMPY);
|
||||
multi_identity = mul_output;
|
||||
multi_identity = std::move(mul_output);
|
||||
}
|
||||
return multi_identity;
|
||||
}
|
||||
|
|
@ -545,7 +545,7 @@ void extract_diagonal(ov::TensorVector& inputs, std::vector<std::string>& input_
|
|||
|
||||
const auto& input_ptr = inputs[input_ind];
|
||||
const auto& input_subscript = input_subscripts[input_ind];
|
||||
const auto input_shape = input_ptr.get_shape();
|
||||
const auto& input_shape = input_ptr.get_shape();
|
||||
|
||||
std::string resultant_subscript = "";
|
||||
constexpr char ellipsis[] = "...";
|
||||
|
|
@ -591,8 +591,8 @@ void extract_diagonal(ov::TensorVector& inputs, std::vector<std::string>& input_
|
|||
|
||||
auto result = ov::Tensor(input_ptr.get_element_type(), result_shape);
|
||||
reference::reduce_sum(mul_output.data<T>(), result.data<T>(), mul_output.get_shape(), reduced_axes);
|
||||
inputs[input_ind] = result;
|
||||
input_subscripts[input_ind] = resultant_subscript;
|
||||
inputs[input_ind] = std::move(result);
|
||||
input_subscripts[input_ind] = std::move(resultant_subscript);
|
||||
}
|
||||
|
||||
/// \brief Reshape input to the new shape specified by sub-shapes of the
|
||||
|
|
|
|||
|
|
@ -306,7 +306,8 @@ InfoForFFTCalculation get_info_for_calculation(const Shape& input_data_shape,
|
|||
const int64_t complex_data_rank = static_cast<int64_t>(input_data_shape.size() - 1);
|
||||
|
||||
const auto reversed_output_shape = fft_common::reverse_shape_of_emulated_complex_tensor(output_shape);
|
||||
auto fft_axes = get_axes(axes_data, axes_data_shape, complex_data_rank);
|
||||
auto& fft_axes = result.fft_axes;
|
||||
fft_axes = get_axes(axes_data, axes_data_shape, complex_data_rank);
|
||||
fft_axes = fft_common::reverse_fft_axes(fft_axes, complex_data_rank);
|
||||
|
||||
const int64_t fft_rank = fft_axes.size();
|
||||
|
|
@ -320,30 +321,22 @@ InfoForFFTCalculation get_info_for_calculation(const Shape& input_data_shape,
|
|||
const auto outer_strides = fft_common::compute_strides(outer_lengths);
|
||||
const int64_t outer_size = outer_strides[outer_rank];
|
||||
|
||||
const int64_t buffer_size = compute_buffer_size(fft_lengths);
|
||||
|
||||
const auto output_strides = fft_common::compute_strides(reversed_output_shape);
|
||||
const auto output_fft_strides = get_lengths(output_strides, fft_axes);
|
||||
const auto output_outer_strides = get_lengths(output_strides, outer_axes);
|
||||
const auto reversed_input_shape = fft_common::reverse_shape_of_emulated_complex_tensor(input_data_shape);
|
||||
const auto input_fft_lengths = get_lengths(reversed_input_shape, fft_axes);
|
||||
const auto input_strides = fft_common::compute_strides(reversed_input_shape);
|
||||
const auto input_fft_strides = get_lengths(input_strides, fft_axes);
|
||||
const auto input_outer_strides = get_lengths(input_strides, outer_axes);
|
||||
|
||||
result.fft_axes = fft_axes;
|
||||
result.fft_lengths = fft_lengths;
|
||||
result.fft_strides = fft_strides;
|
||||
result.outer_strides = outer_strides;
|
||||
result.output_fft_strides = output_fft_strides;
|
||||
result.output_outer_strides = output_outer_strides;
|
||||
result.input_fft_lengths = input_fft_lengths;
|
||||
result.input_fft_strides = input_fft_strides;
|
||||
result.input_outer_strides = input_outer_strides;
|
||||
result.output_fft_strides = get_lengths(output_strides, fft_axes);
|
||||
result.output_outer_strides = get_lengths(output_strides, outer_axes);
|
||||
result.input_fft_lengths = get_lengths(reversed_input_shape, fft_axes);
|
||||
result.input_fft_strides = get_lengths(input_strides, fft_axes);
|
||||
result.input_outer_strides = get_lengths(input_strides, outer_axes);
|
||||
result.fft_rank = fft_rank;
|
||||
result.fft_size = fft_size;
|
||||
result.outer_size = outer_size;
|
||||
result.buffer_size = buffer_size;
|
||||
result.buffer_size = compute_buffer_size(fft_lengths);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,10 +93,10 @@ InterpolateEvalHelper::InfoForGenericLinearONNXMode InterpolateEvalHelper::get_i
|
|||
result.batch_size = batch_size;
|
||||
result.num_channels = num_channels;
|
||||
result.spatial_rank = static_cast<int64_t>(spatial_rank);
|
||||
result.input_index_multipliers = input_index_multipliers;
|
||||
result.output_index_multipliers = output_index_multipliers;
|
||||
result.input_spatial_shape = input_spatial_shape;
|
||||
result.output_spatial_shape = output_spatial_shape;
|
||||
result.input_index_multipliers = std::move(input_index_multipliers);
|
||||
result.output_index_multipliers = std::move(output_index_multipliers);
|
||||
result.input_spatial_shape = std::move(input_spatial_shape);
|
||||
result.output_spatial_shape = std::move(output_spatial_shape);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -134,10 +134,10 @@ InterpolateEvalHelper::InfoForLinearMode InterpolateEvalHelper::get_info_for_lin
|
|||
InfoForLinearMode result;
|
||||
|
||||
result.antialias = antialias;
|
||||
result.a = a;
|
||||
result.r = r;
|
||||
result.a = std::move(a);
|
||||
result.r = std::move(r);
|
||||
result.prod_a = prod_a;
|
||||
result.shape_for_indices = shape_for_indices;
|
||||
result.shape_for_indices = std::move(shape_for_indices);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -163,8 +163,8 @@ InterpolateEvalHelper::ICoords InterpolateEvalHelper::get_icoords(const Coordina
|
|||
icoords_r[axis] = static_cast<int64_t>(std::round(in_coord));
|
||||
}
|
||||
|
||||
result.icoords = icoords;
|
||||
result.icoords_r = icoords_r;
|
||||
result.icoords = std::move(icoords);
|
||||
result.icoords_r = std::move(icoords_r);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ InterpolateEvalHelper::LinearModeInnerIterationResult InterpolateEvalHelper::inn
|
|||
Coordinate inner_coord{unsigned_inner_coords_vector};
|
||||
|
||||
result.w = w;
|
||||
result.inner_coord = inner_coord;
|
||||
result.inner_coord = std::move(inner_coord);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ void loop(const std::shared_ptr<Model>& func,
|
|||
ov::Tensor in_tensor(func->get_parameters().at(cur_iter_idx)->get_element_type(),
|
||||
func->get_parameters().at(cur_iter_idx)->get_shape());
|
||||
std::memset(in_tensor.data(), 0, in_tensor.get_byte_size());
|
||||
inputs_to_body.at(cur_iter_idx) = in_tensor;
|
||||
inputs_to_body.at(cur_iter_idx) = std::move(in_tensor);
|
||||
}
|
||||
|
||||
// Port map processing: inputs and back edges
|
||||
|
|
|
|||
Loading…
Reference in New Issue