Skip to content

Conversation

@0x45f
Copy link
Contributor

@0x45f 0x45f commented Aug 4, 2021

PR types

New features

PR changes

OPs

Describe

[NPU] Add exp and exp_grad npu op
截屏2021-08-06 上午11 16 26
截屏2021-08-06 上午11 18 26
截屏2021-08-06 上午11 20 54


REGISTER_OP_NPU_KERNEL(
exp, ops::ExpNPUKernel<paddle::platform::NPUDeviceContext, float>,

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this empty line

Copy link
Contributor

Choose a reason for hiding this comment

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

Why forward kernel dones't register int/int64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

前向调用了CANN中实现的exp算子,该算子支持的类型如下,不支持int/int64
exp


REGISTER_OP_NPU_KERNEL(
exp_grad, ops::ExpGradNPUKernel<paddle::platform::NPUDeviceContext, float>,

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

self.__class__.use_npu = True


class TestExpNPUOPFloat64(TestExpNPUOP):
Copy link
Contributor

Choose a reason for hiding this comment

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

why not add unittest of int / int64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

移除了反向中的int/int64 kernel的注册,与前向类型保持一致

This File can make gcc to compile './exp_op_npu.cc' .
If this file is deleted, exp_op_npu will not be compiled!
Refer to ./activation_op.cc to get ExpOP definition
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

activation相关的算子都写在activation_op_npu.cc文件里面,这个exp_op.cc和exp_op_npu.cc都不需要

Copy link
Contributor Author

Choose a reason for hiding this comment

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

activation相关的算子都写在activation_op_npu.cc文件里面,这个exp_op.cc和exp_op_npu.cc都不需要
已经将实现代码放入activation_op_npu.cc文件中,删除了exp_op.cc和exp_op_npu.cc文件

}
if (ctx.HasAttr("shift")) {
attr_input["shift"] = ctx.Attr<float>("shift");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

参考activation_op.cc中的ExpOpMaker, Paddle的EXP算子没有以上三个attribute,请根据Paddle算子的输入和运算逻辑进行实现。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

删除了代码中的三个attribute

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 b5ec65e into PaddlePaddle:develop Aug 11, 2021
@0x45f 0x45f deleted the add_exp_op_npu branch August 24, 2021 07:40
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