Skip to content

Commit 5f9d410

Browse files
committed
follow comment
1 parent 7cd4d0a commit 5f9d410

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

python/paddle/fluid/framework.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class Operator(object):
418418
Args:
419419
block(Block): The block has the current operator.
420420
desc(core.OpDesc): The protobuf description of Operator.
421-
type(str): The type of operator.
421+
type(str): The type of operator. Default None.
422422
inputs(dict): The input of this Operator. it is a dictionary, for every
423423
element, key is the input parameter name, and value is a list of
424424
variables. Default None.
@@ -459,7 +459,12 @@ class Operator(object):
459459
'channel_recv', 'select', 'gen_nccl_id'
460460
}
461461

462-
def __init__(self, block, desc, type, inputs=None, outputs=None,
462+
def __init__(self,
463+
block,
464+
desc,
465+
type=None,
466+
inputs=None,
467+
outputs=None,
463468
attrs=None):
464469

465470
self.block = block
@@ -484,7 +489,9 @@ def __init__(self, block, desc, type, inputs=None, outputs=None,
484489

485490
if len(self.desc.type()) != 0:
486491
return
487-
492+
if type is None:
493+
raise ValueError(
494+
"`type` to initilized an Operator can not be None.")
488495
self.desc.set_type(type)
489496
proto = OpProtoHolder.instance().get_op_proto(type)
490497

0 commit comments

Comments
 (0)