-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PIR] OneDNN Pir onednn instruction #60257
Merged
wanghuancoder
merged 58 commits into
PaddlePaddle:develop
from
wanghuancoder:pir_onednn_instruction
Dec 28, 2023
Merged
Changes from 55 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
9efacb5
onednn dialect gen
wanghuancoder 0db3ed6
merge
wanghuancoder 7555dc2
refine
wanghuancoder 7c8c581
refine
wanghuancoder 307d5fc
refine
wanghuancoder 6e4f8f8
refine
wanghuancoder 1907da1
refine
wanghuancoder 2f3f243
refine
wanghuancoder c83a066
refine
wanghuancoder 5f17461
refine
wanghuancoder 94a7cd7
refine
wanghuancoder ff94b90
refine
wanghuancoder fd4f845
refine
wanghuancoder 9987288
refine
wanghuancoder d189be9
refine
wanghuancoder 46aafd2
refine
wanghuancoder d9fa4de
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
wanghuancoder 1145d13
refine
wanghuancoder d7d9438
instruction
wanghuancoder 43a3f59
refine
wanghuancoder 53d0f0d
refine
wanghuancoder fe4ee21
refine
wanghuancoder 50d2638
refine
wanghuancoder 7711601
refine
wanghuancoder 7383d3a
refine
wanghuancoder e497a50
refine
wanghuancoder 78e3e95
merge
wanghuancoder 9804390
refine
wanghuancoder e708252
refine
wanghuancoder 387b5c0
refine
wanghuancoder 2560f7f
refine
wanghuancoder dc2fecd
refine
wanghuancoder 24b55d1
refine
wanghuancoder b2466eb
refine
wanghuancoder 3284848
refine
wanghuancoder 716894e
refine
wanghuancoder f3a8bd8
refine
wanghuancoder dcd2ade
refine
wanghuancoder bfb3b42
refine
wanghuancoder 22573ea
Merge branch 'pir_onednn' of https://github.com/wanghuancoder/Paddle …
wanghuancoder 556c194
refine
wanghuancoder 9dee464
refine
wanghuancoder 8f9fc8a
Merge branch 'pir_onednn' of https://github.com/wanghuancoder/Paddle …
wanghuancoder afdc617
refine
wanghuancoder bea4572
refine
wanghuancoder 9c97de7
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
wanghuancoder 8608d49
refine
wanghuancoder 8b7751b
merge
wanghuancoder 7a3412a
refine
wanghuancoder b5493dc
refine
wanghuancoder 43a6921
refine
wanghuancoder 6ff60e1
refine
wanghuancoder 29accca
refine
wanghuancoder 19423a8
refine
wanghuancoder d8e315f
refine
wanghuancoder 935ad92
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
wanghuancoder 8ca1f82
refine
wanghuancoder 972a8a0
refine
wanghuancoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
paddle/fluid/framework/new_executor/instruction/onednn/onednn_legacy_kernel_instruction.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// 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 "paddle/fluid/framework/new_executor/instruction/onednn/onednn_legacy_kernel_instruction.h" | ||
|
||
#include "paddle/fluid/framework/new_executor/instruction/instruction_util.h" | ||
#include "paddle/fluid/framework/new_executor/interpreter/interpreter_util.h" | ||
#include "paddle/fluid/framework/new_executor/interpreter/stream_analyzer.h" | ||
#include "paddle/fluid/framework/new_executor/pir_adaptor/pir_adaptor_util.h" | ||
#include "paddle/fluid/framework/scope.h" | ||
#include "paddle/fluid/pir/dialect/operator/interface/infermeta.h" | ||
#include "paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h" | ||
#include "paddle/fluid/pir/dialect/operator/ir/op_dialect.h" | ||
#include "paddle/fluid/pir/dialect/operator/utils/op_yaml_info_parser.h" | ||
|
||
#include "paddle/fluid/platform/device_context.h" | ||
#include "paddle/phi/core/infermeta_utils.h" | ||
#include "paddle/phi/core/meta_tensor.h" | ||
#include "paddle/phi/core/type_defs.h" | ||
|
||
namespace paddle { | ||
namespace framework { | ||
|
||
OneDNNLegacyKernelInstruction::OneDNNLegacyKernelInstruction( | ||
size_t id, | ||
const platform::Place& place, | ||
pir::Operation* op, | ||
const ValueExecutionInfo* value_exec_info) | ||
: InstructionBase(id, place), value_exec_info_(value_exec_info) { | ||
PADDLE_THROW(platform::errors::Unimplemented( | ||
"OneDNNLegacyKernelInstruction not defined now.")); | ||
} | ||
|
||
OneDNNLegacyKernelInstruction::~OneDNNLegacyKernelInstruction() {} | ||
|
||
void OneDNNLegacyKernelInstruction::Run() { | ||
PADDLE_THROW(platform::errors::Unimplemented( | ||
"OneDNNLegacyKernelInstruction not defined now.")); | ||
} | ||
} // namespace framework | ||
} // namespace paddle |
72 changes: 72 additions & 0 deletions
72
paddle/fluid/framework/new_executor/instruction/onednn/onednn_legacy_kernel_instruction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h" | ||
|
||
namespace pir { | ||
class Operation; | ||
} // namespace pir | ||
|
||
namespace paddle { | ||
namespace framework { | ||
class Scope; | ||
class ValueExecutionInfo; | ||
|
||
class OneDNNLegacyKernelInstruction : public InstructionBase { | ||
public: | ||
OneDNNLegacyKernelInstruction(size_t id, | ||
const platform::Place& place, | ||
::pir::Operation* op, | ||
const ValueExecutionInfo* value_exec_info); | ||
|
||
~OneDNNLegacyKernelInstruction(); | ||
phi::Kernel* PhiKernel() const { return phi_kernel_; } | ||
|
||
const phi::InferMetaContext& InferMetaContext() const { | ||
return infer_meta_context_; | ||
} | ||
|
||
paddle::dialect::InferMetaInterface::Concept* InferMetaInterface() const { | ||
return infer_meta_interface_; | ||
} | ||
|
||
void Run() override; | ||
|
||
const std::string& Name() const override { return legacy_op_name_; } | ||
|
||
::pir::Operation* Operation() const override { return op_; } | ||
|
||
private: | ||
std::string legacy_op_name_; | ||
|
||
paddle::dialect::InferMetaInterface::Concept* infer_meta_interface_{ | ||
nullptr}; // not owned | ||
|
||
phi::InferMetaContext infer_meta_context_; | ||
|
||
paddle::framework::ExecutionContext* kernel_context_{nullptr}; | ||
std::shared_ptr<framework::RuntimeContext> runtime_context_; | ||
std::shared_ptr<paddle::framework::OperatorBase> operator_base_; | ||
|
||
phi::Kernel* phi_kernel_{nullptr}; // not owned | ||
|
||
::pir::Operation* op_{nullptr}; // not owned | ||
|
||
const ValueExecutionInfo* value_exec_info_; // not owned | ||
}; | ||
|
||
} // namespace framework | ||
} // namespace paddle |
61 changes: 61 additions & 0 deletions
61
...le/fluid/framework/new_executor/instruction/onednn/onednn_mixed_phi_kernel_instruction.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// 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 "paddle/fluid/framework/new_executor/instruction/onednn/onednn_mixed_phi_kernel_instruction.h" | ||
|
||
#include "paddle/fluid/framework/new_executor/interpreter/interpreter_util.h" | ||
#include "paddle/fluid/framework/new_executor/interpreter/stream_analyzer.h" | ||
#include "paddle/fluid/framework/new_executor/pir_adaptor/pir_adaptor_util.h" | ||
#include "paddle/fluid/framework/scope.h" | ||
#include "paddle/fluid/pir/dialect/operator/interface/infermeta.h" | ||
#include "paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h" | ||
#include "paddle/fluid/pir/dialect/operator/ir/op_dialect.h" | ||
#include "paddle/fluid/pir/dialect/operator/utils/op_yaml_info_parser.h" | ||
#include "paddle/fluid/platform/collective_helper.h" | ||
#include "paddle/fluid/platform/device_context.h" | ||
#include "paddle/phi/core/infermeta_utils.h" | ||
#include "paddle/phi/core/meta_tensor.h" | ||
#include "paddle/phi/core/type_defs.h" | ||
|
||
#include "paddle/pir/core/builtin_attribute.h" | ||
#include "paddle/pir/core/operation.h" | ||
#include "paddle/pir/core/value.h" | ||
|
||
#include "dnnl.hpp" // NOLINT | ||
#include "paddle/fluid/framework/new_executor/instruction/instruction_util.h" | ||
#include "paddle/fluid/framework/type_defs.h" | ||
#include "paddle/fluid/ir_adaptor/translator/op_compat_info.h" | ||
#include "paddle/phi/backends/onednn/onednn_context.h" | ||
#include "paddle/phi/backends/onednn/onednn_helper.h" | ||
#include "paddle/phi/kernels/funcs/data_layout_transform.h" | ||
|
||
namespace paddle { | ||
namespace framework { | ||
|
||
OneDNNMixedPhiKernelInstruction::OneDNNMixedPhiKernelInstruction( | ||
size_t id, | ||
const platform::Place& place, | ||
pir::Operation* op, | ||
const ValueExecutionInfo* value_exec_info) | ||
: OneDNNPhiKernelInstruction(id, place, op, value_exec_info) {} | ||
|
||
void OneDNNMixedPhiKernelInstruction::Run() { | ||
// Step1. Mixed Dynamic Choose Kernel | ||
// todo if (input_tensor.layout() != phi::DataLayout::ONEDNN) | ||
|
||
OneDNNPhiKernelInstruction::Run(); | ||
} | ||
|
||
} // namespace framework | ||
} // namespace paddle |
42 changes: 42 additions & 0 deletions
42
paddle/fluid/framework/new_executor/instruction/onednn/onednn_mixed_phi_kernel_instruction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include "paddle/fluid/framework/new_executor/instruction/onednn/onednn_phi_kernel_instruction.h" | ||
|
||
namespace pir { | ||
class Operation; | ||
} // namespace pir | ||
|
||
namespace paddle { | ||
namespace framework { | ||
class Scope; | ||
class ValueExecutionInfo; | ||
|
||
using RuntimeAttribute = phi::Attribute; | ||
using PIRAttribute = pir::Attribute; | ||
|
||
class OneDNNMixedPhiKernelInstruction : public OneDNNPhiKernelInstruction { | ||
public: | ||
OneDNNMixedPhiKernelInstruction(size_t id, | ||
const platform::Place& place, | ||
::pir::Operation* op, | ||
const ValueExecutionInfo* value_exec_info); | ||
|
||
void Run() override; | ||
}; | ||
|
||
} // namespace framework | ||
} // namespace paddle |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REMOVE_ITEM支持移除多个,可以合并:https://cmake.org/cmake/help/v3.0/command/list.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!