forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync_net_barrier_op.h
30 lines (24 loc) · 904 Bytes
/
async_net_barrier_op.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef CAFFE2_OPERATORS_ASYNC_BARRIER_OP_H_
#define CAFFE2_OPERATORS_ASYNC_BARRIER_OP_H_
#include "caffe2/core/context.h"
#include "caffe2/core/export_caffe2_op_to_c10.h"
#include "caffe2/core/operator.h"
namespace caffe2 {
template <class Context>
class AsyncNetBarrierOp : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
USE_SIMPLE_CTOR_DTOR(AsyncNetBarrierOp)
bool RunOnDevice() override {
// This is a pretty much no-op operator, since it's only purposes is make
// sure that async_scheduling will schedule certain operations earlier than
// others.
//
// Exaple where this operator can work well - mixture of data-parallel and
// model parallel training, where one wants to force that all copies are
// started before data-parallel part starts.
return true;
}
};
} // namespace caffe2
#endif // CAFFE2_OPERATORS_ASYNC_BARRIER_OP_H_