Python side TaskNode, connection to the c++ side TaskNode
"""
# track the previous init method
previous=None
def__init__(self,
cur_rank,
rank,
max_run_times,
max_slot_times,
role=None,
node_type='Compute',
task_id=None,
node_type=None,
task_id=0,
ops=None,
program=None):
program=None,
lazy_initialize=False):
"""
:param cur_rank (int): Current rank of the task node.
:param rank (int): Current rank of the task node.
:param max_run_times (int): The max run times of the task node.
:param max_slot_times (int): The mas slot times of the task node.
:param role (int): The role of the task node.
:param node_type (str): The type of the task node, default is 'Compute'
:param task_id (int): The task id of the task node.
:param ops (list): A list of op.desc to init the task node.
:param role (int): The role of the task node. (Will be removed in the future)
:param node_type (str): The type of the task node.
:param task_id (int): The id of task node.
:param ops (list): A list of op.desc to init the task node. (Will be removed in the future)
:param program (Program): An instance of Program to init the task node.
:param lazy_initialize (bool): In user-defined task, the program may change adding feed/fetch op. As efficient consideration, the task node will have the C++ object later.
"""
# NOTE: ops should be checked by `is not None`, since it may be empty list
assert((opsisnotNone)^(programisnotNone)), \
"Should provide only one of ops or program to task node."
"Inside program is unchangable for immediate initialized task node. Set the lazy_initialize to be true if the inside program need to be update. Remember to do all your change before eval node.task_node()."
self.program=program
self.node.set_program(program.desc)
defget_program(self):
asserthasattr(self,'program'),'There is no program to get'
assertself.programisnotNone,"The task node is not initialized using program"