Skip to content

[SOT] Support .tolist() in SOT Static Mode #71201

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

Merged
merged 6 commits into from
Feb 20, 2025

Conversation

DrRyanHuang
Copy link
Contributor

@DrRyanHuang DrRyanHuang commented Feb 19, 2025

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

Currently, .tolist() method is not supported in SOT static mode.

import paddle
import numpy as np


def fn():
    x = paddle.rand([3])
    y = x.tolist()
    return y


static_fn = paddle.jit.to_static(fn, full_graph=False)

out = static_fn()
# out = fn()
print(out)

the code will raise:

paddle.jit.sot.utils.exceptions.HasNoAttributeError: Unknown Tensor attribute: tolist

Under @SigureMo ’s guidance, this PR implements .tolist() support, following a similar approach to the .numpy() implementation.

PCard-66972

Copy link

paddle-bot bot commented Feb 19, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Feb 19, 2025
@DrRyanHuang DrRyanHuang changed the title [SOT] Support .tolist() in SOT Static Mode [SOT] Support .tolist() in SOT Static Mode Feb 19, 2025
Comment on lines 51 to 52
a.tolist(),
a.numpy(),
Copy link
Member

Choose a reason for hiding this comment

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

这里有点多了,tolistnumpy 一定会 breakgraph,可以拆成两个,其它不会 breakgraph 的可以加个 check_no_breakgraph 确保不会 break

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

test/dygraph_to_static/test_tensor_attr_consistency.py 里可以将 tolist 移除一下了

这个列表也可以关注下

@SigureMo SigureMo changed the title [SOT] Support .tolist() in SOT Static Mode [SOT][3.13] Support .tolist() in SOT Static Mode Feb 20, 2025
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo changed the title [SOT][3.13] Support .tolist() in SOT Static Mode [SOT] Support .tolist() in SOT Static Mode Feb 20, 2025
@SigureMo SigureMo merged commit 1bb12d0 into PaddlePaddle:develop Feb 20, 2025
35 checks passed
@DrRyanHuang DrRyanHuang deleted the add_tolist_support_new branch February 20, 2025 12:32
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Mar 6, 2025
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants