MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _create_block

Method _create_block

python/paddle/base/framework.py:7293–7314  ·  view source on GitHub ↗

Create a new block with the :code:`parent_idx` and change the current block to new block. Args: parent_idx(int): The parent block index. Returns: Block: The new block.

(self, parent_idx=None)

Source from the content-addressed store, hash-verified

7291 return self.blocks[self.current_block_idx]
7292
7293 def _create_block(self, parent_idx=None):
7294 """
7295 Create a new block with the :code:`parent_idx` and change the current block
7296 to new block.
7297
7298 Args:
7299
7300 parent_idx(int): The parent block index.
7301
7302 Returns:
7303 Block: The new block.
7304 """
7305 new_block_idx = len(self.blocks)
7306 parent = (
7307 self.current_block()
7308 if parent_idx is None
7309 else self.block(parent_idx)
7310 )
7311 self.desc.append_block(parent.desc)
7312 self.current_block_idx = new_block_idx
7313 self.blocks.append(Block(self, self.current_block_idx))
7314 return self.current_block()
7315
7316 def _roll_to_global_block(self):
7317 self.current_block_idx = 0

Callers 15

get_pserver_programMethod · 0.95
get_pserver_programMethod · 0.95
run_pserverFunction · 0.95
__enter__Method · 0.80
create_backward_blockFunction · 0.80

Calls 4

current_blockMethod · 0.95
blockMethod · 0.95
BlockClass · 0.70
appendMethod · 0.45

Tested by 2

run_pserverFunction · 0.76
test_error_typeMethod · 0.64