From d5ee05e6c376929e416854f8864a672c6cc84958 Mon Sep 17 00:00:00 2001 From: baojun-nervana Date: Tue, 27 Nov 2018 23:06:17 -0800 Subject: [PATCH] Replaced VarIsTensor test=develop --- paddle/fluid/framework/ngraph_operator.cc | 10 +++++----- paddle/fluid/framework/operator.cc | 2 +- paddle/fluid/framework/operator.h | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/framework/ngraph_operator.cc b/paddle/fluid/framework/ngraph_operator.cc index 61bae1aba..1c770a237 100644 --- a/paddle/fluid/framework/ngraph_operator.cc +++ b/paddle/fluid/framework/ngraph_operator.cc @@ -283,7 +283,7 @@ void NgraphOperator::GetNgInputShape(std::shared_ptr op) { for (auto& var_name_item : op->Inputs()) { for (auto& var_name : var_name_item.second) { auto* var = scope_.FindVar(var_name); - if (var && VarIsTensor(*var)) { + if (var && var->IsType()) { auto* tensor_pd = GetLoDTensorOrSelectedRowsValueFromVar(*var); auto sp = Ddim2Shape(tensor_pd->dims()); if (std::find(var_in_.begin(), var_in_.end(), var_name) != @@ -305,7 +305,7 @@ void NgraphOperator::BuildNgNode() { for (auto& var_name : var_out_) { if (var_node_map_->find(var_name) == var_node_map_->end()) { auto* var = scope_.FindVar(var_name); - if (var && VarIsTensor(*var)) { + if (var && var->IsType()) { auto* tensor_pd = GetLoDTensorOrSelectedRowsValueFromVar(*var); auto& ddim = tensor_pd->dims(); auto ng_shape = Ddim2Shape(ddim); @@ -433,7 +433,7 @@ std::shared_ptr NgraphOperator::GetCacheKey() { for (auto& var_name : var_out_) { auto* var = scope_.FindVar(var_name); - if (var && VarIsTensor(*var)) { + if (var && var->IsType()) { auto* tensor_pd = GetLoDTensorOrSelectedRowsValueFromVar(*var); auto& ddim = tensor_pd->dims(); for (int i = 0; i < ddim.size(); ++i) { @@ -469,7 +469,7 @@ void NgraphOperator::Run(const Scope& scope, auto sp = var_node_map_->at(vi)->get_shape(); std::shared_ptr ti; auto* var = scope.FindVar(vi); - if (var && VarIsTensor(*var)) { + if (var && var->IsType()) { auto* tensor_pd = GetLoDTensorOrSelectedRowsValueFromVar(*var); PADDLE_ENFORCE(sp == Ddim2Shape(tensor_pd->dims()), "Ensure ngraph tensor layout align with paddle tensor"); @@ -518,7 +518,7 @@ void NgraphOperator::Run(const Scope& scope, auto var_name = var_out_[i]; auto* var = scope.FindVar(var_name); std::shared_ptr to; - if (var && VarIsTensor(*var)) { + if (var && var->IsType()) { auto* tensor_pd = GetMutableLoDTensorOrSelectedRowsValueFromVar(var); auto dd = tensor_pd->dims(); ngraph::Shape sp = Ddim2Shape(dd); diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index f3d225df6..c6f3254e9 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -355,7 +355,7 @@ void OperatorBase::GenerateTemporaryNames() { } } -bool VarIsTensor(const Variable& var) { +static bool VarIsTensor(const Variable& var) { return var.IsType() || var.IsType(); } diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index efc9a1b6f..0a6a28a5b 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -64,7 +64,6 @@ inline std::string GradVarName(const std::string& var_name) { } proto::VarType::Type GetDataTypeOfVar(const Variable* var); -bool VarIsTensor(const Variable& var); const Tensor* GetLoDTensorOrSelectedRowsValueFromVar(const Variable& var); Tensor* GetMutableLoDTensorOrSelectedRowsValueFromVar(Variable* var); -- GitLab