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

[feat]: index_fill_ frontend pytorch op #27420

Merged
merged 11 commits into from
Nov 26, 2024

Conversation

cocoshe
Copy link
Contributor

@cocoshe cocoshe commented Nov 6, 2024

Details:

Add support for aten::index_fill_ for pytorch models

Tickets:

#23326

@cocoshe cocoshe requested a review from a team as a code owner November 6, 2024 07:14
@github-actions github-actions bot added the category: PyTorch FE OpenVINO PyTorch Frontend label Nov 6, 2024
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Nov 6, 2024
Copy link
Contributor

@mvafin mvafin left a comment

Choose a reason for hiding this comment

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

In general looks good, please also fix code style

src/frontends/pytorch/src/op/index_fill_.cpp Outdated Show resolved Hide resolved
Co-authored-by: Maxim Vafin <[email protected]>
@cocoshe
Copy link
Contributor Author

cocoshe commented Nov 20, 2024

In general looks good, please also fix code style

OK, and by the way, the code style check can only be enabled when CMake? Some other projects support the code style check by pre-commit, does openvino support it?

@mlukasze
Copy link
Contributor

yes, that's how we know it should be corrected for this PR ;)

@cocoshe cocoshe requested a review from mvafin November 20, 2024 16:39
@cocoshe
Copy link
Contributor Author

cocoshe commented Nov 20, 2024

yes, that's how we know it should be corrected for this PR ;)

I'm not very sure about it, the CI use clang-format tool here:

- name: Create code style diff
run: cmake --build build --target clang_format_fix_all -j8

I used to participate in some projects like PaddlePaddle, it support the pre-commit with the .pre-commit-config.yaml config file:

https://github.com/PaddlePaddle/Paddle/blob/c3ba53c8c9df394d2054e5d1e19eab357c9b6b26/.pre-commit-config.yaml#L68-L75

# For C++ files
-   repo: local
    hooks:
    -   id: clang-format
        name: clang-format
        description: Format files with ClangFormat.
        entry: bash ./tools/codestyle/clang_format.sh -i
        language: system
        files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$

It seems the CI requires the make process, while PaddlePaddle can run the code style check when git commit -m 'xxxx', it only focus on the file you modified, and don't need to run make again. With the pre-commit hook, just run git commit -m "xxxx" can get the modified result directly, and all we need is to run git add and git commit again to add the fixed code. PaddlePaddle is felt more convenient since the pre-commit don't need to make the code style check again and again. And the CI just need to run the bash to show "It is a code style problem, and where is the problem, and how to fix the code style problem":

echo -e '\n************************************************************************************'
if [ ${check_error} != 0 ];then
    echo "Your PR code style check failed."
    echo "Please install pre-commit locally and set up git hook scripts:"
    echo ""
    echo "    pip install pre-commit==2.17.0"
    echo "    pre-commit install"
    echo ""
    if [[ $num_diff_files -le 100 ]];then
        echo "Then, run pre-commit to check codestyle issues in your PR:"
        echo ""
        echo "    pre-commit run --files" $(echo ${diff_files} | tr "\n" " ")
        echo ""
    fi
    echo "For more information, please refer to our codestyle check guide:"
    echo "https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/dev_guides/git_guides/codestyle_check_guide_cn.html"
else
    echo "Your PR code style check passed."
fi
echo -e '************************************************************************************\n'

So I'm not sure if the the openvino only support the code style check with make. If yes, I think a pre-commit like PaddlePaddle did maybe much more convenient.

Just a few feelings when contributing code for openvino 👀💭

Copy link
Contributor

@mvafin mvafin left a comment

Choose a reason for hiding this comment

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

Looks good, tests are passing

@mvafin
Copy link
Contributor

mvafin commented Nov 21, 2024

build_jenkins

Copy link
Contributor

@mvafin mvafin left a comment

Choose a reason for hiding this comment

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

Was wrong. Tests fail on windows:

RuntimeError: index_fill_(): Expected dtype int64 for index.

@cocoshe
Copy link
Contributor Author

cocoshe commented Nov 22, 2024

Was wrong. Tests fail on windows:

RuntimeError: index_fill_(): Expected dtype int64 for index.

I don't have any win device for now, and not very sure about what makes the error only on win but not on linux.
The error occured when generating torchscript, and I just noticed some other tests define the index dtype as long specifically for torchscript generation. So I commit a bit on it, could you pls rerun the CI for me? Or any other advice or help on solving the error?

@mvafin
Copy link
Contributor

mvafin commented Nov 22, 2024

build_jenkins

@cocoshe
Copy link
Contributor Author

cocoshe commented Nov 24, 2024

@mvafin Hi, Anything else I should do?

@mvafin
Copy link
Contributor

mvafin commented Nov 25, 2024

@mvafin Hi, Anything else I should do?

@cocoshe No, I will take it from here

@cocoshe
Copy link
Contributor Author

cocoshe commented Nov 25, 2024

@mvafin Hi, Anything else I should do?

@cocoshe No, I will take it from here

OK, tks for your review:)

@mvafin
Copy link
Contributor

mvafin commented Nov 26, 2024

build_jenkins

@mvafin mvafin added this pull request to the merge queue Nov 26, 2024
Merged via the queue into openvinotoolkit:master with commit 17e17b2 Nov 26, 2024
171 checks passed
@mlukasze mlukasze added this to the 2025.0 milestone Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: PyTorch FE OpenVINO PyTorch Frontend ExternalPR External contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Good First Issue]: Support aten::index_fill_ for pytorch models
4 participants