-
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
[Move selected_rows PR #5] VisitDataType use Pten::DataType #39236
Merged
veyron95
merged 25 commits into
PaddlePaddle:develop
from
veyron95:fluid_move_selected_rows_to_pten_5
Jan 26, 2022
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f533aa0
Added selected_rows and rw_lock to pten
veyron95 832e903
Renamed the unit test target to fix CI
veyron95 318ef67
Removed Class SelectedRows in Fluid, changed include/cmake relationsh…
veyron95 40f635d
Remove rw_lock.h,rw_lock_test.cc in fluid
veyron95 aa5d93f
Use pten::RWLock and pten::AutoRDLock, fix CI
veyron95 8c51888
Use pten::SelectedRows
veyron95 15328f3
Use pten::SelectedRows
veyron95 7416f99
Fix to pass NPU CI
veyron95 794f7ef
Merge commit 'refs/pull/39128/head' of https://github.com/PaddlePaddl…
veyron95 4511b17
Merge branch 'develop' into fluid_move_selected_rows_to_pten_3
veyron95 47e3ccb
Selected_Rows inherits from TensorBase
veyron95 7afa032
Fix conflict
veyron95 3942e0f
Use pten::SelectedRows, to pass NPU CI
veyron95 75de13d
To fix NPU CI
veyron95 c650f51
Merge commit 'refs/pull/39128/head' of https://github.com/PaddlePaddl…
veyron95 d241507
To fix NPU CI again
veyron95 ef71e4a
Merge commit 'refs/pull/39128/head' of https://github.com/PaddlePaddl…
veyron95 51b0f24
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
veyron95 ef79f84
Use paddle/pten/core/enforce and polish code
veyron95 d815960
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
veyron95 ccd0e78
Use pten::DataType instead of using proto_type
veyron95 835330e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
veyron95 5397c54
Move part of data_type to pten
veyron95 8e61902
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
veyron95 53db5d3
Polish Code
veyron95 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* Copyright (c) 2022 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 <iostream> | ||
#include <string> | ||
#include <typeindex> | ||
|
||
#include "paddle/pten/common/data_type.h" | ||
#include "paddle/pten/core/enforce.h" | ||
#include "paddle/pten/kernels/funcs/eigen/extensions.h" | ||
|
||
namespace pten { | ||
|
||
#define _PtenForEachDataTypeHelper_(callback, cpp_type, data_type) \ | ||
callback(cpp_type, data_type); | ||
|
||
#define _PtenForEachDataType_(callback) \ | ||
_PtenForEachDataTypeHelper_(callback, float, DataType::FLOAT32); \ | ||
_PtenForEachDataTypeHelper_( \ | ||
callback, ::paddle::platform::float16, DataType::FLOAT16); \ | ||
_PtenForEachDataTypeHelper_( \ | ||
callback, ::paddle::platform::bfloat16, DataType::BFLOAT16); \ | ||
_PtenForEachDataTypeHelper_(callback, double, DataType::FLOAT64); \ | ||
_PtenForEachDataTypeHelper_(callback, int, DataType::INT32); \ | ||
_PtenForEachDataTypeHelper_(callback, int64_t, DataType::INT64); \ | ||
_PtenForEachDataTypeHelper_(callback, bool, DataType::BOOL); \ | ||
_PtenForEachDataTypeHelper_(callback, uint8_t, DataType::UINT8); \ | ||
_PtenForEachDataTypeHelper_(callback, int16_t, DataType::INT16); \ | ||
_PtenForEachDataTypeHelper_(callback, int8_t, DataType::INT8); \ | ||
_PtenForEachDataTypeHelper_( \ | ||
callback, ::paddle::platform::complex<float>, DataType::COMPLEX64); \ | ||
_PtenForEachDataTypeHelper_( \ | ||
callback, ::paddle::platform::complex<double>, DataType::COMPLEX128); | ||
|
||
template <typename Visitor> | ||
inline void VisitDataType(pten::DataType type, Visitor visitor) { | ||
#define PtenVisitDataTypeCallback(cpp_type, data_type) \ | ||
do { \ | ||
if (type == data_type) { \ | ||
visitor.template apply<cpp_type>(); \ | ||
return; \ | ||
} \ | ||
} while (0) | ||
|
||
_PtenForEachDataType_(PtenVisitDataTypeCallback); | ||
#undef PtenVisitDataTypeCallback | ||
PADDLE_THROW(pten::errors::Unimplemented( | ||
"Not supported proto::VarType::Type(%d) as data type.", | ||
static_cast<int>(type))); | ||
} | ||
} // namespace pten |
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.
同步一下,这个VisitDataType我们认为写得不是很直观,之前讨论过说希望用switch-case的形式替换掉的,参考pten/api/ext/dispatch.h,不过短时间内好像也比较困难;
此外,后续如果还是有其他kernel使用,我们可能会考虑把这段实现直接放到common/data_type.h中
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.
好的,后续再替换或者进一步优化,多谢。