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

[3.13] add simulation support for user-defined iterable objects #70620

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

GoldenStain
Copy link
Contributor

@GoldenStain GoldenStain commented Jan 3, 2025

PR Category

User Experience

PR Types

New features

Description

如果用户自定义的Iterable对象,其__iter()__方法返回的结果是listdicttupletensorrange,那么就能够模拟iter
PCard-66972

@GoldenStain
Copy link
Contributor Author

test case:

class IterableWithList():
    def __init__(self):
        self._list = [1, 2, 3]
    def __iter__(self):
        return self._list.__iter__()

def list_within_class(x: paddle.Tensor):
    my_iterable = IterableWithList()
    for i in my_iterable:
        x += i
    return x

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.

1 participant