未验证 提交 5607bcf2 编写于 作者: C Chen Weihang 提交者: GitHub

fix reshape async copy error (#37595)

上级 04e3b62f
...@@ -376,13 +376,15 @@ class ReshapeKernel { ...@@ -376,13 +376,15 @@ class ReshapeKernel {
// framework::DDim out_dims = out->dims(); // framework::DDim out_dims = out->dims();
auto pt_x = paddle::experimental::MakePtenDenseTensor(*in); auto pt_x = paddle::experimental::MakePtenDenseTensor(*in);
// we can't MakePtenDenseTensor by out, because reshape will realloc memory // we can't MakePtenDenseTensor by out, because the out of reshape may have
// and this will throw error(can't realloc shared memory) in current // multiple states, some can MakePtenDenseTensor but other's cannot:
// DenseTensor // 1. out tensor is not initialized
// design. So, codes below create a tmp densetensor for output. // 2. out tensor is input (complete inplace)
// TODO(YuanRisheng) we can use MakePtenDenseTensor after #36916 merge. // 3. out tensor is view of input
// We can't MakePtenDenseTensor for case 2, so we solve this case by
// creating a temporary tensor here:
const auto alloc = std::make_shared<paddle::experimental::DefaultAllocator>( const auto alloc = std::make_shared<paddle::experimental::DefaultAllocator>(
paddle::platform::CPUPlace()); ctx.GetPlace());
pten::DenseTensorMeta meta{pten::TransToPtenDataType(in->type()), pten::DenseTensorMeta meta{pten::TransToPtenDataType(in->type()),
in->dims(), in->dims(),
pten::TransToPtenDataLayout(in->layout())}; pten::TransToPtenDataLayout(in->layout())};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册