forked from huawei/mindspore2022
code check cleanup
This commit is contained in:
parent
9c3e4a408b
commit
615c977caa
|
|
@ -959,7 +959,6 @@ void KPynativeCellImpl::SetSensAndWeights(const AnfNodePtrList &weights, bool ha
|
|||
}
|
||||
// Add sens parameter
|
||||
if (has_sens_arg) {
|
||||
// sens parameter;
|
||||
auto sens_param = tape_->add_parameter();
|
||||
sens_param->debug_info()->set_name("sens");
|
||||
sens_param->set_abstract(last_node_adjoint_iter->second->out()->ToAbstract()->Broaden());
|
||||
|
|
|
|||
|
|
@ -1338,7 +1338,7 @@ void ClearResAtexit() {
|
|||
trace::ClearTraceStack();
|
||||
}
|
||||
|
||||
py::bytes PyEncrypt(char *plain_data, const size_t plain_len, char *key, const size_t key_len, std::string enc_mode) {
|
||||
py::bytes PyEncrypt(char *plain_data, size_t plain_len, char *key, size_t key_len, const std::string &enc_mode) {
|
||||
size_t encrypt_len;
|
||||
auto encrypt_data = mindspore::Encrypt(&encrypt_len, reinterpret_cast<Byte *>(plain_data), plain_len,
|
||||
reinterpret_cast<Byte *>(key), key_len, enc_mode);
|
||||
|
|
@ -1349,7 +1349,7 @@ py::bytes PyEncrypt(char *plain_data, const size_t plain_len, char *key, const s
|
|||
return py_encrypt_data;
|
||||
}
|
||||
|
||||
py::bytes PyDecrypt(std::string encrypt_data_path, char *key, const size_t key_len, std::string dec_mode) {
|
||||
py::bytes PyDecrypt(const std::string &encrypt_data_path, char *key, size_t key_len, const std::string &dec_mode) {
|
||||
size_t decrypt_len;
|
||||
auto decrypt_data =
|
||||
mindspore::Decrypt(&decrypt_len, encrypt_data_path, reinterpret_cast<Byte *>(key), key_len, dec_mode);
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ bool InitExecDatasetVm(const std::string &queue_name, int64_t size, int64_t batc
|
|||
|
||||
void ProcessVmArgInner(const py::tuple &args, const ResourcePtr &res, VectorRef *const arg_list);
|
||||
|
||||
py::bytes PyEncrypt(char *plain_data, const size_t plain_len, char *key, const size_t key_len, std::string enc_mode);
|
||||
py::bytes PyDecrypt(std::string encrypt_data_path, char *key, const size_t key_len, std::string dec_mode);
|
||||
py::bytes PyEncrypt(char *plain_data, size_t plain_len, char *key, size_t key_len, const std::string &enc_mode);
|
||||
py::bytes PyDecrypt(const std::string &encrypt_data_path, char *key, size_t key_len, const std::string &dec_mode);
|
||||
bool PyIsCipherFile(const std::string &file_path);
|
||||
} // namespace pipeline
|
||||
} // namespace mindspore
|
||||
|
|
|
|||
|
|
@ -222,7 +222,6 @@ EvalResultPtr AnalysisEngine::Eval(const AnfNodeConfigPtr &conf) {
|
|||
auto abstract = EvalValueNode(value_node, conf);
|
||||
eval_result = std::make_shared<EvalResult>(abstract, std::make_shared<AttrValueMap>());
|
||||
} else if (node->isa<CNode>()) {
|
||||
// CheckNoStackInSameFuncGraph(conf);
|
||||
auto cnode = node->cast<CNodePtr>();
|
||||
trace::TraceEvalCNodeEnter(conf);
|
||||
eval_result = EvalCNode(cnode, conf);
|
||||
|
|
|
|||
|
|
@ -801,7 +801,7 @@ AbstractBasePtr InferImplReshape(const AnalysisEnginePtr &, const PrimitivePtr &
|
|||
if (it_second != shape.end()) {
|
||||
MS_LOG(EXCEPTION) << "At most one component of input shape can be -1";
|
||||
}
|
||||
auto index = std::distance(shape.begin(), it_first);
|
||||
auto index = LongToSize(std::distance(shape.begin(), it_first));
|
||||
int64_t infer_value = x_num;
|
||||
int64_t infer_min_value = x_min_num;
|
||||
int64_t infer_max_value = x_max_num;
|
||||
|
|
@ -1164,7 +1164,9 @@ AbstractBasePtr InferImplDynamicStitch(const AnalysisEnginePtr &, const Primitiv
|
|||
const AbstractBasePtrList &args_spec_list) {
|
||||
MS_EXCEPTION_IF_NULL(primitive);
|
||||
auto prim_name = primitive->name();
|
||||
(void)CheckAndConvertUtils::CheckInteger("input number", args_spec_list.size(), kEqual, 2, prim_name);
|
||||
constexpr int64_t args_size = 2;
|
||||
(void)CheckAndConvertUtils::CheckInteger("input number", SizeToLong(args_spec_list.size()), kEqual, args_size,
|
||||
prim_name);
|
||||
for (const auto &item : args_spec_list) {
|
||||
MS_EXCEPTION_IF_NULL(item);
|
||||
}
|
||||
|
|
@ -1188,16 +1190,16 @@ AbstractBasePtr InferImplDynamicStitch(const AnalysisEnginePtr &, const Primitiv
|
|||
MS_LOG(EXCEPTION) << "The number of input[0] must be the same as input[0]!";
|
||||
}
|
||||
|
||||
int indices_total_size = 0;
|
||||
int64_t indices_total_size = 0;
|
||||
std::map<std::string, TypePtr> types;
|
||||
types.emplace("data0", data0->BuildType());
|
||||
(void)types.emplace("data0", data0->BuildType());
|
||||
for (size_t i = 1; i < data.size(); ++i) {
|
||||
auto indicesi_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(indices[i]->BuildShape())[kShape];
|
||||
auto datai_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(data[i]->BuildShape())[kShape];
|
||||
if (indicesi_shape.size() > datai_shape.size()) {
|
||||
MS_LOG(EXCEPTION) << "The rank of indices[i] must be <= rank of data[i]!";
|
||||
}
|
||||
indices_total_size += indicesi_shape.size();
|
||||
indices_total_size += SizeToLong(indicesi_shape.size());
|
||||
}
|
||||
std::set<TypePtr> valid_types = ops::common_valid_types;
|
||||
auto infer_type = CheckAndConvertUtils::CheckTensorTypeSame(types, valid_types, prim_name);
|
||||
|
|
@ -1206,7 +1208,7 @@ AbstractBasePtr InferImplDynamicStitch(const AnalysisEnginePtr &, const Primitiv
|
|||
for (size_t i = indices0_shape.size(); i < data0_shape.size(); ++i) {
|
||||
out_shape.push_back(data0_shape[i]);
|
||||
}
|
||||
const size_t EXPAND_MAX = 10;
|
||||
const int64_t EXPAND_MAX = 10;
|
||||
ShapeVector min_shape = out_shape;
|
||||
ShapeVector max_shape = out_shape;
|
||||
min_shape[0] = 1;
|
||||
|
|
|
|||
|
|
@ -411,9 +411,11 @@ std::string GetVirtualNodeTargetFromInputs(const AnfNodePtr &node) {
|
|||
const size_t update_state_valid_input_index = 2;
|
||||
const size_t make_tuple_valid_input_index = 1;
|
||||
if (IsPrimitiveCNode(node, prim::kPrimUpdateState) && inputs.size() > update_state_valid_input_index) {
|
||||
std::copy(inputs.begin() + update_state_valid_input_index, inputs.end(), std::back_inserter(real_inputs));
|
||||
(void)std::copy(inputs.begin() + SizeToLong(update_state_valid_input_index), inputs.end(),
|
||||
std::back_inserter(real_inputs));
|
||||
} else if (IsPrimitiveCNode(node, prim::kPrimMakeTuple) && inputs.size() > make_tuple_valid_input_index) {
|
||||
std::copy(inputs.begin() + make_tuple_valid_input_index, inputs.end(), std::back_inserter(real_inputs));
|
||||
(void)std::copy(inputs.begin() + SizeToLong(make_tuple_valid_input_index), inputs.end(),
|
||||
std::back_inserter(real_inputs));
|
||||
}
|
||||
std::string first_input_target = kTargetUnDefined;
|
||||
bool has_diff_target =
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ AbstractBasePtr InferImplAssign(const abstract::AnalysisEnginePtr &, const Primi
|
|||
const AbstractBasePtrList &args_spec_list) {
|
||||
MS_EXCEPTION_IF_NULL(primitive);
|
||||
auto prim_name = primitive->name();
|
||||
(void)CheckAndConvertUtils::CheckInteger("Assign infer", (CheckAndConvertUtils::GetRemoveMonadAbsNum(args_spec_list)),
|
||||
kEqual, 2, prim_name);
|
||||
(void)CheckAndConvertUtils::CheckInteger(
|
||||
"Assign infer", SizeToLong(CheckAndConvertUtils::GetRemoveMonadAbsNum(args_spec_list)), kEqual, 2, prim_name);
|
||||
auto check_types = common_valid_types;
|
||||
check_types.emplace(kBool);
|
||||
auto variable_type = args_spec_list[0]->BuildType();
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ ShapeMap CheckAndConvertUtils::ConvertShapePtrToShapeMap(const BaseShapePtr &sha
|
|||
abstract::ShapePtr CheckAndConvertUtils::GetTensorInputShape(const std::string &prim_name,
|
||||
const std::vector<AbstractBasePtr> &input_args,
|
||||
int64_t index) {
|
||||
auto abstract = CheckAndConvertUtils::CheckArgs<abstract::AbstractTensor>(prim_name, input_args, index);
|
||||
auto abstract = CheckAndConvertUtils::CheckArgs<abstract::AbstractTensor>(prim_name, input_args, LongToSize(index));
|
||||
MS_EXCEPTION_IF_NULL(abstract);
|
||||
auto base_shape = abstract->BuildShape();
|
||||
MS_EXCEPTION_IF_NULL(base_shape);
|
||||
|
|
@ -517,7 +517,7 @@ TypePtr CheckAndConvertUtils::_CheckTypeSame(const std::map<std::string, TypePtr
|
|||
MS_EXCEPTION_IF_NULL(type);
|
||||
if (!allow_mix) {
|
||||
// input must be all tensor or all other type
|
||||
if (tensor_flag ^ type->isa<TensorType>()) {
|
||||
if ((tensor_flag && !type->isa<TensorType>()) || (!tensor_flag && type->isa<TensorType>())) {
|
||||
buffer << "For " << prim_name << "'s "
|
||||
<< "type is not same";
|
||||
for (const auto &error_elem : args) {
|
||||
|
|
@ -532,9 +532,9 @@ TypePtr CheckAndConvertUtils::_CheckTypeSame(const std::map<std::string, TypePtr
|
|||
auto element = tensor_type->element();
|
||||
MS_EXCEPTION_IF_NULL(element);
|
||||
return_type = element->DeepCopy();
|
||||
types_id.emplace(element->type_id());
|
||||
(void)types_id.emplace(element->type_id());
|
||||
} else {
|
||||
types_id.emplace(type->type_id());
|
||||
(void)types_id.emplace(type->type_id());
|
||||
return_type = type->DeepCopy();
|
||||
}
|
||||
if (types_id.size() > 1) {
|
||||
|
|
@ -587,13 +587,13 @@ void CheckAndConvertUtils::CheckSummaryParam(const AbstractBasePtr &name, const
|
|||
MS_EXCEPTION_IF_NULL(name);
|
||||
MS_EXCEPTION_IF_NULL(value);
|
||||
CheckMode(class_name);
|
||||
CheckTypeValid("name", name->BuildType(), {kString}, class_name);
|
||||
(void)CheckTypeValid("name", name->BuildType(), {kString}, class_name);
|
||||
auto s = GetValue<std::string>(name->BuildValue());
|
||||
if (s.empty()) {
|
||||
MS_EXCEPTION(ValueError) << "For 'name' the value should by valid string in " << class_name
|
||||
<< ", but got an empty string.";
|
||||
}
|
||||
CheckTypeValid("value", value->BuildType(), {kTensorType}, class_name);
|
||||
(void)CheckTypeValid("value", value->BuildType(), {kTensorType}, class_name);
|
||||
}
|
||||
|
||||
void CheckAndConvertUtils::CheckMode(const std::string &class_name) {
|
||||
|
|
@ -660,15 +660,15 @@ int64_t CheckAndConvertUtils::GetAndCheckFormat(const ValuePtr &value) {
|
|||
}
|
||||
return data_format;
|
||||
}
|
||||
int64_t CheckAndConvertUtils::GetRemoveMonadAbsNum(const AbstractBasePtrList &abs_list) {
|
||||
int64_t remove_monad_count = abs_list.size();
|
||||
size_t CheckAndConvertUtils::GetRemoveMonadAbsNum(const AbstractBasePtrList &abs_list) {
|
||||
size_t remove_monad_count = abs_list.size();
|
||||
for (const auto &item : abs_list) {
|
||||
if (item->isa<abstract::AbstractMonad>()) {
|
||||
--remove_monad_count;
|
||||
}
|
||||
}
|
||||
|
||||
for (int64_t i = 0; i < remove_monad_count; ++i) {
|
||||
for (size_t i = 0; i < remove_monad_count; ++i) {
|
||||
if (abs_list[i]->isa<abstract::AbstractMonad>()) {
|
||||
MS_EXCEPTION(UnknownError) << "The monad inputs of the node must at last of the node inputs.";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ class CheckAndConvertUtils {
|
|||
const std::string &arg_name);
|
||||
static void CheckMinMaxShape(const ShapeVector &shape, ShapeVector *min_shape, ShapeVector *max_shape);
|
||||
static int64_t GetAndCheckFormat(const ValuePtr &value);
|
||||
static int64_t GetRemoveMonadAbsNum(const AbstractBasePtrList &abs_list);
|
||||
static size_t GetRemoveMonadAbsNum(const AbstractBasePtrList &abs_list);
|
||||
|
||||
private:
|
||||
static bool IsEqualVector(const std::vector<int64_t> &vec_1, const std::vector<int64_t> &vec_2);
|
||||
|
|
|
|||
Loading…
Reference in New Issue