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

Optimize the calling logic of the cast and cast_grad kernels to reduce compilation size #57083

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

AnnaTrainingG
Copy link
Contributor

@AnnaTrainingG AnnaTrainingG commented Sep 7, 2023

PR types

Others

PR changes

Others

Description

Pcard-70459
compile test 4.1
体积变化:
image

@paddle-bot
Copy link

paddle-bot bot commented Sep 7, 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.

CastCUDAKernelImpl<T, data_t>(
dev_ctx, out_grad, x_grad->dtype(), x_grad);
}));
CastImpl<T, Context>(dev_ctx, out_grad, x_grad->dtype(), x_grad);
Copy link
Contributor

Choose a reason for hiding this comment

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

这样还是会编译2份吧?能直接调phi::CastKernel吗?

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

}

template <typename T, typename Context>
void CastKernel(const Context& dev_ctx,
Copy link
Contributor

Choose a reason for hiding this comment

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

CastKernel实现不用挪到头文件中,在cast_kernel.cu里面实现就行,cast_grad_kernel.cu里面只需include cast_kernel.h

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

@AnnaTrainingG AnnaTrainingG force-pushed the compile_4_1 branch 2 times, most recently from 3dc24d2 to e55c537 Compare September 13, 2023 05:36
CastCUDAKernelImpl<T, data_t>(
dev_ctx, out_grad, x_grad->dtype(), x_grad);
}));
CastKernel<T, Context>(dev_ctx, out_grad, x_grad->dtype(), x_grad);
Copy link
Contributor

Choose a reason for hiding this comment

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

我觉得这里传x.dtype()比较合适。x_grad是输出,其实它的数据类型在Alloc之前是没有确定的,后面也会重置(cast_impl.h里面的第39行out->set_type(out_dtype);)。

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

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

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

LGTM

@AnnaTrainingG AnnaTrainingG changed the title compile test 4.1 Optimize the calling logic of the cast and cast_grad kernels to reduce compilation size Sep 15, 2023
@AnnaTrainingG AnnaTrainingG merged commit b9ee842 into PaddlePaddle:develop Sep 15, 2023
27 checks passed
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
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