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

Function _slice_tensor_array

python/paddle/base/layers/math_op_patch.py:106–119  ·  view source on GitHub ↗
(array, start, end)

Source from the content-addressed store, hash-verified

104# TODO(liym27): A better way to slice tensor array.
105# Maybe support start == end for slice op.
106def _slice_tensor_array(array, start, end):
107 from paddle.static.nn import cond
108 from paddle.tensor import create_array
109
110 def true_fn():
111 null_array = create_array("float32")
112 return null_array
113
114 def false_fn(array, start, end):
115 new_array = array[start:end]
116 return new_array
117
118 new_array = cond(start == end, true_fn, lambda: false_fn(array, start, end))
119 return new_array
120
121
122def monkey_patch_variable():

Callers 1

popFunction · 0.85

Calls 2

condFunction · 0.90
false_fnFunction · 0.70

Tested by

no test coverage detected