Skip to content

Commit a943134

Browse files
committed
fix a few more tests
test=develop
1 parent 5839e32 commit a943134

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

paddle/fluid/framework/ir/conv_relu_mkldnn_fuse_pass_tester.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "paddle/fluid/framework/ir/conv_relu_mkldnn_fuse_pass.h"
1616

1717
#include <gtest/gtest.h>
18+
#include "paddle/fluid/framework/op_proto_maker.h"
1819

1920
namespace paddle {
2021
namespace framework {
@@ -36,6 +37,8 @@ void SetOp(ProgramDesc* prog, const std::string& type, const std::string& name,
3637
op->SetInput("X", inputs);
3738
}
3839
op->SetOutput("Out", outputs);
40+
op->SetAttr(OpProtoAndCheckerMaker::OpRoleAttrName(),
41+
static_cast<int>(OpRole::kForward));
3942
}
4043

4144
// a->OP0->b

paddle/fluid/framework/ir/fc_fuse_pass_tester.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "paddle/fluid/framework/ir/fc_fuse_pass.h"
1616

1717
#include <gtest/gtest.h>
18+
#include "paddle/fluid/framework/op_proto_maker.h"
1819

1920
namespace paddle {
2021
namespace framework {
@@ -32,6 +33,8 @@ void SetOp(ProgramDesc* prog, const std::string& type,
3233
op->SetInput("X", inputs);
3334
}
3435
op->SetOutput("Out", outputs);
36+
op->SetAttr(OpProtoAndCheckerMaker::OpRoleAttrName(),
37+
static_cast<int>(OpRole::kForward));
3538
}
3639

3740
// a->OP0->b

paddle/fluid/framework/ir/graph.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ namespace paddle {
2424
namespace framework {
2525
namespace ir {
2626
namespace {
27+
2728
void CheckProgram(const ProgramDesc &program) {
2829
std::map<int, bool> visit;
2930
#define _INT(role) static_cast<int>(role)
3031

3132
for (size_t i = 0; i < program.Size(); ++i) {
3233
for (OpDesc *op : program.Block(i).AllOps()) {
34+
// For backward compatibility, some program doesn't have role added.
35+
if (!op->HasAttr(OpProtoAndCheckerMaker::OpRoleAttrName())) continue;
3336
int role_id = boost::get<int>(
3437
op->GetAttr(OpProtoAndCheckerMaker::OpRoleAttrName()));
3538
visit[role_id] = true;

paddle/fluid/inference/analysis/data_flow_graph_tester.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#include "paddle/fluid/inference/analysis/data_flow_graph.h"
16+
#include "paddle/fluid/framework/op_proto_maker.h"
1617
#include "paddle/fluid/framework/program_desc.h"
1718
#include "paddle/fluid/inference/analysis/ut_helper.h"
1819

@@ -130,6 +131,8 @@ void SetOp(framework::ProgramDesc* prog, const std::string& type,
130131
op->SetType(type);
131132
op->SetInput("Xs", inputs);
132133
op->SetOutput("Xs", outputs);
134+
op->SetAttr(framework::OpProtoAndCheckerMaker::OpRoleAttrName(),
135+
static_cast<int>(framework::OpRole::kForward));
133136
}
134137

135138
TEST(DataFlowGraph, Build_IR_Graph) {

0 commit comments

Comments
 (0)