forked from mindspore-Ecosystem/mindspore
clean code warnings for svd, scatter_nd_update
This commit is contained in:
parent
deabda1856
commit
7b0aac92dd
|
@ -33,17 +33,17 @@ bool Compute(const ComputeParams<T> *params, const size_t start, const size_t en
|
|||
T *x = params->x_;
|
||||
int *indices = params->indices_;
|
||||
T *updates = params->updates_;
|
||||
std::vector<int> *out_strides = params->out_strides_;
|
||||
std::vector<size_t> *out_strides = params->out_strides_;
|
||||
MS_EXCEPTION_IF_NULL(x);
|
||||
MS_EXCEPTION_IF_NULL(indices);
|
||||
MS_EXCEPTION_IF_NULL(updates);
|
||||
MS_EXCEPTION_IF_NULL(out_strides);
|
||||
|
||||
for (int i = SizeToInt(start); i < SizeToInt(end); ++i) {
|
||||
int offset = 0;
|
||||
std::vector<int> local_indices;
|
||||
for (int j = 0; j < params->indices_unit_rank_; ++j) {
|
||||
auto index = indices[i * params->indices_unit_rank_ + j];
|
||||
for (size_t i = start; i < end; ++i) {
|
||||
size_t offset = 0;
|
||||
std::vector<size_t> local_indices;
|
||||
for (size_t j = 0; j < params->indices_unit_rank_; ++j) {
|
||||
auto index = IntToSize(indices[i * params->indices_unit_rank_ + j]);
|
||||
(void)local_indices.emplace_back(index);
|
||||
if (index < 0) {
|
||||
MS_LOG(ERROR) << "For '" << kKernelName
|
||||
|
@ -104,20 +104,20 @@ void ScatterUpdateCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
|||
<< indices_shape[i];
|
||||
}
|
||||
}
|
||||
indices_unit_rank_ = SizeToInt(indices_unit_rank);
|
||||
indices_unit_rank_ = indices_unit_rank;
|
||||
unit_size_ = 1;
|
||||
for (size_t i = indices_shape.size() - 1; i < updates_shape.size(); ++i) {
|
||||
unit_size_ *= SizeToInt(updates_shape[i]);
|
||||
unit_size_ *= updates_shape[i];
|
||||
}
|
||||
num_units_ = 1;
|
||||
num_units_ *= updates_shape[indices_shape.size() - 2];
|
||||
for (int i = SizeToInt(indices_shape.size()) - 3; i >= 0; i--) {
|
||||
num_units_ *= updates_shape[i];
|
||||
}
|
||||
int out_stride = 1;
|
||||
size_t out_stride = 1;
|
||||
out_strides_.push_back(out_stride);
|
||||
for (int i = indices_unit_rank_ - 2; i >= 0; i--) {
|
||||
out_stride *= shape[i + 1];
|
||||
out_stride *= LongToSize(shape[i + 1]);
|
||||
out_strides_.push_back(out_stride);
|
||||
}
|
||||
reverse(out_strides_.begin(), out_strides_.end());
|
||||
|
|
|
@ -30,9 +30,9 @@ struct ComputeParams {
|
|||
T *x_{nullptr};
|
||||
int *indices_{nullptr};
|
||||
T *updates_{nullptr};
|
||||
int unit_size_{0};
|
||||
int indices_unit_rank_{0};
|
||||
std::vector<int> *out_strides_{nullptr};
|
||||
size_t unit_size_{0};
|
||||
size_t indices_unit_rank_{0};
|
||||
std::vector<size_t> *out_strides_{nullptr};
|
||||
size_t x_mem_size_{0};
|
||||
};
|
||||
|
||||
|
@ -55,10 +55,10 @@ class ScatterUpdateCpuKernelMod : public DeprecatedNativeCpuKernelMod {
|
|||
void LaunchKernel(const std::vector<AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &outputs);
|
||||
|
||||
TypeId dtype_{kTypeUnknown};
|
||||
int unit_size_{0};
|
||||
size_t unit_size_{0};
|
||||
size_t num_units_{0};
|
||||
int indices_unit_rank_{0};
|
||||
std::vector<int> out_strides_;
|
||||
size_t indices_unit_rank_{0};
|
||||
std::vector<size_t> out_strides_;
|
||||
};
|
||||
|
||||
class ScatterNdUpdateCpuKernelMod : public ScatterUpdateCpuKernelMod {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "mindapi/ir/type.h"
|
||||
#include "utils/check_convert_utils.h"
|
||||
|
@ -39,7 +40,7 @@ abstract::BaseShapePtr SvdInferShape(const PrimitivePtr &prim, const std::vector
|
|||
auto n = a_shape[ndim - kIndexOne];
|
||||
auto p = std::min(m, n);
|
||||
|
||||
auto s_shape = ShapeVector(a_shape.begin(), a_shape.end() - kIndexOne);
|
||||
auto s_shape = ShapeVector(a_shape.begin(), a_shape.end() - SizeToLong(kIndexOne));
|
||||
s_shape[s_shape.size() - kIndexOne] = p;
|
||||
auto u_shape = ShapeVector(a_shape.begin(), a_shape.end());
|
||||
auto v_shape = ShapeVector(a_shape.begin(), a_shape.end());
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#ifndef MINDSPORE_CORE_OPS_SVD_H_
|
||||
#define MINDSPORE_CORE_OPS_SVD_H_
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "ops/base_operator.h"
|
||||
|
|
Loading…
Reference in New Issue