未验证 提交 5f443601 编写于 作者: H Huang Jiyi 提交者: GitHub

[phi decoupling] move sequence_padding from fluid to phi (#50639)

* move sequence_padding to phi

* fix bugs

* fix bugs

* fix bugs

* fix bugs

* fix bugs

* fix bugs

* fix bugs

* fix bugs

* fix buga

* fix bugs

* revert and update phi::XPUContext
上级 d79d5933
......@@ -28,7 +28,6 @@ math_library(sampler DEPS generator)
# math_library(math_function DEPS blas dense_tensor tensor)
math_library(sequence_padding DEPS lod_tensor)
math_library(sequence_pooling DEPS math_function jit_kernel_helper)
if(WITH_ASCEND_CL)
math_library(beam_search DEPS math_function beam_search_npu)
......@@ -55,10 +54,6 @@ cc_test(
vol2col_test
SRCS vol2col_test.cc
DEPS vol2col)
cc_test(
sequence_padding_test
SRCS sequence_padding_test.cc
DEPS sequence_padding)
cc_test(
sequence_pooling_test
SRCS sequence_pooling_test.cc
......
......@@ -94,7 +94,7 @@ class SequencePadOp : public framework::OperatorWithKernel {
static_cast<int64_t>(x_lod_0.back())));
int seq_num = x_lod_0.size() - 1;
int max_seq_len = math::MaximumSequenceLength(x_lod_0);
int max_seq_len = phi::funcs::MaximumSequenceLength(x_lod_0);
if (padded_length == -1) {
padded_length = max_seq_len;
}
......
......@@ -18,8 +18,8 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/memory/memcpy.h"
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
namespace paddle {
namespace operators {
......@@ -45,7 +45,7 @@ class SequencePadOpKernel : public framework::OpKernel<T> {
int padded_length = ctx.Attr<int>("padded_length");
math::PaddingLoDTensorFunctor<DeviceContext, T>()(
phi::funcs::PaddingLoDTensorFunctor<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(),
*x,
out,
......@@ -53,7 +53,7 @@ class SequencePadOpKernel : public framework::OpKernel<T> {
padded_length,
0,
false,
math::kBatchLengthWidth);
phi::funcs::kBatchLengthWidth);
phi::DenseTensor seq_len;
seq_len.Resize(len_t->dims());
......@@ -80,14 +80,14 @@ class SequencePadGradOpKernel : public framework::OpKernel<T> {
int padded_length = ctx.Attr<int>("padded_length");
math::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
phi::funcs::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(),
*d_out,
d_x,
padded_length,
0,
false,
math::kBatchLengthWidth);
phi::funcs::kBatchLengthWidth);
}
}
};
......
......@@ -18,8 +18,8 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/memory/memcpy.h"
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
namespace paddle {
namespace operators {
......@@ -70,8 +70,14 @@ class SequenceUnpadOpKernel : public framework::OpKernel<T> {
out_t->mutable_data<T>(ctx.GetPlace());
int64_t padded_length = x_t->dims()[1];
math::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
dev_ctx, *x_t, out_t, padded_length, 0, false, math::kBatchLengthWidth);
phi::funcs::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
dev_ctx,
*x_t,
out_t,
padded_length,
0,
false,
phi::funcs::kBatchLengthWidth);
}
};
......@@ -93,7 +99,7 @@ class SequenceUnpadGradOpKernel : public framework::OpKernel<T> {
auto& dev_ctx = ctx.template device_context<DeviceContext>();
set_zero(dev_ctx, &zero_pads, static_cast<T>(0));
math::PaddingLoDTensorFunctor<DeviceContext, T>()(
phi::funcs::PaddingLoDTensorFunctor<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(),
*d_out,
d_x,
......@@ -101,7 +107,7 @@ class SequenceUnpadGradOpKernel : public framework::OpKernel<T> {
padded_length,
0,
false,
math::kBatchLengthWidth);
phi::funcs::kBatchLengthWidth);
}
}
};
......
......@@ -17,8 +17,7 @@ limitations under the License. */
#include "paddle/fluid/operators/sequence_ops/sequence_unpad_op.h"
namespace ops = paddle::operators;
REGISTER_OP_XPU_KERNEL(
sequence_unpad,
ops::SequenceUnpadOpKernel<paddle::platform::XPUDeviceContext, float>);
REGISTER_OP_XPU_KERNEL(sequence_unpad,
ops::SequenceUnpadOpKernel<phi::XPUContext, float>);
#endif
......@@ -23,6 +23,7 @@ math_library(softmax DEPS math_function)
math_library(maxouting)
math_library(matrix_bit_code)
math_library(sequence_scale)
math_library(sequence_padding DEPS lod_utils)
cc_library(
phi_data_layout_transform
......
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -12,18 +12,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/fluid/platform/device/device_wrapper.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
namespace phi {
class DenseTensor;
} // namespace phi
#ifdef PADDLE_WITH_XPU
#include "paddle/phi/backends/xpu/enforce_xpu.h"
#endif
namespace paddle {
namespace operators {
namespace math {
namespace phi {
namespace funcs {
template <typename T>
void CopyValidData(phi::DenseTensor* dst_tensor,
......@@ -46,7 +44,7 @@ void CopyValidData(phi::DenseTensor* dst_tensor,
PADDLE_ENFORCE_GE(
pad_seq_len,
valid_seq_len,
platform::errors::InvalidArgument(
phi::errors::InvalidArgument(
"The padded sequence length can not "
"be less than its original length. Expected %ld >= %ld, but got "
"%ld < %ld. Please check input value.",
......@@ -107,7 +105,7 @@ class PaddingLoDTensorFunctor<phi::CPUContext, T> {
bool norm_by_times = false,
const PadLayout layout = kBatchLengthWidth) {
auto seq_lod = seq_tensor.lod();
const auto seq_offsets = framework::ToAbsOffset(seq_lod)[lod_level];
const auto seq_offsets = phi::ToAbsOffset(seq_lod)[lod_level];
const auto& seq_tensor_dims = seq_tensor.dims();
const auto& pad_tensor_dims = pad_tensor->dims();
if (pad_seq_len == -1) {
......@@ -125,7 +123,7 @@ class PaddingLoDTensorFunctor<phi::CPUContext, T> {
PADDLE_ENFORCE_EQ(
pad_value.numel() == 1 || pad_value.numel() == step_width,
true,
platform::errors::InvalidArgument(
phi::errors::InvalidArgument(
"The numel of 'pad_value' can only be 1 or be equal to the "
"'step_width', but got %ld != 1 and %ld. Please check the input "
"value.",
......@@ -165,7 +163,7 @@ class UnpaddingLoDTensorFunctor<phi::CPUContext, T> {
int lod_level = 0,
bool norm_by_times = false,
const PadLayout layout = kBatchLengthWidth) {
auto seq_offsets = framework::ToAbsOffset(seq_tensor->lod())[lod_level];
auto seq_offsets = phi::ToAbsOffset(seq_tensor->lod())[lod_level];
const auto& seq_tensor_dims = seq_tensor->dims();
const auto& pad_tensor_dims = pad_tensor.dims();
if (pad_seq_len == -1) {
......@@ -193,16 +191,16 @@ class UnpaddingLoDTensorFunctor<phi::CPUContext, T> {
#ifdef PADDLE_WITH_XPU
template <typename T>
class UnpaddingLoDTensorFunctor<platform::XPUDeviceContext, T> {
class UnpaddingLoDTensorFunctor<phi::XPUContext, T> {
public:
void operator()(const platform::XPUDeviceContext& context,
void operator()(const phi::XPUContext& context,
const phi::DenseTensor& pad_tensor,
phi::DenseTensor* seq_tensor,
int pad_seq_len = -1,
int lod_level = 0,
bool norm_by_times = false,
const PadLayout layout = kBatchLengthWidth) {
auto seq_offsets = framework::ToAbsOffset(seq_tensor->lod())[lod_level];
auto seq_offsets = phi::ToAbsOffset(seq_tensor->lod())[lod_level];
const auto& seq_tensor_dims = seq_tensor->dims();
const auto& pad_tensor_dims = pad_tensor.dims();
if (pad_seq_len == -1) {
......@@ -246,9 +244,8 @@ template class UnpaddingLoDTensorFunctor<phi::CPUContext, float>;
template class UnpaddingLoDTensorFunctor<phi::CPUContext, double>;
#ifdef PADDLE_WITH_XPU
template class UnpaddingLoDTensorFunctor<platform::XPUDeviceContext, float>;
template class UnpaddingLoDTensorFunctor<phi::XPUContext, float>;
#endif
} // namespace math
} // namespace operators
} // namespace paddle
} // namespace funcs
} // namespace phi
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -14,12 +14,11 @@ limitations under the License. */
#include <algorithm>
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
namespace paddle {
namespace operators {
namespace math {
namespace phi {
namespace funcs {
template <typename T, CopyType Type>
__global__ void SequencePaddingKernel(T* dst,
......@@ -69,7 +68,7 @@ class PaddingLoDTensorFunctor<phi::GPUContext, T> {
bool norm_by_times = false,
const PadLayout layout = kBatchLengthWidth) {
auto seq_lod = seq_tensor.lod();
auto seq_offsets = framework::ToAbsOffset(seq_lod)[lod_level];
auto seq_offsets = phi::ToAbsOffset(seq_lod)[lod_level];
const auto& seq_tensor_dims = seq_tensor.dims();
const auto& pad_tensor_dims = pad_tensor->dims();
int max_seq_len = MaximumSequenceLength(seq_offsets);
......@@ -79,7 +78,7 @@ class PaddingLoDTensorFunctor<phi::GPUContext, T> {
PADDLE_ENFORCE_GE(
pad_seq_len,
max_seq_len,
platform::errors::InvalidArgument(
phi::errors::InvalidArgument(
"The pad_seq_len must be equal to or greater than the "
"original max sequence length. Expected %ld >= %ld, but got %ld < "
"%ld. Please check the input value.",
......@@ -99,7 +98,7 @@ class PaddingLoDTensorFunctor<phi::GPUContext, T> {
PADDLE_ENFORCE_EQ(
pad_value.numel() == 1 || pad_value.numel() == step_width,
true,
platform::errors::InvalidArgument(
phi::errors::InvalidArgument(
"The numel of 'pad_value' can only be 1 or be equal to "
"the 'step_width', but got %ld != 1 and %ld. Please check the "
"input value.",
......@@ -149,7 +148,7 @@ class UnpaddingLoDTensorFunctor<phi::GPUContext, T> {
int lod_level = 0,
bool norm_by_times = false,
const PadLayout layout = kBatchLengthWidth) {
auto seq_offsets = framework::ToAbsOffset(seq_tensor->lod())[lod_level];
auto seq_offsets = phi::ToAbsOffset(seq_tensor->lod())[lod_level];
const auto& seq_tensor_dims = seq_tensor->dims();
const auto& pad_tensor_dims = pad_tensor.dims();
int max_seq_len = MaximumSequenceLength(seq_offsets);
......@@ -216,6 +215,5 @@ template class UnpaddingLoDTensorFunctor<phi::GPUContext, int64_t>;
template class UnpaddingLoDTensorFunctor<phi::GPUContext, float>;
template class UnpaddingLoDTensorFunctor<phi::GPUContext, double>;
} // namespace math
} // namespace operators
} // namespace paddle
} // namespace funcs
} // namespace phi
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -17,12 +17,13 @@ limitations under the License. */
#include <algorithm>
#include <vector>
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/lod_utils.h"
#include "paddle/phi/core/mixed_vector.h"
namespace paddle {
namespace operators {
namespace math {
namespace phi {
namespace funcs {
enum PadLayout { kBatchLengthWidth = 0, kLengthBatchWidth };
......@@ -130,6 +131,5 @@ class UnpaddingLoDTensorFunctor {
const PadLayout layout = kBatchLengthWidth);
};
} // namespace math
} // namespace operators
} // namespace paddle
} // namespace funcs
} // namespace phi
......@@ -16,12 +16,12 @@
#include <vector>
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/phi/backends/dynload/warpctc.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/kernels/empty_kernel.h"
#include "paddle/phi/kernels/funcs/eigen/common.h"
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
#include "paddle/phi/kernels/funcs/sequence_scale.h"
#include "paddle/utils/optional.h"
......@@ -69,14 +69,14 @@ void WarpctcGradKernel(const Context& dev_ctx,
logits_grad_e.device(*place) = logits_g;
}
} else {
paddle::operators::math::UnpaddingLoDTensorFunctor<Context, T>()(
phi::funcs::UnpaddingLoDTensorFunctor<Context, T>()(
dev_ctx,
warpctcgrad,
logits_grad,
-1,
0,
norm_by_times,
paddle::operators::math::kLengthBatchWidth);
phi::funcs::kLengthBatchWidth);
const T* loss_grad_data = loss_grad.data<T>();
phi::funcs::ScaleLoDTensorFunctor<Context, T>()(
......
......@@ -16,13 +16,13 @@
#include <vector>
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/phi/backends/dynload/warpctc.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/lod_utils.h"
#include "paddle/phi/core/tensor_utils.h"
#include "paddle/phi/kernels/empty_kernel.h"
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
#include "paddle/phi/kernels/funcs/sequence_scale.h"
#include "paddle/utils/optional.h"
......@@ -333,8 +333,7 @@ void WarpctcKernel(const Context& dev_ctx,
num_sequences));
sequence_width = logits.numel() / logits_dims[0];
max_sequence_length =
paddle::operators::math::MaximumSequenceLength(logits_lod);
max_sequence_length = phi::funcs::MaximumSequenceLength(logits_lod);
}
auto loss_dims = phi::make_ddim({static_cast<int64_t>(num_sequences), 1});
......@@ -361,7 +360,7 @@ void WarpctcKernel(const Context& dev_ctx,
phi::Copy(dev_ctx, cpu_pad_value, dev_ctx.GetPlace(), true, &pad_value);
}
paddle::operators::math::PaddingLoDTensorFunctor<Context, T>()(
phi::funcs::PaddingLoDTensorFunctor<Context, T>()(
dev_ctx,
logits,
&warpctc_logits,
......@@ -369,7 +368,7 @@ void WarpctcKernel(const Context& dev_ctx,
-1,
0,
false /* norm_by_times */,
paddle::operators::math::kLengthBatchWidth);
phi::funcs::kLengthBatchWidth);
}
const T* warpctc_logits_data = warpctc_logits.data<T>();
......@@ -394,39 +393,36 @@ void WarpctcKernel(const Context& dev_ctx,
DenseTensor warpctc_label;
if (logits_length.is_initialized()) {
warpctc_label.Resize(
{static_cast<int64_t>(
paddle::operators::math::TotalSequenceLength(label_lod)),
1});
{static_cast<int64_t>(phi::funcs::TotalSequenceLength(label_lod)), 1});
dev_ctx.template HostAlloc<int>(&warpctc_label);
std::vector<phi::Vector<size_t>> lod;
lod.push_back(label_lod);
warpctc_label.set_lod(lod);
if (dev_ctx.GetPlace() == phi::CPUPlace()) {
paddle::operators::math::UnpaddingLoDTensorFunctor<Context, int>()(
phi::funcs::UnpaddingLoDTensorFunctor<Context, int>()(
dev_ctx,
label,
&warpctc_label,
label.dims()[1] /*pad_seq_len*/,
0 /*lod_level*/,
false /*norm_by_times*/,
paddle::operators::math::kBatchLengthWidth);
phi::funcs::kBatchLengthWidth);
} else {
DenseTensor gpu_label;
gpu_label.Resize(
{static_cast<int64_t>(
paddle::operators::math::TotalSequenceLength(label_lod)),
{static_cast<int64_t>(phi::funcs::TotalSequenceLength(label_lod)),
1});
dev_ctx.template Alloc<int>(&gpu_label);
gpu_label.set_lod(lod);
paddle::operators::math::UnpaddingLoDTensorFunctor<Context, int>()(
phi::funcs::UnpaddingLoDTensorFunctor<Context, int>()(
dev_ctx,
label,
&gpu_label,
label.dims()[1] /*pad_seq_len*/,
0 /*lod_level*/,
false /*norm_by_times*/,
paddle::operators::math::kBatchLengthWidth);
phi::funcs::kBatchLengthWidth);
phi::Copy(dev_ctx, gpu_label, phi::CPUPlace(), true, &warpctc_label);
}
} else {
......
......@@ -100,3 +100,8 @@ cc_test(
strided_memcpy_test
SRCS strided_memcpy_test.cc
DEPS device_context memory)
cc_test(
sequence_padding_test
SRCS sequence_padding_test.cc
DEPS sequence_padding)
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -11,13 +11,15 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <gtest/gtest.h>
#include "paddle/fluid/operators/math/sequence_padding.h"
#include "paddle/phi/kernels/funcs/sequence_padding.h"
#include "paddle/phi/core/tensor_utils.h"
#include <gtest/gtest.h>
template <typename DeviceContext, typename T>
void TestSequencePadding(const DeviceContext &context,
const paddle::framework::LoD &lod,
const phi::LoD &lod,
const size_t sequence_width) {
phi::DenseTensor cpu_seq;
phi::DenseTensor cpu_seq_back;
......@@ -32,38 +34,43 @@ void TestSequencePadding(const DeviceContext &context,
static_cast<int64_t>(sequence_width)});
cpu_seq.set_lod(lod);
cpu_seq.mutable_data<T>(seq_dims, paddle::platform::CPUPlace());
auto *dev_ctx = static_cast<phi::CPUContext *>(
paddle::platform::DeviceContextPool::Instance().Get(phi::CPUPlace()));
cpu_seq.Resize(seq_dims);
dev_ctx->template Alloc<T>(&cpu_seq);
for (int64_t i = 0; i < cpu_seq.numel(); ++i) {
cpu_seq.data<T>()[i] = static_cast<T>(i);
}
auto place = context.GetPlace();
if (paddle::platform::is_cpu_place(place)) {
if (place.GetType() == phi::AllocationType::CPU) {
seq = cpu_seq;
} else {
paddle::framework::TensorCopySync(cpu_seq, place, &seq);
phi::Copy(context, cpu_seq, place, true, &seq);
seq.set_lod(lod);
}
const size_t max_sequence_length =
paddle::operators::math::MaximumSequenceLength(lod[level]);
phi::funcs::MaximumSequenceLength(lod[level]);
const size_t num_sequences = lod[level].size() - 1;
auto padding_dims = phi::make_ddim({static_cast<int64_t>(max_sequence_length),
static_cast<int64_t>(num_sequences),
static_cast<int64_t>(sequence_width)});
padding.mutable_data<T>(padding_dims, place);
padding.Resize(padding_dims);
context.template Alloc<T>(&padding);
T *pad_value_data =
cpu_pad_value.mutable_data<T>({1}, paddle::platform::CPUPlace());
cpu_pad_value.Resize({1});
T *pad_value_data = dev_ctx->template Alloc<T>(&cpu_pad_value);
*pad_value_data = static_cast<T>(0);
if (paddle::platform::is_cpu_place(place)) {
if (place.GetType() == phi::AllocationType::CPU) {
pad_value = cpu_pad_value;
} else {
paddle::framework::TensorCopySync(cpu_pad_value, place, &pad_value);
phi::Copy(context, cpu_pad_value, place, true, &pad_value);
}
paddle::operators::math::PaddingLoDTensorFunctor<DeviceContext, T>()(
phi::funcs::PaddingLoDTensorFunctor<DeviceContext, T>()(
context,
seq,
&padding,
......@@ -71,24 +78,18 @@ void TestSequencePadding(const DeviceContext &context,
-1,
0,
false,
paddle::operators::math::kLengthBatchWidth);
phi::funcs::kLengthBatchWidth);
seq_back.set_lod(lod);
seq_back.mutable_data<T>(seq_dims, place);
paddle::operators::math::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
context,
padding,
&seq_back,
-1,
0,
false,
paddle::operators::math::kLengthBatchWidth);
seq_back.Resize(seq_dims);
context.template Alloc<T>(&seq_back);
phi::funcs::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
context, padding, &seq_back, -1, 0, false, phi::funcs::kLengthBatchWidth);
if (paddle::platform::is_cpu_place(place)) {
if (place.GetType() == phi::AllocationType::CPU) {
cpu_seq_back = seq_back;
} else {
paddle::framework::TensorCopySync(
seq_back, paddle::platform::CPUPlace(), &cpu_seq_back);
phi::Copy(context, seq_back, phi::CPUPlace(), true, &cpu_seq_back);
cpu_seq_back.set_lod(lod);
}
......@@ -100,15 +101,15 @@ void TestSequencePadding(const DeviceContext &context,
}
TEST(Seq2BatchPadding, CPU) {
auto place = paddle::platform::CPUPlace();
auto place = phi::CPUPlace();
auto *context = static_cast<phi::CPUContext *>(
paddle::platform::DeviceContextPool::Instance().Get(place));
paddle::framework::LoD lod1;
phi::LoD lod1;
lod1.push_back(std::vector<size_t>{0, 10});
TestSequencePadding<phi::CPUContext, float>(*context, lod1, 16);
paddle::framework::LoD lod2;
phi::LoD lod2;
lod2.push_back(std::vector<size_t>{0, 2, 7, 10});
TestSequencePadding<phi::CPUContext, float>(*context, lod2, 128);
}
......@@ -119,11 +120,11 @@ TEST(SequencePadding, CUDA) {
auto *context = static_cast<phi::GPUContext *>(
paddle::platform::DeviceContextPool::Instance().Get(place));
paddle::framework::LoD lod1;
phi::LoD lod1;
lod1.push_back(std::vector<size_t>{0, 10});
TestSequencePadding<phi::GPUContext, float>(*context, lod1, 16);
paddle::framework::LoD lod2;
phi::LoD lod2;
lod2.push_back(std::vector<size_t>{0, 2, 7, 10});
TestSequencePadding<phi::GPUContext, float>(*context, lod2, 128);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册