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

[NPU] Support npu kernel for assign_value op #34568

Merged
merged 3 commits into from
Aug 4, 2021
Merged

[NPU] Support npu kernel for assign_value op #34568

merged 3 commits into from
Aug 4, 2021

Conversation

betterpig
Copy link
Contributor

@betterpig betterpig commented Aug 3, 2021

PR types

New features

PR changes

OPs

Describe

  1. add assign_value_op_npu.cc, it simply register npu kernel, and call compute function in assign_value_op.h to finish job.
  2. add code for npu condition in paddle/fluid/framework/tensor_util.h: TensorFromArray. The reason is as follows:
    When inputs' dtype is bool, there is no corresponding TensorFromVector template function for vector, so only TensorFromArray can be used, but it didn't consider npu condition before.

ctest result and op running environment
Pasted Graphic 6

@CLAassistant
Copy link

CLAassistant commented Aug 3, 2021

CLA assistant check
All committers have signed the CLA.

zhwesky2010
zhwesky2010 previously approved these changes Aug 3, 2021
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

paddle/fluid/operators/assign_value_op_npu.cc Outdated Show resolved Hide resolved
a=[False, True], size=(2, 5)).astype(numpy.bool)
self.attrs["bool_values"] = [bool(v) for v in self.value.flat]


Copy link
Contributor

Choose a reason for hiding this comment

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

建议参考test_assign_value_op.py把里面4个TestAssignApi相关的单测也加上,相应的修改NPUPlace。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

你好,感谢review。已将相应的TestAssignApi类加上并改成NPUPlace,单测结果如下图。
Pasted Graphic 7

Copy link
Contributor

@qili93 qili93 left a comment

Choose a reason for hiding this comment

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

LGTM

@qili93 qili93 merged commit f39c3a5 into PaddlePaddle:develop Aug 4, 2021
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.

4 participants