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

Function check_view_value

python/paddle/utils/inplace_utils.py:34–47  ·  view source on GitHub ↗
(value: Value)

Source from the content-addressed store, hash-verified

32
33
34def check_view_value(value: Value) -> bool:
35 # check if the value is a view tensor
36 if value.get_defining_op().name() in stride_ops:
37 # TODO(ooooo-create): The `x = stride_op(x)` shouldn't return True.
38 return True
39 all_used_ops = value.all_used_ops()
40 if len(all_used_ops) == 0:
41 return False
42 for op in all_used_ops:
43 if op.name() in stride_ops and op.operand_source(0).is_same(value):
44 # TODO(ooooo-create): The `y = stride_op(x).clone()` and `y = stride_op(x) + op` should also return False.
45 # Now is True.
46 return True
47 return False
48
49
50# NOTE(pangyoki): The Inplace APIs with underline(`_`) is only valid for the method of calling `_C_ops`

Callers 1

__impl__Function · 0.85

Calls 2

nameMethod · 0.45
operand_sourceMethod · 0.45

Tested by

no test coverage detected