未验证 提交 698b8b73 编写于 作者: Z Zhang Ting 提交者: GitHub

optimize lod_reset op to avoid data transform

上级 f0b15184
......@@ -14,6 +14,7 @@ limitations under the License. */
#include "paddle/fluid/operators/lod_reset_op.h"
#include <memory>
#include <string>
namespace paddle {
namespace operators {
......@@ -50,6 +51,14 @@ class LoDResetOp : public framework::OperatorWithKernel {
OperatorWithKernel::IndicateVarDataType(ctx, "X"),
ctx.device_context());
}
framework::OpKernelType GetKernelTypeForVar(
const std::string &var_name, const framework::Tensor &tensor,
const framework::OpKernelType &expected_kernel_type) const override {
return framework::OpKernelType(expected_kernel_type.data_type_,
expected_kernel_type.place_,
tensor.layout());
}
};
class LoDResetOpVarTypeInference : public framework::VarTypeInference {
......
......@@ -45,7 +45,7 @@ class LoDResetKernel : public framework::OpKernel<T> {
return; // early return, since lod already set
} else {
auto* lod = lod_t->data<int>();
if (platform::is_gpu_place(ctx.GetPlace())) {
if (platform::is_gpu_place(lod_t->place())) {
framework::Tensor lod_cpu;
framework::TensorCopySync(*lod_t, platform::CPUPlace(), &lod_cpu);
lod = lod_cpu.data<int>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册