-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PIR]Support custom op in PIR (#59790)
* support custom op in pir * fix compile bugs * fix bugs * delete code * fix windows bugs * fix windows bugs * add symbol to paddle lib * fix windows bugs * revert code * fix bugs * fix bugs * perfect code according comment * fix py3 * revert third party * fix bugs * fix bug * fix compile bugs * fix windows
- Loading branch information
1 parent
7c7446f
commit cfad7d2
Showing
32 changed files
with
1,624 additions
and
258 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
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 | ||
|
||
inline void HashCombine(std::size_t* seed) {} | ||
|
||
// combine hash value | ||
// https://stackoverflow.com/questions/2590677/how-do-i-combine-hash-values-in-c0x | ||
template <typename T, typename... Rest> | ||
inline void HashCombine(std::size_t* seed, const T& v, Rest... rest) { | ||
std::hash<T> hasher; | ||
*seed ^= hasher(v) + 0x9e3779b9 + (*seed << 6) + (*seed >> 2); | ||
*seed *= 0x00000100000001B3; | ||
HashCombine(seed, rest...); | ||
} | ||
|
||
// custom specialization of std::hash can be injected in namespace std | ||
// ref: https://en.cppreference.com/w/cpp/utility/hash | ||
namespace std { | ||
template <typename T> | ||
struct hash<std::vector<T>> { | ||
std::size_t operator()(std::vector<T> const& vec) const noexcept { | ||
std::size_t seed = 0xcbf29ce484222325; | ||
for (auto val : vec) { | ||
HashCombine(&seed, val); | ||
} | ||
return seed; | ||
} | ||
}; | ||
} // namespace std |
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
Oops, something went wrong.