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

【Pten】Support data transform in C++ API #39263

Merged
merged 11 commits into from
Feb 4, 2022

Conversation

zyfncg
Copy link
Contributor

@zyfncg zyfncg commented Jan 27, 2022

PR types

New features

PR changes

Others

Describe

C++ API内部支持自动data transform

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

auto* dev_ctx = static_cast<pten::CPUContext*>(pool.Get(tensor.place()));
return pten::TransferLayout(*dev_ctx, tensor, layout);
} else {
PADDLE_THROW(platform::errors::PreconditionNotMet(
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的报错也可以改成pten::errors

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,thx

case DataType::UINT8:
return pten::Cast<uint8_t>(dev_ctx, tensor, dtype);
default:
PADDLE_THROW(platform::errors::Unimplemented(
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
Contributor Author

Choose a reason for hiding this comment

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

Done, thx

}

#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
pten::DenseTensor CastDateType(const pten::GPUContext& 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.

这里为什么需要单独重载一个函数

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GPU的Cast不支持bfloat16类型,所以单独分出来处理了

jim19930609
jim19930609 previously approved these changes Jan 29, 2022
chenwhql
chenwhql previously approved these changes Jan 29, 2022
@zyfncg zyfncg dismissed stale reviews from chenwhql and jim19930609 via 0c55f17 February 2, 2022 16:43
@zyfncg zyfncg merged commit dcff7fa into PaddlePaddle:develop Feb 4, 2022
@zyfncg zyfncg deleted the api_data_transform branch February 4, 2022 12:35
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