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

Add RARE (CRNN-seq2seq) README and support O2 training #274

Merged
merged 4 commits into from
May 11, 2023

Conversation

zhtmike
Copy link
Collaborator

@zhtmike zhtmike commented May 10, 2023

  • Add RARE (CRNN-seq2seq) README and benchmark result.
  • The native GRUCell operator does not support FP16 input (see issue https://gitee.com/mindspore/mindspore/issues/I6ZY2O), here we implemented a input-fixed version
  • Update the multi dataset evaluation script due to the interface update (num_columns -> columns_index), handle the exception when data_dir_root is incorrect

Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:

Motivation

(Write your motivation for proposed changes here.)

Test Plan

(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)

Related Issues and PRs

(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)

@zhtmike zhtmike requested review from SamitHuang and hqkate May 10, 2023 02:07
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 可否通过修改amp.py里的white/black list来将RNN层设成半精度?
  2. 建议rename _nn -> utils,可把自定义的layers 和 helpers放里面

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

RNNCell应当属于white list, 会把input 自动cast为fp16。但目前mindspore RNNCell会在fp16输入时前向报错,原因是RNNCell内参如weight_ih没有自动转换成fp16,从而当用到MatMul算子时因为两边输入type不对齐而报错。此改动强制将内参和输入转换成统一type,避免这一问题。

Copy link
Collaborator

Choose a reason for hiding this comment

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

了解,那应该在自定义的RNNCell init中加入 cast_fp16的选项?否则如果设成O0的话,该层仍然会半精度计算。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

现在RNNCell内参会根据输入的type改变的,如果输入为fp32,那内参会改为fp32,计算会是全精度

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

_nn 已才成 utils

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 可否通过修改amp.py里的white/black list来将RNN层设成半精度?
  2. 建议rename _nn -> utils,可把自定义的layers 和 helpers放里面

@zhtmike zhtmike requested a review from HaoyangLee May 10, 2023 07:44
@zhtmike
Copy link
Collaborator Author

zhtmike commented May 10, 2023

Uploaded checkpoint path, can review @SamitHuang @HaoyangLee

@SamitHuang
Copy link
Collaborator

Conflicts are to be solved before merge

@SamitHuang SamitHuang merged commit 6caef01 into mindspore-lab:main May 11, 2023
@zhtmike zhtmike deleted the seq2seq_merge2 branch May 15, 2023 10:29
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.

3 participants