diff --git a/paddle/fluid/framework/ngraph_operator.cc b/paddle/fluid/framework/ngraph_operator.cc index 61bae1aba41d7630d40585b521688fbd6c069165..1c770a2370926c6b32236537cbb265e8a9eaa468 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 f3d225df69c5f6c320d60897b959f66e86080205..c6f3254e9f7cedcf47be8ce8c3eecf4aa1b57add 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 efc9a1b6f5a38f73fec2771d3bc6c3141f642baf..0a6a28a5bce01d71cf56f25f5556033db94452c2 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);