-
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.
* [cherry-pick2.3]fix compile bug of windows cuda11.5 (#41464) cherry-pick fix compile bug of windows cuda11.5 #41433 * fix bug of missing boost when compile cache.cc (#41449) 【chery-pick #41430】fix bug of random compile failure, due to incorrect compile order of dependencies * Fix eager try catch (#41438) (#41477) [Cherry-Pick]Fix eager try catch (#41438) * Cherry-pick-PR41407, fix device_id bug for final_state op in multiprocess testcase (#41407) (#41475) Cherry-pick PR #41407 * [BugFix] Add error hint for one_hot gpu version (#41335) (#41495) * add one_hot gpu hint * move allow_out_of_range judgement * delete useless unittest * fix bugs of reshape double grad infermeta (#41459) (#41493) * [cherrypick-2.3] modify infer gpu memory strategy (#41427), remove cudnn_deterministic=True (#41341) (#41491) Co-authored-by: JingZhuangzhuang <[email protected]> * [Cherry-pick][ROCm] fix dcu error in device event base, test=develop (#41523) Cherry-pick of #41521 * [Cherry-Pick]Cherry pick PR41200, PR41474, PR41382 (#41509) * Use `self`as a parameter of _hash_with_id function to avoid error caused by hash_id reuse (#41200) * Add fill_constant_batch_size YAML and UT (#41474) * Switch some dy2st UT to eager mode (#41382) * Sitch some dy2st UT to eager mode * Fix test_lstm and remove test_transformer * Run test_resnet_v2 in old dy mode * Unittest recover (#41431) * update name * update name * fix test * fix fleet bind * update name * update name * fix test * fix gpups wrapper * remove Push/Pull/Load/Save with context in client and wrapper base class * fix * fix * remove some interface * fix * remove * code style * recover * fix * remove code unused * remove some unused table & accessor & CommonDenseTable => MemoryDenseTable * fix * fix * fix * recover * remove unused code * recover unittest * fix * remove * fix * remove code unuseful * remove * fix * recover * remove Co-authored-by: esythan <[email protected]> * add ssd sparse table * fix * add cache shuffle * fix * fix * fix * fix * fix * fix * add unit test * fix Co-authored-by: Zhou Wei <[email protected]> Co-authored-by: Sing_chan <[email protected]> Co-authored-by: 0x45f <[email protected]> Co-authored-by: pangyoki <[email protected]> Co-authored-by: Siming Dai <[email protected]> Co-authored-by: YuanRisheng <[email protected]> Co-authored-by: Zhang Jun <[email protected]> Co-authored-by: JingZhuangzhuang <[email protected]> Co-authored-by: Qi Li <[email protected]> Co-authored-by: esythan <[email protected]>
- Loading branch information
1 parent
4fd190d
commit cca57c4
Showing
37 changed files
with
1,526 additions
and
62 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,70 @@ | ||
// 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 <queue> | ||
#include <unordered_map> | ||
|
||
namespace paddle { | ||
namespace distributed { | ||
class TopkCalculator { | ||
public: | ||
TopkCalculator(int shard_num, size_t k) | ||
: _shard_num(shard_num), _total_max_size(k) { | ||
_shard_max_size = _total_max_size / shard_num; | ||
_shard_max_size = _shard_max_size > 1 ? _shard_max_size : 1; | ||
for (int i = 0; i < shard_num; ++i) { | ||
_mpq.emplace(i, std::priority_queue<double, std::vector<double>, | ||
std::greater<double>>()); | ||
} | ||
} | ||
~TopkCalculator() {} | ||
bool push(int shard_id, double value) { | ||
if (_mpq.find(shard_id) == _mpq.end()) { | ||
return false; | ||
} | ||
auto &pq = _mpq[shard_id]; | ||
if (pq.size() < _shard_max_size) { | ||
pq.push(value); | ||
} else { | ||
if (pq.top() < value) { | ||
pq.pop(); | ||
pq.push(value); | ||
} | ||
} | ||
return true; | ||
} | ||
// TODO 再进行一次堆排序merge各个shard的结果 | ||
int top() { | ||
double total = 0; | ||
for (const auto &item : _mpq) { | ||
auto &pq = item.second; | ||
if (!pq.empty()) { | ||
total += pq.top(); | ||
} | ||
} | ||
return total / _shard_num; | ||
} | ||
|
||
private: | ||
std::unordered_map<int, std::priority_queue<double, std::vector<double>, | ||
std::greater<double>>> | ||
_mpq; | ||
int _shard_num; | ||
size_t _total_max_size; | ||
size_t _shard_max_size; | ||
}; | ||
|
||
} // namespace distributed | ||
} // 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
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
Oops, something went wrong.