Skip to content

Commit 4a7c549

Browse files
smessmerfacebook-github-bot
authored andcommitted
refactor caffe2 operator constructors - 11/9 (pytorch#17722)
Summary: Pull Request resolved: pytorch#17722 clangr codemod Reviewed By: ezyang Differential Revision: D14350584 fbshipit-source-id: adef54cedc9409b4fb365f6644e2621a9e47b2ff
1 parent 55cf9c7 commit 4a7c549

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

caffe2/operators/box_with_nms_limit_op.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ template <class Context>
1313
class BoxWithNMSLimitOp final : public Operator<Context> {
1414
public:
1515
USE_OPERATOR_CONTEXT_FUNCTIONS;
16-
BoxWithNMSLimitOp(const OperatorDef& operator_def, Workspace* ws)
17-
: Operator<Context>(operator_def, ws),
16+
template <class... Args>
17+
explicit BoxWithNMSLimitOp(Args&&... args)
18+
: Operator<Context>(std::forward<Args>(args)...),
1819
score_thres_(
1920
this->template GetSingleArgument<float>("score_thresh", 0.05)),
2021
nms_thres_(this->template GetSingleArgument<float>("nms", 0.3)),

caffe2/operators/cast_op.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CastOp : public Operator<Context> {
1515
public:
1616
USE_OPERATOR_CONTEXT_FUNCTIONS;
1717

18-
CastOp(const OperatorDef& operator_def, Workspace* ws)
18+
explicit CastOp(const OperatorDef& operator_def, Workspace* ws)
1919
: Operator<Context>(operator_def, ws) {
2020
const ArgumentHelper helper(operator_def);
2121
TensorProto_DataType to = cast::GetCastDataType(helper, "to");

caffe2/operators/channel_backprop_stats_op.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ template <class Context>
1111
class ChannelBackpropStatsOp : public Operator<Context> {
1212
public:
1313
USE_OPERATOR_CONTEXT_FUNCTIONS;
14-
ChannelBackpropStatsOp(const OperatorDef& operator_def, Workspace* ws)
15-
: Operator<Context>(operator_def, ws) {}
14+
template <class... Args>
15+
explicit ChannelBackpropStatsOp(Args&&... args)
16+
: Operator<Context>(std::forward<Args>(args)...) {}
1617
~ChannelBackpropStatsOp() {}
1718

1819
bool RunOnDevice() override {

caffe2/operators/channel_shuffle_op.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ class ChannelShuffleOp final : public Operator<Context> {
1212
public:
1313
USE_OPERATOR_CONTEXT_FUNCTIONS;
1414

15-
ChannelShuffleOp(const OperatorDef& operator_def, Workspace* ws)
16-
: Operator<Context>(operator_def, ws),
15+
template <class... Args>
16+
explicit ChannelShuffleOp(Args&&... args)
17+
: Operator<Context>(std::forward<Args>(args)...),
1718
order_(StringToStorageOrder(
1819
this->template GetSingleArgument<std::string>("order", "NCHW"))),
1920
OP_SINGLE_ARG(int, "group", group_, 1) {
@@ -39,8 +40,9 @@ class ChannelShuffleGradientOp final : public Operator<Context> {
3940
public:
4041
USE_OPERATOR_CONTEXT_FUNCTIONS;
4142

42-
ChannelShuffleGradientOp(const OperatorDef& operator_def, Workspace* ws)
43-
: Operator<Context>(operator_def, ws),
43+
template <class... Args>
44+
explicit ChannelShuffleGradientOp(Args&&... args)
45+
: Operator<Context>(std::forward<Args>(args)...),
4446
order_(StringToStorageOrder(
4547
this->template GetSingleArgument<std::string>("order", "NCHW"))),
4648
OP_SINGLE_ARG(int, "group", group_, 1) {

caffe2/operators/channel_stats_op.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ template <class Context>
1111
class ChannelStatsOp : public Operator<Context> {
1212
public:
1313
USE_OPERATOR_CONTEXT_FUNCTIONS;
14-
ChannelStatsOp(const OperatorDef& operator_def, Workspace* ws)
15-
: Operator<Context>(operator_def, ws) {}
14+
template <class... Args>
15+
explicit ChannelStatsOp(Args&&... args)
16+
: Operator<Context>(std::forward<Args>(args)...) {}
1617
~ChannelStatsOp() {}
1718

1819
bool RunOnDevice() override {

0 commit comments

Comments
 (0)