Browse Source

!6263 fix bugs which lead to segment fault

Merge pull request !6263 from Simson/bugfix
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
b8979f047b
3 changed files with 21 additions and 3 deletions
  1. +8
    -3
      mindspore/ccsrc/pipeline/jit/pipeline.cc
  2. +12
    -0
      mindspore/ccsrc/pipeline/pynative/pynative_execute.cc
  3. +1
    -0
      mindspore/common/parameter.py

+ 8
- 3
mindspore/ccsrc/pipeline/jit/pipeline.cc View File

@@ -710,9 +710,14 @@ void ProcessVmArgInner(const py::tuple &args, const ResourcePtr &res, VectorRef
if (!succ) {
MS_LOG(EXCEPTION) << "The " << i << "th arg convert failed.";
}
if (MsContext::GetInstance()->get_param<int>(MS_CTX_EXECUTION_MODE) == 0 && !converted->isa<tensor::Tensor>()) {
MS_EXCEPTION(TypeError) << "For 'graph mode', the " << i << "th arg: " << converted->ToString()
<< " is not tensor.";
if (MsContext::GetInstance()->get_param<int>(MS_CTX_EXECUTION_MODE) == 0) {
if (!converted->isa<tensor::Tensor>()) {
MS_EXCEPTION(TypeError) << "For 'graph mode', the " << i << "th arg: " << converted->ToString()
<< " is not tensor.";
}
if (converted->cast<TensorPtr>()->is_parameter()) {
MS_EXCEPTION(TypeError) << "The inputs could not be Parameter.";
}
}
arg_list->push_back(converted);
}


+ 12
- 0
mindspore/ccsrc/pipeline/pynative/pynative_execute.cc View File

@@ -1064,6 +1064,14 @@ void PynativeExecutor::NewGraphInner(const py::object &cell, const py::args &arg

auto g = std::make_shared<FuncGraph>();
if (graph_context_.empty()) {
for (auto arg : args) {
if (py::isinstance<tensor::Tensor>(arg)) {
auto tensor = arg.cast<tensor::TensorPtr>();
if (tensor && tensor->is_parameter()) {
MS_EXCEPTION(TypeError) << "The inputs could not be Parameter.";
}
}
}
// a df builder is built for every top function graph
df_builder_ = std::make_shared<FuncGraph>();
df_builder_map_[cell_id] = df_builder_;
@@ -1279,6 +1287,10 @@ void PynativeExecutor::EndGraphByOutId(const std::string &out_id, const py::obje
if (need_replace_param) {
auto params = newfg->parameters();
auto manager = Manage({newfg}, false);
if (args.size() > params.size()) {
MS_EXCEPTION(ValueError) << "The number of arguments " << args.size()
<< " is more than the number of parameters required, which is " << params.size();
}
for (size_t i = 0; i < args.size(); i++) {
ValuePtr value = PyAttrValue(args[i]);
auto v_node = NewValueNode(value);


+ 1
- 0
mindspore/common/parameter.py View File

@@ -47,6 +47,7 @@ class Parameter(MetaTensor):

Note:
Each parameter of Cell is represented by Parameter class.
A Parameter has to belong to a Cell.

Args:
default_input (Union[Tensor, Initializer, Number]): Parameter data, to be set initialized.


Loading…
Cancel
Save