Skip to content

Commit 9f48878

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into change-mklml-download-url
2 parents 72913dc + 7bf82f8 commit 9f48878

File tree

15 files changed

+265
-164
lines changed

15 files changed

+265
-164
lines changed

paddle/fluid/framework/block_desc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License. */
1717
#include <deque>
1818
#include <memory>
1919
#include <set>
20+
#include <string>
2021
#include <unordered_map>
2122
#include <vector>
2223

@@ -96,6 +97,8 @@ class BlockDesc {
9697
*/
9798
void RemoveOp(size_t s, size_t e);
9899

100+
void RemoveVar(const std::string &name) { vars_.erase(name); }
101+
99102
std::vector<OpDesc *> AllOps() const;
100103

101104
size_t OpSize() const { return ops_.size(); }

paddle/fluid/framework/channel.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ limitations under the License. */
1414

1515
#pragma once
1616

17-
#include <stddef.h> // for size_t
18-
#include <condition_variable>
17+
#include <stddef.h> // for size_t
18+
#include <condition_variable> // NOLINT
1919
#include <typeindex>
2020
#include "paddle/fluid/platform/enforce.h"
2121

@@ -216,7 +216,8 @@ class ChannelHolder {
216216

217217
template <typename T>
218218
struct PlaceholderImpl : public Placeholder {
219-
PlaceholderImpl(size_t buffer_size) : type_(std::type_index(typeid(T))) {
219+
explicit PlaceholderImpl(size_t buffer_size)
220+
: type_(std::type_index(typeid(T))) {
220221
channel_.reset(MakeChannel<T>(buffer_size));
221222
}
222223

paddle/fluid/framework/channel_impl.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License. */
1515
#pragma once
1616
#include <stddef.h> // for size_t
1717
#include <atomic>
18-
#include <condition_variable>
18+
#include <condition_variable> // NOLINT
1919
#include <deque>
2020
#include "paddle/fluid/framework/channel.h"
2121
#include "paddle/fluid/platform/enforce.h"
@@ -38,7 +38,7 @@ class ChannelImpl : public paddle::framework::Channel<T> {
3838
virtual void Unlock();
3939
virtual bool IsClosed();
4040
virtual void Close();
41-
ChannelImpl(size_t);
41+
explicit ChannelImpl(size_t);
4242
virtual ~ChannelImpl();
4343

4444
virtual void AddToSendQ(const void *referrer, T *data,
@@ -60,7 +60,7 @@ class ChannelImpl : public paddle::framework::Channel<T> {
6060
const void *referrer; // TODO(thuan): figure out better way to do this
6161
std::function<bool(ChannelAction)> callback;
6262

63-
QueueMessage(T *item)
63+
explicit QueueMessage(T *item)
6464
: data(item), cond(std::make_shared<std::condition_variable_any>()) {}
6565

6666
QueueMessage(T *item, std::shared_ptr<std::condition_variable_any> cond)
@@ -88,15 +88,15 @@ class ChannelImpl : public paddle::framework::Channel<T> {
8888
}
8989

9090
std::shared_ptr<QueueMessage> get_first_message(
91-
std::deque<std::shared_ptr<QueueMessage>> &queue, ChannelAction action) {
92-
while (!queue.empty()) {
91+
std::deque<std::shared_ptr<QueueMessage>> *queue, ChannelAction action) {
92+
while (!queue->empty()) {
9393
// Check whether this message was added by Select
9494
// If this was added by Select then execute the callback
9595
// to check if you can execute this message. The callback
9696
// can return false if some other case was executed in Select.
9797
// In that case just discard this QueueMessage and process next.
98-
std::shared_ptr<QueueMessage> m = queue.front();
99-
queue.pop_front();
98+
std::shared_ptr<QueueMessage> m = queue->front();
99+
queue->pop_front();
100100
if (m->callback == nullptr || m->callback(action)) return m;
101101
}
102102
return nullptr;
@@ -147,7 +147,7 @@ void ChannelImpl<T>::Send(T *item) {
147147
// to send to the receiver, bypassing the channel buffer if any
148148
if (!recvq.empty()) {
149149
std::shared_ptr<QueueMessage> m =
150-
get_first_message(recvq, ChannelAction::SEND);
150+
get_first_message(&recvq, ChannelAction::SEND);
151151

152152
if (m != nullptr) {
153153
*(m->data) = std::move(*item);
@@ -198,7 +198,7 @@ bool ChannelImpl<T>::Receive(T *item) {
198198
// buffer and move front of send queue to the buffer
199199
if (!sendq.empty()) {
200200
std::shared_ptr<QueueMessage> m =
201-
get_first_message(sendq, ChannelAction::RECEIVE);
201+
get_first_message(&sendq, ChannelAction::RECEIVE);
202202
if (buf_.size() > 0) {
203203
// Case 1 : Channel is Buffered
204204
// Do Data transfer from front of buffer
@@ -219,8 +219,9 @@ bool ChannelImpl<T>::Receive(T *item) {
219219
if (m != nullptr) {
220220
*item = std::move(*(m->data));
221221
m->Notify();
222-
} else
222+
} else {
223223
return recv_return(Receive(item));
224+
}
224225
}
225226
return recv_return(true);
226227
}

0 commit comments

Comments
 (0)