-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Custom Op] New custom operator extension mechanism #30690
Merged
chenwhql
merged 39 commits into
PaddlePaddle:develop
from
chenwhql:extension/new_custom_op
Feb 10, 2021
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
654b1c6
initial commit: simple demo
chenwhql de4914f
polish copyright format
chenwhql fdbe86b
add grap op simple demo
chenwhql 870cf63
adapt uncertain number of argument
chenwhql 9f80d3c
change trait marco name
chenwhql 8395c28
add place & dtype support for add kernel
chenwhql 0cd74f9
add dispath and infershape func
chenwhql 976e70a
poish code & add notes
chenwhql 5f355fc
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
chenwhql d1d0ba7
add dynamic_loader dep for paddle_framework
chenwhql 7d6a187
add new custom op test dir
chenwhql b085762
Merge branch 'extension/new_custom_op' of https://github.com/chenwhql…
chenwhql a38b373
polish impl details
chenwhql 44878a4
merge develop, resolve conflict
chenwhql ef52fb1
add unittest for new custom op
chenwhql 9d4c964
fix failed unittest
chenwhql 15a86da
Costum op (#1)
JiabinYang 4b6649f
Remove ShareData from user && Change CustomTensor to Tensor && Suppor…
JiabinYang ffdb824
refactor register design & add test
chenwhql 41aadfe
change op_funtion to op_meta_info
chenwhql 82bfa1b
split op meta info into .h and .cc
chenwhql 005f928
move get methods into friend class
chenwhql 0859385
move OpMetaInfoHelper into framework space
chenwhql 780c56a
move CustomTensorUtils into framework space
chenwhql 9bcc048
change pybind api name
chenwhql 8f6452f
move PD C API into op meta info
chenwhql cf20f1d
add register custom op api
chenwhql 6892ef5
remove inference cmake change
chenwhql f5c639d
refactor copy to api && change Reshape to lowercase && support more d…
JiabinYang 3ea5ca0
Merge branch 'extension/new_custom_op' of https://github.com/chenwhql…
chenwhql 8dc6c94
polish detail & error message
chenwhql c174345
polish test details
chenwhql e5cc53b
Add cast api && Change copy related api to copy_to && add more test (#4)
JiabinYang 222ad9c
resolve conflict
chenwhql 44811a0
fix uint8 type error
chenwhql 85d7b2c
fix lost uint8 type error
chenwhql 0c90069
add test for coverage
chenwhql e24aba2
polish details by reviewer comments
chenwhql 5d0088d
add prefix for DISABLE_COPY_AND_ASSIGN
chenwhql 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* Copyright (c) 2021 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 | ||
|
||
// All paddle apis in C++ frontend | ||
#include "paddle/fluid/extension/include/all.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,25 @@ | ||
/* Copyright (c) 2021 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 | ||
|
||
#if !defined(_MSC_VER) && __cplusplus < 199711L | ||
#error C++11 or later compatible compiler is required to use Paddle. | ||
#endif | ||
|
||
#include "paddle/fluid/extension/include/dispatch.h" | ||
#include "paddle/fluid/extension/include/dtype.h" | ||
#include "paddle/fluid/extension/include/op_meta_info.h" | ||
#include "paddle/fluid/extension/include/place.h" | ||
#include "paddle/fluid/extension/include/tensor.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,46 @@ | ||
/* Copyright (c) 2021 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/extension/include/dtype.h" | ||
|
||
namespace paddle { | ||
|
||
#define PD_PRIVATE_CASE_TYPE_USING_HINT(NAME, enum_type, type, HINT, ...) \ | ||
case enum_type: { \ | ||
using HINT = type; \ | ||
__VA_ARGS__(); \ | ||
break; \ | ||
} | ||
|
||
#define PD_PRIVATE_CASE_TYPE(NAME, enum_type, type, ...) \ | ||
PD_PRIVATE_CASE_TYPE_USING_HINT(NAME, enum_type, type, data_t, __VA_ARGS__) | ||
|
||
#define PD_DISPATCH_FLOATING_TYPES(TYPE, NAME, ...) \ | ||
[&] { \ | ||
const auto& dtype = TYPE; \ | ||
switch (dtype) { \ | ||
PD_PRIVATE_CASE_TYPE(NAME, ::paddle::DataType::FLOAT32, float, \ | ||
__VA_ARGS__) \ | ||
PD_PRIVATE_CASE_TYPE(NAME, ::paddle::DataType::FLOAT64, double, \ | ||
__VA_ARGS__) \ | ||
default: \ | ||
throw std::runtime_error("function not implemented for this type."); \ | ||
} \ | ||
}() | ||
|
||
// TODD(chenweihang): implement other DISPATH macros in next PR | ||
|
||
} // namespace paddle |
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,39 @@ | ||
/* Copyright (c) 2021 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/platform/bfloat16.h" | ||
#include "paddle/fluid/platform/complex128.h" | ||
#include "paddle/fluid/platform/complex64.h" | ||
#include "paddle/fluid/platform/float16.h" | ||
|
||
namespace paddle { | ||
|
||
enum DataType { | ||
FLOAT32, | ||
FLOAT64, | ||
BFLOAT16, | ||
COMPLEX128, | ||
COMPLEX64, | ||
FLOAT16, | ||
INT64, | ||
INT32, | ||
INT16, | ||
UINT8, | ||
INT8, | ||
BOOL, | ||
// TODO(JiabinYang) support more data types if needed. | ||
}; | ||
|
||
} // 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.
这个头文件看起来会引用一些 platform 的内部头文件,在预测发布时,需要评估下这样暴露头文件是否会有问题
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.
这里暴露的头文件是paddle底层的数据类型,包括:
为了支持完备的自定义Op,Op支持的数据类型是需要暴露的
如线下讨论的,这里可以按如下两种方式解决:
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.
好