|
|
|
@ -570,9 +570,6 @@ def where(condition, x, y, name=None):
|
|
|
|
|
|
|
|
|
|
def index_sample(x, index):
|
|
|
|
|
"""
|
|
|
|
|
:alias_main: paddle.index_sample
|
|
|
|
|
:alias: paddle.index_sample,paddle.tensor.index_sample,paddle.tensor.search.index_sample
|
|
|
|
|
|
|
|
|
|
**IndexSample Layer**
|
|
|
|
|
|
|
|
|
|
IndexSample OP returns the element of the specified location of X,
|
|
|
|
@ -595,13 +592,13 @@ def index_sample(x, index):
|
|
|
|
|
[6, 8, 10]]
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x (Variable): The source input tensor with 2-D shape. Supported data type is
|
|
|
|
|
x (Tensor): The source input tensor with 2-D shape. Supported data type is
|
|
|
|
|
int32, int64, float32, float64.
|
|
|
|
|
index (Variable): The index input tensor with 2-D shape, first dimension should be same with X.
|
|
|
|
|
index (Tensor): The index input tensor with 2-D shape, first dimension should be same with X.
|
|
|
|
|
Data type is int32 or int64.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
output (Variable): The output is a tensor with the same shape as index.
|
|
|
|
|
output (Tensor): The output is a tensor with the same shape as index.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
|
@ -609,7 +606,6 @@ def index_sample(x, index):
|
|
|
|
|
|
|
|
|
|
import paddle
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
x = paddle.to_tensor([[1.0, 2.0, 3.0, 4.0],
|
|
|
|
|
[5.0, 6.0, 7.0, 8.0],
|
|
|
|
|
[9.0, 10.0, 11.0, 12.0]], dtype='float32')
|
|
|
|
@ -644,8 +640,10 @@ def index_sample(x, index):
|
|
|
|
|
# [ 800 700]
|
|
|
|
|
# [1200 1100]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
if in_dygraph_mode():
|
|
|
|
|
return core.ops.index_sample(x, index)
|
|
|
|
|
|
|
|
|
|
helper = LayerHelper("index_sample", **locals())
|
|
|
|
|
check_variable_and_dtype(x, 'x', ['float32', 'float64', 'int32', 'int64'],
|
|
|
|
|
'paddle.tensor.search.index_sample')
|
|
|
|
|