Python IrVarNode. Beneath it is a core.Node, it inherits from IrNode.
| 5320 | |
| 5321 | |
| 5322 | class IrVarNode(IrNode): |
| 5323 | """ |
| 5324 | Python IrVarNode. Beneath it is a core.Node, it inherits from IrNode. |
| 5325 | """ |
| 5326 | |
| 5327 | def __init__(self, node): |
| 5328 | """ |
| 5329 | Construct an IrVarNode using core.Node. |
| 5330 | |
| 5331 | Args: |
| 5332 | node(core.Node): C++ Node. |
| 5333 | """ |
| 5334 | assert isinstance(node, core.Node) and node.is_var(), ( |
| 5335 | "node must be the instance of core.Node and it must be a variable node." |
| 5336 | ) |
| 5337 | super().__init__(node) |
| 5338 | self.node = node |
| 5339 | |
| 5340 | def set_shape(self, shape): |
| 5341 | """ |
| 5342 | Set the node variable shape. |
| 5343 | |
| 5344 | Args: |
| 5345 | shape(list): shape to be set. |
| 5346 | """ |
| 5347 | assert self.node.var() is not None, ( |
| 5348 | "The node variable description can not be None." |
| 5349 | ) |
| 5350 | self.node.var().set_shape(shape) |
| 5351 | |
| 5352 | def persistable(self): |
| 5353 | """ |
| 5354 | If the variable node is a persistable variable, then return true. |
| 5355 | |
| 5356 | Returns: |
| 5357 | bool: indicate whether the variable is persistable. |
| 5358 | """ |
| 5359 | assert self.node.var() is not None, ( |
| 5360 | "The node variable description can not be None." |
| 5361 | ) |
| 5362 | return self.node.var().persistable() |
| 5363 | |
| 5364 | def type(self): |
| 5365 | """ |
| 5366 | Return the variable type. |
| 5367 | |
| 5368 | Returns: |
| 5369 | core.VarDesc.VarType: the variable type. |
| 5370 | """ |
| 5371 | assert self.node.var() is not None, ( |
| 5372 | "The node variable description can not be None." |
| 5373 | ) |
| 5374 | return self.node.var().type() |
| 5375 | |
| 5376 | def dtype(self): |
| 5377 | """ |
| 5378 | Return the variable data type. |
| 5379 |
no outgoing calls
no test coverage detected