Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new api/op repeat_interleave #37981

Merged
merged 1 commit into from
Dec 17, 2021
Merged

Conversation

kuizhiqing
Copy link
Member

@kuizhiqing kuizhiqing commented Dec 8, 2021

PR types

New features

PR changes

APIs

Describe

new api/op repeat_interleave

examples

x = paddle.to_tensor([[1, 2, 3], [4, 5, 6]])
repeats  = paddle.to_tensor([3, 2, 1], dtype='int32')

paddle.repeat_interleave(x, repeats, 1)
# [[1, 1, 1, 2, 2, 3],
#  [4, 4, 4, 5, 5, 6]]

paddle.repeat_interleave(x, 2, 0)
# [[1, 2, 3], [1, 2, 3], [4, 5, 6], [4, 5, 6]]

paddle.repeat_interleave(x, 2, None)
# [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]

performance v.s. PyTorch

input(shape) output(shape) paddle(s) torch(s)
[100, 2, 40] [100, 7, 40] 6.16 8.20
[100, 5, 40] [100, 29, 40] 6.41 8.34
[100,30,40] [100, 154, 40] 6.97 8.44
[100, 50, 40] [100, 229, 40] 7.64 8.59
[100, 100, 40] [100, 470, 40] 8.88 10.22
[100, 1000, 40] [100, 4589, 40] 31.57 37.41
[100, 1000, 40] [445, 1000, 40] 28.26 35.51
[100, 1000, 40] [100, 1000, 179] 30.05 37.00

@paddle-bot-old
Copy link

paddle-bot-old bot commented Dec 8, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@CLAassistant
Copy link

CLAassistant commented Dec 10, 2021

CLA assistant check
All committers have signed the CLA.

python/paddle/tensor/manipulation.py Outdated Show resolved Hide resolved
python/paddle/tensor/manipulation.py Outdated Show resolved Hide resolved
paddle/fluid/operators/repeat_interleave_op.cu Outdated Show resolved Hide resolved
python/paddle/__init__.py Show resolved Hide resolved
python/paddle/tensor/__init__.py Show resolved Hide resolved
python/paddle/tensor/manipulation.py Show resolved Hide resolved
python/paddle/tensor/manipulation.py Outdated Show resolved Hide resolved
@jeff41404
Copy link
Contributor

shall we add example of API in Describe ?

x (Tensor): The input Tensor to be operated. The data of ``x`` can be one of float32, float64, int32, int64.
repeats (Tensor or int): The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.
axis (int, optional): The dimension in which we manipulate. Default: if None, the output tensor is flatten.
name(str, optional): The default value is None. Normally there is no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if None -> None


Returns:
Tensor: A Tensor with same data type as ``x``.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

示例代码要显式的写 Examples:

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@xymyeah xymyeah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@TCChenlong TCChenlong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Fix API Docs

Copy link
Member

@ForFishes ForFishes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ForFishes ForFishes merged commit a7de0e6 into PaddlePaddle:develop Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants