Skip to content

Commit

Permalink
adapt Flatten kernel for new register architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanRisheng committed Oct 19, 2021
1 parent b77d1ee commit b67480c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
19 changes: 19 additions & 0 deletions paddle/fluid/operators/flatten_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,25 @@ class FlattenContiguousRangeOp : public framework::OperatorWithKernel {

return out_shape;
}

framework::KernelSignature GetExpectedPtKernelArgs(
const framework::ExecutionContext &ctx) const override {
if (ctx.HasOutput("XShape")) {
return std::make_pair(
"flatten_contiguous_range.mid",
std::make_tuple(
paddle::SmallVector<std::string>({"X"}),
paddle::SmallVector<std::string>({"start_axis", "stop_axis"}),
paddle::SmallVector<std::string>({"Out", "XShape"})));
} else {
return std::make_pair(
"flatten_contiguous_range",
std::make_tuple(
paddle::SmallVector<std::string>({"X"}),
paddle::SmallVector<std::string>({"start_axis", "stop_axis"}),
paddle::SmallVector<std::string>({"Out"})));
}
}
};

class FlattenContiguousRangeOpMaker : public FlattenOpMaker {
Expand Down
19 changes: 13 additions & 6 deletions paddle/fluid/operators/flatten_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ limitations under the License. */
#pragma once
#include <vector>
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/tcmpt_utils.h"
#include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/pooling.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/tcmpt/api/include/core.h"
#include "paddle/tcmpt/api/include/manipulation.h"

namespace paddle {
namespace operators {
Expand Down Expand Up @@ -122,13 +125,17 @@ class FlattenContiguousRangeKernel : public framework::OpKernel<T> {
void Compute(const framework::ExecutionContext &context) const override {
auto *in = context.Input<framework::LoDTensor>("X");
auto *out = context.Output<framework::LoDTensor>("Out");
auto out_dims = out->dims();

out->mutable_data(context.GetPlace(), in->type());
framework::TensorCopy(
*in, context.GetPlace(),
context.template device_context<platform::DeviceContext>(), out);
out->Resize(out_dims);
auto &start_axis = context.Attr<int>("start_axis");
auto &stop_axis = context.Attr<int>("stop_axis");
auto &dev_ctx = context.device_context<DeviceContext>();
auto pt_x = framework::MakeTensorImpl<pt::DenseTensor>(*in, in->place(),
in->type());
auto pt_out = framework::MakeTensorImpl<pt::DenseTensor>(*out, out->place(),
out->type());

// call new kernel
pt::Flatten<T>(dev_ctx, *pt_x.get(), start_axis, stop_axis, pt_out.get());
}
};

Expand Down

1 comment on commit b67480c

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on b67480c Oct 19, 2021

Choose a reason for hiding this comment

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

🕵️ CI failures summary

🔍 PR: #22 Commit ID: b67480c contains failed CI.

🔹 Failed: PR-CI-Windows

test_failed
2021-10-19 19:37:15 The following tests FAILED:
2021-10-19 19:37:15 658 - test_inplace (Failed)
2021-10-19 19:37:15 658 - test_inplace (Failed)
2021-10-19 19:37:15 658 - test_inplace (Failed)
2021-10-19 19:37:15 C:\Users\Administrator\Downloads\workspace\2d6a3973-c8a6-4ab7-83a2-0f70673c0071\Paddle\build>goto:eof
2021-10-19 19:37:15 C:\Users\Administrator\Downloads\workspace\2d6a3973-c8a6-4ab7-83a2-0f70673c0071\Paddle\build>for /F %# in ('wmic os get localdatetime|findstr 20') do set end=%#
2021-10-19 19:37:16 C:\Users\Administrator\Downloads\workspace\2d6a3973-c8a6-4ab7-83a2-0f70673c0071\Paddle\build>set end=20211019193715.984000+480
2021-10-19 19:37:16 C:\Users\Administrator\Downloads\workspace\2d6a3973-c8a6-4ab7-83a2-0f70673c0071\Paddle\build>set end=1019193715
2021-10-19 19:37:16 C:\Users\Administrator\Downloads\workspace\2d6a3973-c8a6-4ab7-83a2-0f70673c0071\Paddle\build>call :timestamp "1019181511" "1019193715" "1 card TestCases Total"
2021-10-19 19:37:16 C:\Users\Administrator\Downloads\workspace\2d6a3973-c8a6-4ab7-83a2-0f70673c0071\Paddle\build>setlocal enabledelayedexpansion
2021-10-19 19:37:16 1707311
2021-10-19 19:37:16 "Windows 1 card TestCases Total Time: 4924s"
2021-10-19 19:37:16 ipipe_log_param_Windows_1_card_TestCases_Total_Time: 4924s
2021-10-19 19:37:16 1707311
2021-10-19 19:37:16 "Windows TestCases Total Time: 4924s"
2021-10-19 19:37:16 ipipe_log_param_Windows_TestCases_Total_Time: 4924s
2021-10-19 19:37:16 Running unit tests failed, will exit
2021-10-19 19:37:20 EXCODE: 8

🔹 Failed: PR-CI-Mac-Python3

test_failed
2021-10-19 20:37:10 The following tests FAILED:
2021-10-19 20:37:10 603 - test_inplace (Failed)
2021-10-19 20:37:10 604 - test_inplace (Failed)
2021-10-19 20:37:10 + EXCODE=8
2021-10-19 20:37:10 + echo 'EXCODE: 8'
2021-10-19 20:37:10 EXCODE: 8
2021-10-19 20:37:10 + echo 'ipipe_log_param_EXCODE: 8'
2021-10-19 20:37:10 ipipe_log_param_EXCODE: 8
2021-10-19 20:37:10 + '[' 8 -eq 0 ']'
2021-10-19 20:37:10 + set +x
2021-10-19 20:37:10 Sorry, some tests failed.
2021-10-19 20:37:10 + exit 8

🔹 Failed: PR-CI-OP-benchmark

Unknown Failed
2021-10-19 21:45:40 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-10-19 21:45:40 + '[' -z flatten,flatten,flatten.json,True ']'
2021-10-19 21:45:40 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-10-19 21:45:40 + '[' -z '' ']'
2021-10-19 21:45:40 + exit_code=8
2021-10-19 21:45:40 + LOG '[ERROR] Missing test script of "fill_any_like"(paddle/fluid/operators/fill_any_like_op.cu) in benchmark.'
2021-10-19 21:45:40 + echo '[tools/test_ci_op_benchmark.sh:271] [ERROR] Missing test script of "fill_any_like"(paddle/fluid/operators/fill_any_like_op.cu) in benchmark.'
2021-10-19 21:45:40 [tools/test_ci_op_benchmark.sh:271] [ERROR] Missing test script of "fill_any_like"(paddle/fluid/operators/fill_any_like_op.cu) in benchmark.
2021-10-19 21:45:40 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-10-19 21:45:40 + '[' -z matmul,matmul,matmul.json,True ']'
2021-10-19 21:45:40 + '[' 8 -ne 0 ']'
2021-10-19 21:45:40 + LOG '[INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.'
2021-10-19 21:45:40 + echo '[tools/test_ci_op_benchmark.sh:275] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.'
2021-10-19 21:45:40 [tools/test_ci_op_benchmark.sh:275] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.
2021-10-19 21:45:40 + LOG '[INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.'
2021-10-19 21:45:40 + echo '[tools/test_ci_op_benchmark.sh:276] [INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.'
2021-10-19 21:45:40 [tools/test_ci_op_benchmark.sh:276] [INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.
2021-10-19 21:45:40 + exit 8
2021-10-19 21:45:40 {build code state=8}

🔹 Failed: PR-CI-Py3

test_failed
2021-10-20 03:03:50 The following tests FAILED:
2021-10-20 03:03:50 762 - test_inplace (Failed)
2021-10-20 03:03:50 762 - test_inplace (Failed)
2021-10-20 03:03:50 + EXCODE=8
2021-10-20 03:03:50 + echo 'EXCODE: 8'
2021-10-20 03:03:50 EXCODE: 8
2021-10-20 03:03:50 + echo 'ipipe_log_param_EXCODE: 8'
2021-10-20 03:03:50 ipipe_log_param_EXCODE: 8
2021-10-20 03:03:50 + [[ 8 -eq 0 ]]
2021-10-20 03:03:50 + set +x
2021-10-20 03:03:50 Sorry, some tests failed.
2021-10-20 03:03:50 + exit 8
2021-10-20 03:03:50 {build code state=8}

🔹 Failed: PR-CI-Coverage

test_failed
2021-10-20 03:34:43 The following tests FAILED:
2021-10-20 03:34:43 815 - test_inplace (Failed)
2021-10-20 03:34:43 815 - test_inplace (Failed)
2021-10-20 03:34:43 + EXCODE=8
2021-10-20 03:34:43 + echo 8
2021-10-20 03:34:43 8
2021-10-20 03:34:43 + echo 'ipipe_log_param_EXCODE: 8'
2021-10-20 03:34:43 ipipe_log_param_EXCODE: 8
2021-10-20 03:34:43 + '[' 8 -ne 0 ']'
2021-10-20 03:34:43 + '[' 8 -ne 9 ']'
2021-10-20 03:34:43 + exit 8
2021-10-20 03:34:43 {build code state=8}
2021-10-20 03:34:53 kill agent BUILD_CODE_FAIL

Please sign in to comment.