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

Fixed topk op #805

Merged
merged 12 commits into from Jun 6, 2022
Merged

Fixed topk op #805

merged 12 commits into from Jun 6, 2022

Conversation

wjj19950828
Copy link
Collaborator

@wjj19950828 wjj19950828 commented Jun 1, 2022

Create A Good Pull Request

下面的文字请保留在PR说明的最后面,并在提完PR后,根据实际情况勾选确认以下情况

Please check the follow step before merging this pull request

  • Python code style verification
  • Review all the code diff by yourself
  • All models(TensorFLow/Caffe/ONNX/PyTorch) testing passed
  • Details about your pull request, releated issues

If this PR add new model support, please update model_zoo.md and add model to out test model zoos(@wjj19950828)

  • New Model Supported
  • No New Model Supported

Do follow contributes

1、优化topk实现,增加k为attr的实现
2、solved #803

k = k[0]
if k is not None:
is_k_attr = True
layer_attrs["k"] = k
Copy link
Contributor

Choose a reason for hiding this comment

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

这里判断了k is not None,如果k是None会怎样?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这里主要分为两种情况:k不为None,作为属性传入;k为None,作为输入传入

修改了下写法,判断k is not None以及else,Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

这种代码,加上注释吧。 之前的注释确实太少,现在有这种逻辑的,都加上注释说明,避免以后再回过头看代码,不清楚这个逻辑是在干啥

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

k = k[0]
if k is not None:
is_k_attr = True
layer_attrs["k"] = k
Copy link
Contributor

Choose a reason for hiding this comment

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

这种代码,加上注释吧。 之前的注释确实太少,现在有这种逻辑的,都加上注释说明,避免以后再回过头看代码,不清楚这个逻辑是在干啥

@wjj19950828 wjj19950828 merged commit 2cb5ba2 into PaddlePaddle:develop Jun 6, 2022
@wjj19950828 wjj19950828 deleted the fixed_topk branch June 7, 2022 09:28
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.

None yet

2 participants