Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions python/paddle/fluid/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,6 @@ def __init__(self, type=None):
self._type = type

def __getattr__(self, name):
if self._type is not None:
raise AttributeError(
"type object 'OpHelper' has no attribute '{}'".format(name))
op = PassDesc.OpHelper(name)
op.Init()
return op
Expand Down Expand Up @@ -261,7 +258,12 @@ def Init(self):
self._op_idx = len(block.ops)
self._op_desc = block.desc.append_op()
self._op_desc.set_type(self._type)
self._op_proto = OpProtoHolder.instance().get_op_proto(self._type)
self._op_proto = OpProtoHolder.instance().op_proto_map.get(
self._type)
if self._op_proto is None:
raise AttributeError(
"type object 'OpHelper' has no attribute '{}'".format(
self._type))
block.ops.append(self)

def Attr(self, name):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def convert_ops_to_op_dicts(self, ops):
op_dicts[op.type] = [op]
return op_dicts

def test_has_attr(self):
self.assertFalse(hasattr(ir.PassDesc.OP, '__name__'))

def test_generate_fc_fuse(self):
def _check_fc_fuse_pass(pass_desc, with_relu):
pattern_op_dicts = self.convert_ops_to_op_dicts(
Expand Down