forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ddle#39236) * Added selected_rows and rw_lock to pten * Renamed the unit test target to fix CI * Removed Class SelectedRows in Fluid, changed include/cmake relationship, use pten::SelectedRows in Fluid * Remove rw_lock.h,rw_lock_test.cc in fluid * Use pten::RWLock and pten::AutoRDLock, fix CI * Use pten::SelectedRows * Use pten::SelectedRows * Fix to pass NPU CI * Selected_Rows inherits from TensorBase * Use pten::SelectedRows, to pass NPU CI * To fix NPU CI * To fix NPU CI again * Use paddle/pten/core/enforce and polish code * Use pten::DataType instead of using proto_type * Move part of data_type to pten * Polish Code
- Loading branch information
Showing
2 changed files
with
72 additions
and
11 deletions.
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
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 |