updata doc for Parameter & fix codex

pull/4823/head
Wei Luning 5 years ago
parent ccd9ef29e7
commit dde5a1bb48

@ -216,8 +216,10 @@ std::string DataDumpParser::GetOpOverflowBinPath(uint32_t graph_id, uint32_t dev
std::string bin_path = "/var/log/npu/ide_daemon/dump"; std::string bin_path = "/var/log/npu/ide_daemon/dump";
const char *dump_data_path = std::getenv("DATA_DUMP_PATH"); const char *dump_data_path = std::getenv("DATA_DUMP_PATH");
bin_path.append(dump_data_path); if (dump_data_path != nullptr) {
bin_path.append("_"); bin_path.append(dump_data_path);
bin_path.append("_");
}
bin_path.append(std::to_string(device_id)); bin_path.append(std::to_string(device_id));
bin_path.append("/"); bin_path.append("/");
bin_path.append(net_name_); bin_path.append(net_name_);

@ -36,6 +36,9 @@ class SwitchLayerDeferInline : public AnfVisitor {
auto tuple = dyn_cast<abstract::AbstractTuple>(cnode->inputs()[2]->abstract()); auto tuple = dyn_cast<abstract::AbstractTuple>(cnode->inputs()[2]->abstract());
for (auto elem : tuple->elements()) { for (auto elem : tuple->elements()) {
auto abstract = dyn_cast<abstract::FuncGraphAbstractClosure>(elem); auto abstract = dyn_cast<abstract::FuncGraphAbstractClosure>(elem);
if (abstract == nullptr) {
return nullptr;
}
*(abstract->func_graph()->switch_layer_input()) = true; *(abstract->func_graph()->switch_layer_input()) = true;
} }
return nullptr; return nullptr;

@ -173,6 +173,5 @@ bool MergeDuplicateGraphs(const FuncGraphManagerPtr manager) {
} }
return true; return true;
} }
} // namespace pipeline } // namespace pipeline
} // namespace mindspore } // namespace mindspore

@ -31,7 +31,6 @@ void TryToDoReplace(FuncGraphManager *manager, const AnfNodePtr &node, HashCache
size_t HashOfGraph(const FuncGraphPtr &fg); size_t HashOfGraph(const FuncGraphPtr &fg);
bool IsCNodeGraph(const AnfNodePtr &node); bool IsCNodeGraph(const AnfNodePtr &node);
bool MergeDuplicateGraphs(const FuncGraphManagerPtr manager); bool MergeDuplicateGraphs(const FuncGraphManagerPtr manager);
} // namespace pipeline } // namespace pipeline
} // namespace mindspore } // namespace mindspore

@ -473,12 +473,12 @@ bool IsGraphOutputValueNodeOrParameter(const AnfNodePtr &output, const py::tuple
} }
return false; return false;
} }
namespace {
// Isomorphism // Isomorphism
static bool SameNode(const AnfNodePtr &node1, const AnfNodePtr &node2, FuncGraphPairMapEquiv *equiv_func_graph, bool SameNode(const AnfNodePtr &node1, const AnfNodePtr &node2, FuncGraphPairMapEquiv *equiv_func_graph,
NodeMapEquiv *const equiv_node); NodeMapEquiv *const equiv_node);
static bool SameNodeShallow(const AnfNodePtr &node1, const AnfNodePtr &node2, FuncGraphPairMapEquiv *equiv_func_graph, bool SameNodeShallow(const AnfNodePtr &node1, const AnfNodePtr &node2, FuncGraphPairMapEquiv *equiv_func_graph,
NodeMapEquiv *const equiv_node) { NodeMapEquiv *const equiv_node) {
if (equiv_node == nullptr) { if (equiv_node == nullptr) {
MS_LOG(ERROR) << "Invalid equiv_node"; MS_LOG(ERROR) << "Invalid equiv_node";
return false; return false;
@ -534,8 +534,8 @@ bool SameNode(const AnfNodePtr &node1, const AnfNodePtr &node2, FuncGraphPairMap
return SameNodeShallow(node1, node2, equiv_func_graph, equiv_node); return SameNodeShallow(node1, node2, equiv_func_graph, equiv_node);
} }
static bool SameSubgraph(AnfNodePtr root1, AnfNodePtr root2, FuncGraphPairMapEquiv *equiv_func_graph, bool SameSubgraph(AnfNodePtr root1, AnfNodePtr root2, FuncGraphPairMapEquiv *equiv_func_graph,
NodeMapEquiv *const equiv_node) { NodeMapEquiv *const equiv_node) {
std::unordered_set<AnfNodePtr> done; std::unordered_set<AnfNodePtr> done;
std::stack<std::pair<AnfNodePtr, AnfNodePtr>> todo; std::stack<std::pair<AnfNodePtr, AnfNodePtr>> todo;
@ -576,6 +576,7 @@ static bool SameSubgraph(AnfNodePtr root1, AnfNodePtr root2, FuncGraphPairMapEqu
} }
return true; return true;
} }
} // namespace
bool Isomorphic(FuncGraphPtr fg1, FuncGraphPtr fg2, FuncGraphPairMapEquiv *equiv_func_graph, bool Isomorphic(FuncGraphPtr fg1, FuncGraphPtr fg2, FuncGraphPairMapEquiv *equiv_func_graph,
NodeMapEquiv *const equiv_node) { NodeMapEquiv *const equiv_node) {

@ -40,19 +40,18 @@ class Parameter(MetaTensor):
After initialized `Parameter` is a subtype of `Tensor`. After initialized `Parameter` is a subtype of `Tensor`.
In auto_parallel mode of "semi_auto_parallel" and "auto_parallel", if init `Parameter` by In auto_parallel mode of "semi_auto_parallel" and "auto_parallel", if init `Parameter` by
a `Initializer`, the type of Parameter will be a `MetaTensor` not a `Tensor`. `MetaTensor` an `Initializer`, the type of Parameter will be `MetaTensor` not `Tensor`. `MetaTensor`
only save the shape type info of a tensor with no memory usage. The shape can be change while only saves the shape and type info of a tensor with no memory usage. The shape can be changed while
compile for auto-parallel. Call `init_data` will return a Tensor Parameter with initialized data. compile for auto-parallel. Call `init_data` will return a Tensor Parameter with initialized data.
Note: Note:
Each parameter of Cell is represented by Parameter class. Each parameter of Cell is represented by Parameter class.
Args: Args:
default_input (Union[Tensor, Initializer]): Parameter data, when `default_input` is` Initializer`, default_input (Union[Tensor, Initializer, Number]): Parameter data, to be set initialized.
the data stored by Parameter is `MetaTensor`, otherwise it is `Tensor`.
name (str): Name of the child parameter. name (str): Name of the child parameter.
requires_grad (bool): True if the parameter requires gradient. Default: True. requires_grad (bool): True if the parameter requires gradient. Default: True.
layerwise_parallel (bool): A kind of model parallel mode. When layerwise_parallel is true in paralle mode, layerwise_parallel (bool): A kind of model parallel mode. When layerwise_parallel is true in parallel mode,
broadcast and gradients communication would not be applied to parameters. Default: False. broadcast and gradients communication would not be applied to parameters. Default: False.
Example: Example:

@ -580,7 +580,6 @@ class PConstant : public PBase<PConstant<T> > {
return nullptr; return nullptr;
} }
auto value = node->cast<ValueNodePtr>()->value(); auto value = node->cast<ValueNodePtr>()->value();
if (!value->isa<tensor::Tensor>()) { if (!value->isa<tensor::Tensor>()) {
return nullptr; return nullptr;
} }
@ -747,7 +746,6 @@ class PConstant : public PBase<PConstant<T> > {
std::vector<int> tensor_out_shape = tensor_3_abstract->shape()->shape(); std::vector<int> tensor_out_shape = tensor_3_abstract->shape()->shape();
int data_out_size = std::accumulate(tensor_out_shape.begin(), tensor_out_shape.end(), 1, std::multiplies<int>()); int data_out_size = std::accumulate(tensor_out_shape.begin(), tensor_out_shape.end(), 1, std::multiplies<int>());
if ((tensor_ptr_1->DataSize() > 1) && (tensor_ptr_1->DataSize() != data_out_size)) { if ((tensor_ptr_1->DataSize() > 1) && (tensor_ptr_1->DataSize() != data_out_size)) {
return nullptr; return nullptr;
} }

Loading…
Cancel
Save