!39918 Master code clean.

Merge pull request !39918 from chenfei_mindspore/master-develop
This commit is contained in:
i-robot 2022-08-09 08:04:17 +00:00 committed by Gitee
commit e6b4b7328c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
58 changed files with 126 additions and 79 deletions

View File

@ -33,6 +33,7 @@
#include "kernel/common_utils.h"
#include "utils/ms_context.h"
#include "include/common/debug/anf_ir_dump.h"
#include "ir/func_graph_cloner.h"
namespace mindspore::graphkernel {
ExpanderPtr GetExpander(const AnfNodePtr &node, bool abstract) {

View File

@ -30,6 +30,7 @@
#include "backend/common/pass/getitem_tuple.h"
#include "common/graph_kernel/core/graph_kernel_callback.h"
#include "common/graph_kernel/core/graph_kernel_utils.h"
#include "ir/func_graph_cloner.h"
namespace mindspore::graphkernel {
// find outputs of nodes

View File

@ -32,6 +32,7 @@
#include "kernel/common_utils.h"
#include "common/graph_kernel/graph_kernel_helper.h"
#include "common/graph_kernel/core/graph_builder.h"
#include "ir/func_graph_cloner.h"
namespace mindspore::graphkernel {
namespace {

View File

@ -223,14 +223,14 @@ void DoAutoCast(const ValuePtr &func, const std::vector<Signature> &signature, c
TypeId arg_type_id = kTypeUnknown;
auto arg_value = input_types[i];
(void)GetTensorOrScalarTypeInfo(arg_value, &arg_type_id);
auto it_map = type_name_map.find(arg_type_id);
if (it_map == type_name_map.end()) {
auto it_map = type_name_map().find(arg_type_id);
if (it_map == type_name_map().cend()) {
continue;
}
if (is_write) {
if (arg_type_id != it->second) {
auto it_name_map = type_name_map.find(it->second);
if (it_name_map == type_name_map.end()) {
auto it_name_map = type_name_map().find(it->second);
if (it_name_map == type_name_map().cend()) {
continue;
}
RaiseExceptionForConvertRefDtype(func, it_map->second, it_name_map->second, i);

View File

@ -15,6 +15,7 @@
*/
#include "frontend/optimizer/ad/pynative_dfunctor.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
namespace ad {

View File

@ -28,6 +28,7 @@
#include "utils/ms_context.h"
#include "include/common/utils/utils.h"
#include "include/common/debug/anf_ir_dump.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
/* namespace to support opt */

View File

@ -24,6 +24,7 @@
#include "utils/hash_map.h"
#include "frontend/optimizer/optimizer.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
namespace opt {

View File

@ -230,7 +230,7 @@ FuncGraphPtr TransformGraphCondBranchNodes(
}
}
if (should_replace) {
auto new_node = graph->NewCNode();
auto new_node = graph->NewCNode({});
repl_node[node] = new_node;
nodes_changed.emplace_back(node->cast<CNodePtr>(), new_node);
}

View File

@ -195,7 +195,7 @@ class ConvertSwitchReplacement {
ConvertSwitchReplacement() = default;
virtual ~ConvertSwitchReplacement() = default;
bool operator()(const FuncGraphPtr &root, const OptimizerPtr &) {
bool operator()(const FuncGraphPtr &root, const OptimizerPtr &) const {
AnfNodePtr ret = root->get_return();
MS_EXCEPTION_IF_NULL(ret);
std::vector<AnfNodePtr> all_nodes = DeepScopedGraphSearch(ret);

View File

@ -462,7 +462,7 @@ class IncorporateEnvironGetSwitchLayer : public AnfVisitor {
~IncorporateEnvironGetSwitchLayer() override = default;
AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override {
static bool enable_closure = common::GetEnv("MS_DEV_ENABLE_CLOSURE") != "0";
static const bool enable_closure = common::GetEnv("MS_DEV_ENABLE_CLOSURE") != "0";
if (enable_closure) {
return nullptr;
}

View File

@ -29,7 +29,7 @@ namespace opt {
namespace irpass {
class SparseSoftmaxCrossEntropyWithLogitsSplit : public AnfVisitor {
public:
AnfNodePtr operator()(const OptimizerPtr &opt, const AnfNodePtr &node) override;
AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override;
void Visit(const AnfNodePtr &node) override;

View File

@ -177,7 +177,7 @@ class InlinerBase : public AnfVisitor {
}
AnfNodePtr InlineMove(const AnfNodePtr &node, const FuncGraphPtr &fg, const std::vector<AnfNodePtr> &args,
const std::vector<AnfNodePtr> &inputs) {
const std::vector<AnfNodePtr> &inputs) const {
auto mng = fg->manager();
MS_EXCEPTION_IF_NULL(mng);
ReplaceParams(mng, args, fg);

View File

@ -15,8 +15,10 @@
*/
#include "frontend/optimizer/irpass/vmap_eliminate.h"
#include <string>
#include <vector>
#include "ir/func_graph_cloner.h"
#include "frontend/optimizer/irpass/gradient_eliminate.h"
#include "pipeline/pynative/pynative_execute.h"
#include "frontend/operator/composite/vmap.h"

View File

@ -106,7 +106,7 @@ void AnalysisSchedule::Wait() {
StaticAnalysisException::Instance().CheckException();
}
void AnalysisSchedule::WaitForRun() {
void AnalysisSchedule::WaitForRun() const {
// Control the order to run.
AsyncAbstractPtr control_run_order = std::make_shared<AsyncAbstract>();
control_run_order->set_result(std::make_shared<AbstractScalar>(1));

View File

@ -56,13 +56,13 @@ class AnalysisSchedule {
void Stop();
void Wait();
void Add2Schedule(const AsyncInferTaskPtr &async_infer_task_ptr);
void WaitForRun();
void WaitForRun() const;
void Yield(AsyncInferTask *asyncTask);
void EnterWaiting() {
{
std::lock_guard<std::mutex> activeLock(activate_thread_lock_);
activate_threads_.erase(AnalysisSchedule::thread_id());
(void)activate_threads_.erase(AnalysisSchedule::thread_id());
MS_LOG(DEBUG) << "Infer return to main thread.";
}
activate_thread_cv_.notify_one();
@ -84,7 +84,7 @@ class AnalysisSchedule {
{
std::lock_guard<std::mutex> active_lock(activate_thread_lock_);
activate_threads_.erase(AnalysisSchedule::thread_id());
(void)activate_threads_.erase(AnalysisSchedule::thread_id());
MS_LOG(DEBUG) << " The active thread count: " << activate_threads_.size()
<< " The infer_thread_count: " << infer_thread_count_
<< " schedule list size: " << schedule_list_.size() << " thread: " << thread_id() + " "

View File

@ -449,7 +449,7 @@ class SideEffectFinder {
}
}
void CheckAndFixSwitchCall(const CNodePtr &caller, const FuncGraphVector &branches) {
void CheckAndFixSwitchCall(const CNodePtr &caller, const FuncGraphVector &branches) const {
const auto caller_input_size = caller->inputs().size();
for (auto &branch : branches) {
if (caller_input_size != branch->parameters().size() + 1) {

View File

@ -153,8 +153,8 @@ void CastOperation::GetDstType(const FrontendOpRunInfoPtr &op_run_info,
}
const std::string &CastOperation::TypeIdToMsTypeStr(const TypeId &type_id) const {
const auto &type_name = type_name_map.find(type_id);
if (type_name == type_name_map.end()) {
const auto &type_name = type_name_map().find(type_id);
if (type_name == type_name_map().cend()) {
MS_LOG(EXCEPTION) << "For implicit type conversion, not support convert to the type: " << TypeIdToType(type_id);
}
return type_name->second;

View File

@ -18,6 +18,7 @@
#include "pipeline/pynative/pynative_utils.h"
#include "include/common/utils/anfalgo.h"
#include "include/common/utils/parallel_context.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
namespace pynative {

View File

@ -23,6 +23,7 @@
#include "pipeline/jit/pass.h"
#include "runtime/pynative/op_executor.h"
#include "ir/cell.h"
#include "ir/func_graph_cloner.h"
namespace mindspore::pynative {
PyNativeExecutorPtr PyNativeExecutor::executor_ = nullptr;

View File

@ -93,7 +93,7 @@ template <typename T>
void Square(ArithmeticSelfCpuKernelFunc *content, const T *in, T *out, size_t size) {
auto task = [&in, &out](size_t start, size_t end) {
for (size_t i = start; i < end; i++) {
out[i] = in[i] * in[i];
out[i] = static_cast<T>(in[i] * in[i]);
}
};
ParallelLaunchAutoSearch(task, size, content, &content->parallel_search_info_);

View File

@ -262,8 +262,9 @@ void DeformableOffsetGradKernel(const OffsetIndex &offset_index, const OffsetStr
template <typename T>
void DeformableOffsetsGradCpuKernelMod::DeformableOffsetGradNHWCKernel(size_t num_kernels,
const DeformableOffsetGradDims &dims, T *input_x,
T *input_offset, T *input_grad, T *output_grad_x,
const DeformableOffsetGradDims &dims,
const T *input_x, const T *input_offset,
const T *input_grad, T *output_grad_x,
T *output_grad_offset) {
OffsetStride offset_stride;
offset_stride.kernel_w_stride = 1;
@ -315,8 +316,9 @@ void DeformableOffsetsGradCpuKernelMod::DeformableOffsetGradNHWCKernel(size_t nu
template <typename T>
void DeformableOffsetsGradCpuKernelMod::DeformableOffsetGradNCHWKernel(size_t num_kernels,
const DeformableOffsetGradDims &dims, T *input_x,
T *input_offset, T *input_grad, T *output_grad_x,
const DeformableOffsetGradDims &dims,
const T *input_x, const T *input_offset,
const T *input_grad, T *output_grad_x,
T *output_grad_offset) {
OffsetStride offset_stride;
offset_stride.offset_w_stride = 1;
@ -394,9 +396,9 @@ bool DeformableOffsetsGradCpuKernelMod::LaunchKernel(const std::vector<kernel::A
const std::vector<kernel::AddressPtr> &outputs) {
const size_t num_kernels =
dims_.x_n * dims_.offset_h * dims_.offset_w * dims_.kernel_h * dims_.kernel_w * dims_.deformable_group;
T *input_grad = GetDeviceAddress<T>(inputs, kGradXIndex);
T *input_x = GetDeviceAddress<T>(inputs, kXIndex);
T *input_offset = GetDeviceAddress<T>(inputs, kOffsetIndex);
const T *input_grad = GetDeviceAddress<T>(inputs, kGradXIndex);
const T *input_x = GetDeviceAddress<T>(inputs, kXIndex);
const T *input_offset = GetDeviceAddress<T>(inputs, kOffsetIndex);
T *output_grad_x = GetDeviceAddress<T>(outputs, kGradXIndex);
T *output_grad_offset = GetDeviceAddress<T>(outputs, kGradOffsetIndex);
@ -467,7 +469,7 @@ KernelAttrAndFuncList &DeformableOffsetsGradCpuKernelMod::GetFuncList() const {
void DeformableOffsetsGradCpuKernelMod::GetDataFormat() { data_format_ = deformable_kernel_operator_->get_format(); }
void DeformableOffsetsGradCpuKernelMod::CheckInOutNum(size_t inputs_num, size_t outputs_num) {
void DeformableOffsetsGradCpuKernelMod::CheckInOutNum(size_t inputs_num, size_t outputs_num) const {
if (inputs_num != kInputNum) {
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the number of inputs must be " << kInputNum << ", but got "
<< inputs_num;

View File

@ -74,7 +74,7 @@ class DeformableOffsetsGradCpuKernelMod : public NativeCpuKernelMod,
private:
void ResetResource() noexcept;
void CheckInOutNum(size_t inputs_num, size_t outputs_num);
void CheckInOutNum(size_t inputs_num, size_t outputs_num) const;
void GetDataFormat();
@ -85,11 +85,13 @@ class DeformableOffsetsGradCpuKernelMod : public NativeCpuKernelMod,
const std::vector<kernel::AddressPtr> &outputs);
template <typename T>
void DeformableOffsetGradNHWCKernel(size_t num_kernels, const DeformableOffsetGradDims &dims, T *input_x,
T *input_offset, T *input_grad, T *output_grad_x, T *output_grad_offset);
void DeformableOffsetGradNHWCKernel(size_t num_kernels, const DeformableOffsetGradDims &dims, const T *input_x,
const T *input_offset, const T *input_grad, T *output_grad_x,
T *output_grad_offset);
template <typename T>
void DeformableOffsetGradNCHWKernel(size_t num_kernels, const DeformableOffsetGradDims &dims, T *input_x,
T *input_offset, T *input_grad, T *output_grad_x, T *output_grad_offset);
void DeformableOffsetGradNCHWKernel(size_t num_kernels, const DeformableOffsetGradDims &dims, const T *input_x,
const T *input_offset, const T *input_grad, T *output_grad_x,
T *output_grad_offset);
OpsDeformableOffsetsGradPtr deformable_kernel_operator_;
std::string data_format_ = kOpFormat_NCHW;
DeformableOffsetGradDims dims_;

View File

@ -126,7 +126,7 @@ bool FractionalAvgPoolGradCpuKernelMod::FractionalAvgPoolGradLaunch(const std::v
}
}
};
CPUKernelUtils::ParallelFor(sharder_fractional_avg_pool_grad, out_batch);
CPUKernelUtils::ParallelFor(sharder_fractional_avg_pool_grad, LongToSize(out_batch));
// Depending on the type, cast double to type T.
for (size_t i = 0; i < output_nums; ++i) {
*(output + i) = static_cast<T>(in_backprop_tensor_temp[i]);

View File

@ -92,7 +92,7 @@ static std::vector<int64_t> GeneratePoolingSequencePseudoRandom(size_t input_len
double alpha = static_cast<double>(input_length) / output_length;
int k = SizeToInt(input_length / output_length);
double u_max1 = (k + 2) / alpha - 1;
if (common::IsDoubleEqual(alpha, LongToDouble(output_length - 1))) {
if (common::IsDoubleEqual(alpha, LongToDouble(SizeToLong(output_length - 1)))) {
MS_EXCEPTION(ValueError) << "For FractionalAvgPool, the input_length and output_length is wrong, please check "
"the parameter 'pooling ratio'.";
} else {

View File

@ -149,8 +149,7 @@ void FractionalMaxPoolGradCpuKernelMod::FractionalMaxPoolGradCompute(
for (int64_t h = row_start; h <= row_end; ++h) {
for (int64_t w = col_start; w <= col_end; ++w) {
const int64_t input_index =
(SizeToLong(b) * tensor_in_shape_[kInputShapeIndexH] + SizeToLong(h)) * tensor_in_shape_[kInputShapeIndexW] +
SizeToLong(w);
SizeToLong(b) * tensor_in_shape_[kInputShapeIndexH] + h * tensor_in_shape_[kInputShapeIndexW] + w;
// Walk through each channel (depth).
for (size_t d = 0; d < LongToSize(tensor_in_shape_[kInputShapeIndexC]); ++d) {
const T &input_ref = tensor_in_mat.coeffRef(SizeToLong(d), input_index);

View File

@ -43,14 +43,14 @@ bool Compute(const ComputeParams<T> *params, const size_t start, const size_t en
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);
auto index = indices[i * params->indices_unit_rank_ + j];
(void)local_indices.emplace_back(IntToSize(index));
if (index < 0) {
MS_LOG(ERROR) << "For '" << kKernelName
<< "', each element in 'indices' must be greater than or equal to 0, but got " << index;
return false;
}
offset += index * out_strides->at(j) * params->unit_size_;
offset += IntToSize(index) * out_strides->at(j) * params->unit_size_;
}
if (offset * sizeof(T) > params->x_mem_size_) {
MS_LOG(ERROR) << "For '" << kKernelName
@ -116,8 +116,8 @@ void ScatterUpdateCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
}
size_t out_stride = 1;
out_strides_.push_back(out_stride);
for (int i = indices_unit_rank_ - 2; i >= 0; i--) {
out_stride *= LongToSize(shape[i + 1]);
for (int64_t i = SizeToLong(indices_unit_rank_) - 2; i >= 0; i--) {
out_stride *= LongToSize(shape[LongToSize(i + 1)]);
out_strides_.push_back(out_stride);
}
reverse(out_strides_.begin(), out_strides_.end());

View File

@ -181,21 +181,21 @@ int SparseApplyAdamCpuKernelMod::Resize(const BaseOperatorPtr &base_operator,
<< grad_shape.size() << " and the dimension of 'var': " << var_shape.size();
return KRET_RESIZE_FAILED;
}
var_first_dim_size_ = var_shape[0];
var_first_dim_size_ = LongToSize(var_shape[0]);
for (size_t i = 1; i < var_shape.size(); ++i) {
if (var_shape[i] != grad_shape[i]) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the shape of 'var' and 'grad' must be equal in dimension i=" << i
<< ", but got 'var_shape[i]': " << var_shape[i] << " and 'grad_shape[i]': " << grad_shape[i];
return KRET_RESIZE_FAILED;
}
var_outer_dim_size_ *= var_shape[i];
var_outer_dim_size_ *= LongToSize(var_shape[i]);
}
if (indices_shape.size() != 1) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the dimension of 'indices' must be 1-D, but got "
<< indices_shape.size() << "-D.";
return KRET_RESIZE_FAILED;
}
indices_size_ = indices_shape[0];
indices_size_ = LongToSize(indices_shape[0]);
if (grad_shape[0] != SizeToLong(indices_size_)) {
MS_LOG(ERROR) << "For '" << kernel_name_
<< "', the first dimension value of 'grad' must be equal to "
@ -263,7 +263,7 @@ bool SparseApplyAdamCpuKernelMod::LaunchKernel(const std::vector<kernel::Address
auto *m = reinterpret_cast<float *>(inputs[1]->addr);
auto *v = reinterpret_cast<float *>(inputs[2]->addr);
auto beta1_power = reinterpret_cast<float *>(inputs[3]->addr)[0];
if (beta1_power == 1) {
if (std::fabs(beta1_power - 1.0f) <= std::numeric_limits<float>::epsilon()) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the 'beta1_power' can not be 1.";
return false;
}

View File

@ -65,7 +65,7 @@ void ComputeFtrl(MultiThreadComputeParams<T> *input_params, size_t start, size_t
auto accum_new = accum[j] + summed_grad * summed_grad;
float y;
linear[j] += summed_grad;
if (lr_power == -0.5) {
if (std::fabs(lr_power + 0.5) <= std::numeric_limits<float>::epsilon()) {
y = std::sqrt(accum_new);
linear[j] -= ((y - std::sqrt(accum[j])) / lr) * var[j];
} else {
@ -177,21 +177,21 @@ int FusedSparseFtrlCpuKernelMod::Resize(const BaseOperatorPtr &base_operator,
<< grad_shape.size() << " and the dimension of 'var': " << var_shape.size() << ".";
return KRET_RESIZE_FAILED;
}
var_first_dim_size_ = var_shape[0];
var_first_dim_size_ = LongToSize(var_shape[0]);
for (size_t i = 1; i < var_shape.size(); ++i) {
if (var_shape[i] != grad_shape[i]) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the shape of 'var' and 'grad' must be equal in dimension i=" << i
<< ", but got 'var_shape[i]': " << var_shape[i] << " and 'grad_shape[i]': " << grad_shape[i];
return KRET_RESIZE_FAILED;
}
var_outer_dim_size_ *= var_shape[i];
var_outer_dim_size_ *= LongToSize(var_shape[i]);
}
if (indices_shape.size() != 1) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the 'indices' must be a 1-D vector, but got "
<< indices_shape.size() << "-D.";
return KRET_RESIZE_FAILED;
}
indices_size_ = indices_shape[0];
indices_size_ = LongToSize(indices_shape[0]);
if (grad_shape[0] != SizeToLong(indices_size_)) {
MS_LOG(ERROR) << "For '" << kernel_name_
<< "', the first dimension value of 'grad' must be equal to "

View File

@ -157,21 +157,21 @@ int SparseApplyLazyAdamCpuKernelMod::Resize(const BaseOperatorPtr &base_operator
<< grad_shape.size() << " and the dimension of 'var': " << var_shape.size() << ".";
return KRET_RESIZE_FAILED;
}
var_first_dim_size_ = var_shape[0];
var_first_dim_size_ = LongToSize(var_shape[0]);
for (size_t i = 1; i < var_shape.size(); ++i) {
if (var_shape[i] != grad_shape[i]) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the shape of 'var' and 'grad' must be equal in dimension i=" << i
<< ", but got 'var_shape[i]': " << var_shape[i] << " and 'grad_shape[i]': " << grad_shape[i];
return KRET_RESIZE_FAILED;
}
var_outer_dim_size_ *= var_shape[i];
var_outer_dim_size_ *= LongToSize(var_shape[i]);
}
if (indices_shape.size() != 1) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', the 'indices' must be a 1-D vector, but got "
<< indices_shape.size() << "-D.";
return KRET_RESIZE_FAILED;
}
indices_size_ = indices_shape[0];
indices_size_ = LongToSize(indices_shape[0]);
if (grad_shape[0] != SizeToLong(indices_size_)) {
MS_LOG(ERROR) << "For '" << kernel_name_
<< "', the first dimension value of 'grad' must be equal to "
@ -240,7 +240,7 @@ bool SparseApplyLazyAdamCpuKernelMod::LaunchKernel(const std::vector<kernel::Add
auto *m = reinterpret_cast<float *>(inputs[1]->addr);
auto *v = reinterpret_cast<float *>(inputs[2]->addr);
auto beta1_power = reinterpret_cast<float *>(inputs[3]->addr)[0];
if (beta1_power == 1) {
if (std::fabs(beta1_power - 1.0f) <= std::numeric_limits<float>::epsilon()) {
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the 'beta1_power' can not be 1.";
}
auto beta2_power = reinterpret_cast<float *>(inputs[4]->addr)[0];

View File

@ -311,7 +311,7 @@ class SparseOptimizerCpuKernelMod : public NativeCpuKernelMod {
for (size_t i = 0; i < sorted_indices.size(); ++i) {
T index = sorted_indices[i].first;
T global_index = sorted_indices[i].second;
T global_value_offset = global_index * param.value_stride_;
auto global_value_offset = static_cast<size_t>(global_index) * param.value_stride_;
if (i == 0 || index != last_index) {
if (i != 0) {
unique_indices_size++;

View File

@ -174,12 +174,12 @@ AbstractBasePtr InferImplBinaryBase(const AnalysisEnginePtr &, const PrimitivePt
auto x_element_type = x_element->number_type();
auto y_element_type = y_element->number_type();
auto x_priority = type_priority_map.find(x_element_type);
if (x_priority == type_priority_map.end()) {
auto x_priority = type_priority_map().find(x_element_type);
if (x_priority == type_priority_map().cend()) {
MS_LOG(EXCEPTION) << "input_x type is " << x_element_type << ", it's not number type.";
}
auto y_priority = type_priority_map.find(y_element_type);
if (y_priority == type_priority_map.end()) {
auto y_priority = type_priority_map().find(y_element_type);
if (y_priority == type_priority_map().cend()) {
MS_LOG(EXCEPTION) << "input_y type is " << y_element_type << ", it's not number type.";
}

View File

@ -80,6 +80,22 @@ static mindspore::HashMap<TypeId, std::string> g_type_2_lable{{kTypeUnknown, "Un
{kObjectTypeUMonad, "UMonad"},
{kObjectTypeIOMonad, "IOMonad"}};
const mindspore::HashMap<TypeId, int> &type_priority_map() {
static const mindspore::HashMap<TypeId, int> type_priority_map = {
{kNumberTypeBool, 0}, {kNumberTypeUInt8, 1}, {kNumberTypeInt8, 2},
{kNumberTypeInt16, 3}, {kNumberTypeInt32, 4}, {kNumberTypeInt64, 5},
{kNumberTypeFloat16, 6}, {kNumberTypeFloat32, 7}, {kNumberTypeFloat64, 8}};
return type_priority_map;
}
const mindspore::HashMap<TypeId, std::string> &type_name_map() {
static const mindspore::HashMap<TypeId, std::string> type_name_map = {
{kNumberTypeBool, "bool_"}, {kNumberTypeInt8, "int8"}, {kNumberTypeUInt8, "uint8"},
{kNumberTypeInt16, "int16"}, {kNumberTypeInt32, "int32"}, {kNumberTypeInt64, "int64"},
{kNumberTypeFloat16, "float16"}, {kNumberTypeFloat32, "float32"}, {kNumberTypeFloat64, "float64"}};
return type_name_map;
}
TypeId IntBitsToTypeId(const int nbits) {
switch (nbits) {
case static_cast<int>(BitsNum::eBits8):

View File

@ -233,18 +233,15 @@ class MS_CORE_API Object : public Type {
const TypeId parent_type_;
};
//
// TypeId name map
//
inline const mindspore::HashMap<TypeId, std::string> type_name_map = {
{kNumberTypeBool, "bool_"}, {kNumberTypeInt8, "int8"}, {kNumberTypeUInt8, "uint8"},
{kNumberTypeInt16, "int16"}, {kNumberTypeInt32, "int32"}, {kNumberTypeInt64, "int64"},
{kNumberTypeFloat16, "float16"}, {kNumberTypeFloat32, "float32"}, {kNumberTypeFloat64, "float64"}};
/// \brief Gettype_name_map.
///
/// \return type_name_map
MS_CORE_API const mindspore::HashMap<TypeId, std::string> &type_name_map();
inline const mindspore::HashMap<TypeId, int> type_priority_map = {
{kNumberTypeBool, 0}, {kNumberTypeUInt8, 1}, {kNumberTypeInt8, 2},
{kNumberTypeInt16, 3}, {kNumberTypeInt32, 4}, {kNumberTypeInt64, 5},
{kNumberTypeFloat16, 6}, {kNumberTypeFloat32, 7}, {kNumberTypeFloat64, 8}};
/// \brief type_priority_map.
///
/// \return type_priority_map
MS_CORE_API const mindspore::HashMap<TypeId, int> &type_priority_map();
/// \brief Get TypePtrList description.
///

View File

@ -23,6 +23,7 @@
#include "utils/ordered_set.h"
#include "utils/convert_utils_base.h"
#include "abstract/abstract_function.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
/*

View File

@ -37,7 +37,6 @@
#include "utils/ordered_map.h"
#include "base/base_ref.h"
#include "base/effect_info.h"
#include "ir/func_graph_cloner.h"
#include "abstract/abstract_value.h"
#include "ir/func_graph_transform.h"
#include "ir/func_graph_base.h"
@ -137,7 +136,7 @@ class MS_CORE_API FuncGraph : public FuncGraphBase, public EffectInfoHolder {
// Create a cnode with given inputs, bound to this graph.
virtual CNodePtr NewCNode(std::vector<AnfNodePtr> &&inputs);
virtual CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs = std::vector<AnfNodePtr>());
virtual CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs);
CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &inputs);
// Create a cnode with given inputs, bound to this graph and push back to order list.

View File

@ -23,6 +23,7 @@
#include "abstract/abstract_value.h"
#include "abstract/abstract_function.h"
#include "mindspore/core/ops/core_ops.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
using mindspore::abstract::AbstractFunction;

View File

@ -49,6 +49,7 @@ Primitive::Primitive(const std::string &name, const mindspore::HashMap<std::stri
Primitive::Primitive(const Primitive &prim)
: Named(prim),
attrs_(prim.attrs_),
evaluate_added_attrs_(prim.evaluate_added_attrs_),
instance_name_(prim.instance_name_),
is_base_(prim.is_base_),
has_signature_(prim.has_signature_),
@ -63,6 +64,7 @@ Primitive &Primitive::operator=(const Primitive &other) {
}
Named::operator=(other);
attrs_ = other.attrs_;
evaluate_added_attrs_ = other.evaluate_added_attrs_;
instance_name_ = other.instance_name_;
is_base_ = other.is_base_;
has_signature_ = other.has_signature_;

View File

@ -29,6 +29,7 @@
#include "ir/param_info.h"
#include "ops/primitive_c.h"
#include "abstract/abstract_value.h"
#include "abstract/ops/primitive_infer_map.h"
#include "utils/hash_map.h"
#include "utils/log_adapter.h"
#include "utils/shape_utils.h"

View File

@ -25,6 +25,7 @@
#include "ops/primitive_c.h"
#include "abstract/abstract_value.h"
#include "utils/ms_context.h"
#include "abstract/ops/primitive_infer_map.h"
namespace mindspore {
namespace {

View File

@ -86,19 +86,19 @@ void DeformableOffsetsPadFunction(std::vector<int64_t> *output_hw, const std::ve
constexpr size_t left_index = 2;
constexpr size_t right_index = 3;
if (x_h != abstract::Shape::SHP_ANY) {
out_h = static_cast<int64_t>(
std::floor(1 + ((x_h * 1.0) + pads[top_index] + pads[bottom_index] - kernel_size[0] -
static_cast<double>((int64_t)LongToInt(kernel_size[0] - 1) * LongToInt(dilations[h_axis] - 1))) /
strides[h_axis]));
out_h =
static_cast<int64_t>(std::floor(1.0 + LongToDouble(x_h + pads[top_index] + pads[bottom_index] - kernel_size[0] -
(kernel_size[0] - 1) * (dilations[h_axis] - 1)) /
LongToDouble(strides[h_axis])));
if (is_min_shape && out_h < 1) {
out_h = 1L;
}
}
if (x_w != abstract::Shape::SHP_ANY) {
out_w = static_cast<int64_t>(
std::floor(1 + ((x_w * 1.0) + pads[left_index] + pads[right_index] - kernel_size[1] -
static_cast<double>((int64_t)LongToInt(kernel_size[1] - 1) * LongToInt(dilations[w_axis] - 1))) /
strides[w_axis]));
out_w =
static_cast<int64_t>(std::floor(1.0 + LongToDouble(x_w + pads[left_index] + pads[right_index] - kernel_size[1] -
(kernel_size[1] - 1) * (dilations[w_axis] - 1)) /
LongToDouble(strides[w_axis])));
if (is_min_shape && out_w < 1) {
out_w = 1L;
}

View File

@ -22,6 +22,7 @@
#include "utils/check_convert_utils.h"
#include "ops/primitive_c.h"
#include "mindapi/src/helper.h"
#include "abstract/ops/primitive_infer_map.h"
namespace mindspore {
namespace ops {

View File

@ -20,8 +20,10 @@
#include <string>
#include <vector>
#include "ops/primitive_c.h"
#include "ops/core_ops.h"
#include "utils/check_convert_utils.h"
#include "mindapi/src/helper.h"
#include "abstract/ops/primitive_infer_map.h"
namespace mindspore {
namespace ops {

View File

@ -16,6 +16,7 @@
#include "ops/primitive_c.h"
#include "utils/check_convert_utils.h"
#include "abstract/ops/primitive_infer_map.h"
namespace mindspore {
namespace ops {
void PrimitiveC::InitIOName(const std::vector<std::string> &inputs_name, const std::vector<std::string> &outputs_name) {

View File

@ -21,7 +21,6 @@
#include <map>
#include <memory>
#include "ir/primitive.h"
#include "abstract/ops/primitive_infer_map.h"
#include "ir/value.h"
namespace mindspore {
namespace ops {

View File

@ -57,7 +57,7 @@ bool CheckScalarOrTensor(ShapeVector input) {
return flag;
}
abstract::BaseShapePtr SelectInferShape(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) {
abstract::BaseShapePtr SelectInferShape(const PrimitivePtr &, const std::vector<AbstractBasePtr> &input_args) {
auto cond_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(input_args[kSelectCondIndex]->BuildShape())[kShape];
auto x_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(input_args[kSelectXIndex]->BuildShape())[kShape];
auto y_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(input_args[kSelectYIndex]->BuildShape())[kShape];

View File

@ -22,6 +22,7 @@
#include "src/extendrt/utils/kernel_graph_utils.h"
#include "ir/graph_utils.h"
#include "ir/func_graph_cloner.h"
#include "utils/ms_context.h"
#include "backend/common/session/anf_runtime_algorithm.h"
#include "include/common/utils/anfalgo.h"

View File

@ -20,6 +20,7 @@
#include "tools/optimizer/common/gllo_utils.h"
#include "mindspore/core/ir/anf.h"
#include "mindapi/ir/func_graph.h"
#include "ops/core_ops.h"
using mindspore::converter::ConverterParameters;
using mindspore::converter::kFmkTypeCaffe;

View File

@ -26,6 +26,7 @@
#include "tools/common/graph_util.h"
#include "tools/optimizer/common/gllo_utils.h"
#include "ops/fusion/partial_fusion.h"
#include "ops/core_ops.h"
#include "nnacl/op_base.h"
namespace mindspore::lite {

View File

@ -29,6 +29,7 @@
#include "src/common/utils.h"
#include "nnacl/op_base.h"
#include "ops/make_tuple.h"
#include "ops/core_ops.h"
#include "tools/converter/converter_context.h"
#include "tools/optimizer/common/gllo_utils.h"

View File

@ -26,6 +26,7 @@
#include "src/litert/infer_manager.h"
#include "mindspore/core/ops/switch.h"
#include "mindspore/core/ops/call.h"
#include "ops/core_ops.h"
#include "mindspore/core/ops/fusion/partial_fusion.h"
#include "nnacl/op_base.h"

View File

@ -25,6 +25,7 @@
#include "tools/common/node_util.h"
#include "tools/converter/parser/parser_utils.h"
#include "nnacl/op_base.h"
#include "ops/core_ops.h"
namespace mindspore {
namespace lite {

View File

@ -27,6 +27,7 @@
#include "tools/converter/parser/parser_utils.h"
#include "tools/optimizer/common/gllo_utils.h"
#include "nnacl/op_base.h"
#include "ops/core_ops.h"
namespace {
constexpr const int kSwitchTruePartialIndex = 2;
constexpr const int kSwitchFalsePartialIndex = 3;

View File

@ -20,6 +20,7 @@
#include <string>
#include "tools/converter/parser/parser_utils.h"
#include "nnacl/op_base.h"
#include "ops/core_ops.h"
namespace mindspore {
namespace lite {

View File

@ -18,6 +18,7 @@
#include <memory>
#include "ops/primitive_c.h"
#include "nnacl/op_base.h"
#include "ops/core_ops.h"
namespace mindspore::lite {
namespace {

View File

@ -19,6 +19,7 @@
#include <utility>
#include "tools/converter/preprocess/image_preprocess.h"
#include "ops/tuple_get_item.h"
#include "ops/core_ops.h"
#include "tools/optimizer/common/gllo_utils.h"
#include "include/errorcode.h"
#include "src/common/log_adapter.h"

View File

@ -27,6 +27,7 @@
#include "tools/common/node_util.h"
#include "tools/lite_exporter/fetch_content.h"
#include "tools/optimizer/common/format_utils.h"
#include "ops/core_ops.h"
namespace mindspore::lite::quant {
namespace {

View File

@ -22,6 +22,7 @@
#include "tools/optimizer/common/format_utils.h"
#include "utils/ms_utils_secure.h"
#include "nnacl/op_base.h"
#include "ops/core_ops.h"
namespace mindspore {
namespace opt {

View File

@ -25,6 +25,7 @@
#include "frontend/optimizer/opt.h"
#include "frontend/optimizer/irpass.h"
#include "pipeline/jit/action.h"
#include "ir/func_graph_cloner.h"
namespace mindspore {
namespace parse {