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

[XPU][Phi Kernel] nonzero kernel support simulator XPUSIM_SKIP_RUN mode #60224

Merged

Conversation

dynamicheart
Copy link
Contributor

@dynamicheart dynamicheart commented Dec 21, 2023

PR types

New features

PR changes

OPs

Description

nonzero kernel support simulator XPUSIM_SKIP_RUN mode.

In the simulator mode, the variable true_num_cpu stores an uninitialized value. To avoid allocating a memory of random size, we assign numel to it.

Copy link

paddle-bot bot commented Dec 21, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@dynamicheart dynamicheart force-pushed the xpu_nonzero_simulator_skip_run_mode branch from 3f1e56b to ad55026 Compare December 21, 2023 09:07
@@ -40,6 +42,13 @@ void NonZeroKernel(const Context& dev_ctx,
dev_ctx.GetPlace(),
static_cast<void*>(true_num),
sizeof(int32_t));
if (std::getenv("XPU_SIMULATOR_MODE") && std::getenv("XPUSIM_SKIP_RUN") &&
Copy link
Contributor Author

@dynamicheart dynamicheart Dec 21, 2023

Choose a reason for hiding this comment

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

备注:驱动里面仅判断std::getenv("XPU_SIMULATOR_MODE"),模拟器将XPUSIM_SKIP_RUN的值转成bool来进行判断。

Copy link
Contributor

@runzhech runzhech left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@houj04 houj04 left a comment

Choose a reason for hiding this comment

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

代码看起来没问题。但是缺个单测。
不知道好不好写?如果在单测里面刷环境变量,但是CI环境下面又没有模拟器,可能导致一些奇怪的情况出现。

@dynamicheart
Copy link
Contributor Author

代码看起来没问题。但是缺个单测。 不知道好不好写?如果在单测里面刷环境变量,但是CI环境下面又没有模拟器,可能导致一些奇怪的情况出现。

加了几个单测,由于CI环境里面要测到新增代码里面分支,因此要把XPU_SIMULATOR_MODE环境变量的判断去掉,并且把true_num_cpu的取值限定在0<=true_num_cpu<numel之间。或者可以直接去掉环境变量的判断,直接对true_num_cpu进行clip。

@dynamicheart dynamicheart force-pushed the xpu_nonzero_simulator_skip_run_mode branch from 161be2f to dd77073 Compare December 22, 2023 09:44
@houj04 houj04 merged commit b8113f2 into PaddlePaddle:develop Dec 25, 2023
Wanglongzhi2001 pushed a commit to Wanglongzhi2001/Paddle that referenced this pull request Jan 7, 2024
…de (PaddlePaddle#60224)

* [XPU][Phi Kernel] nonzero kernel support simulator XPUSIM_SKIP_RUN mode

* [XPU][Phi Kernel] add unittest for nonzero simulator skip_run mode
@houj04 houj04 added the XPU label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants