Skip to content

Commit

Permalink
remove -1 device in host kernels (#8299)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhupengyang authored Jan 26, 2022
1 parent 10255a4 commit e567783
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 184 deletions.
285 changes: 171 additions & 114 deletions lite/kernels/host/compare_compute.cc

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions lite/kernels/host/fetch_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ class FetchCompute
REGISTER_LITE_KERNEL(
fetch, kHost, kAny, kAny, paddle::lite::kernels::host::FetchCompute, def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.Finalize();
15 changes: 9 additions & 6 deletions lite/kernels/host/flatten_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ REGISTER_LITE_KERNEL(flatten_contiguous_range,
paddle::lite::kernels::host::FlattenContiguousRangeCompute,
def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("XShape",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.Finalize();
10 changes: 6 additions & 4 deletions lite/kernels/host/shape_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ void ShapeCompute::Run() {
REGISTER_LITE_KERNEL(
shape, kHost, kAny, kAny, paddle::lite::kernels::host::ShapeCompute, def)
.BindInput("Input",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.Finalize();
25 changes: 15 additions & 10 deletions lite/kernels/host/squeeze_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ REGISTER_LITE_KERNEL(squeeze,
paddle::lite::kernels::host::SqueezeCompute,
def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.Finalize();

REGISTER_LITE_KERNEL(squeeze2,
Expand All @@ -59,12 +61,15 @@ REGISTER_LITE_KERNEL(squeeze2,
paddle::lite::kernels::host::SqueezeCompute,
def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("XShape",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.Finalize();
30 changes: 18 additions & 12 deletions lite/kernels/host/stack_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,37 @@ using stack_float =
paddle::lite::kernels::host::StackCompute<float, PRECISION(kFloat)>;
REGISTER_LITE_KERNEL(stack, kHost, kFloat, kAny, stack_float, def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kFloat), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kFloat),
DATALAYOUT(kAny))})
.BindOutput("Y",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kFloat), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kFloat),
DATALAYOUT(kAny))})
.Finalize();

using stack_int32 =
paddle::lite::kernels::host::StackCompute<int, PRECISION(kFloat)>;
REGISTER_LITE_KERNEL(stack, kHost, kFloat, kAny, stack_int32, int32_def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindOutput("Y",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.Finalize();

using stack_int64 =
paddle::lite::kernels::host::StackCompute<int64_t, PRECISION(kFloat)>;
REGISTER_LITE_KERNEL(stack, kHost, kFloat, kAny, stack_int64, int64_def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt64), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt64),
DATALAYOUT(kAny))})
.BindOutput("Y",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt64), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt64),
DATALAYOUT(kAny))})
.Finalize();
20 changes: 12 additions & 8 deletions lite/kernels/host/unique_with_counts_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,19 @@ REGISTER_LITE_KERNEL(unique_with_counts,
paddle::lite::kernels::host::UniqueWithCountsCompute,
def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("Index",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindOutput("Count",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.Finalize();
45 changes: 27 additions & 18 deletions lite/kernels/host/unsqueeze_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ REGISTER_LITE_KERNEL(unsqueeze,
paddle::lite::kernels::host::UnsqueezeCompute,
def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindInput("AxesTensor",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindInput("AxesTensorList",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.Finalize();

REGISTER_LITE_KERNEL(unsqueeze2,
Expand All @@ -66,18 +70,23 @@ REGISTER_LITE_KERNEL(unsqueeze2,
paddle::lite::kernels::host::UnsqueezeCompute,
def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindInput("AxesTensor",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindInput("AxesTensorList",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindOutput("Out",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.BindOutput("XShape",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kAny), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kAny),
DATALAYOUT(kAny))})
.Finalize();
20 changes: 12 additions & 8 deletions lite/kernels/host/unstack_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,24 @@ using unstack_float =
paddle::lite::kernels::host::UnstackCompute<float, PRECISION(kFloat)>;
REGISTER_LITE_KERNEL(unstack, kHost, kFloat, kAny, unstack_float, def)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kFloat), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kFloat),
DATALAYOUT(kAny))})
.BindOutput("Y",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kFloat), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kFloat),
DATALAYOUT(kAny))})
.Finalize();

using unstack_int32 =
paddle::lite::kernels::host::UnstackCompute<int32_t, PRECISION(kFloat)>;
REGISTER_LITE_KERNEL(unstack, kHost, kFloat, kAny, unstack_int32, unstack_int32)
.BindInput("X",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.BindOutput("Y",
{LiteType::GetTensorTy(
TARGET(kHost), PRECISION(kInt32), DATALAYOUT(kAny), -1)})
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt32),
DATALAYOUT(kAny))})
.Finalize();

0 comments on commit e567783

Please sign in to comment.