refactor caffe2 operator constructors - 11/9 (#17722)
authorSebastian Messmer <messmer@fb.com>
Fri, 8 Mar 2019 20:33:31 +0000 (12:33 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 8 Mar 2019 20:38:54 +0000 (12:38 -0800)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17722

clangr codemod

Reviewed By: ezyang

Differential Revision: D14350584

fbshipit-source-id: adef54cedc9409b4fb365f6644e2621a9e47b2ff

caffe2/operators/box_with_nms_limit_op.h
caffe2/operators/cast_op.h
caffe2/operators/channel_backprop_stats_op.h
caffe2/operators/channel_shuffle_op.h
caffe2/operators/channel_stats_op.h

index 308da03..722fe2c 100644 (file)
@@ -13,8 +13,9 @@ template <class Context>
 class BoxWithNMSLimitOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  BoxWithNMSLimitOp(const OperatorDef& operator_def, Workspace* ws)
-      : Operator<Context>(operator_def, ws),
+  template <class... Args>
+  explicit BoxWithNMSLimitOp(Args&&... args)
+      : Operator<Context>(std::forward<Args>(args)...),
         score_thres_(
             this->template GetSingleArgument<float>("score_thresh", 0.05)),
         nms_thres_(this->template GetSingleArgument<float>("nms", 0.3)),
index e880a10..2b662a0 100644 (file)
@@ -15,7 +15,7 @@ class CastOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  CastOp(const OperatorDef& operator_def, Workspace* ws)
+  explicit CastOp(const OperatorDef& operator_def, Workspace* ws)
       : Operator<Context>(operator_def, ws) {
     const ArgumentHelper helper(operator_def);
     TensorProto_DataType to = cast::GetCastDataType(helper, "to");
index 05a13bd..2e158fc 100644 (file)
@@ -11,8 +11,9 @@ template <class Context>
 class ChannelBackpropStatsOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  ChannelBackpropStatsOp(const OperatorDef& operator_def, Workspace* ws)
-      : Operator<Context>(operator_def, ws) {}
+  template <class... Args>
+  explicit ChannelBackpropStatsOp(Args&&... args)
+      : Operator<Context>(std::forward<Args>(args)...) {}
   ~ChannelBackpropStatsOp() {}
 
   bool RunOnDevice() override {
index 69e650f..26806e7 100644 (file)
@@ -12,8 +12,9 @@ class ChannelShuffleOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  ChannelShuffleOp(const OperatorDef& operator_def, Workspace* ws)
-      : Operator<Context>(operator_def, ws),
+  template <class... Args>
+  explicit ChannelShuffleOp(Args&&... args)
+      : Operator<Context>(std::forward<Args>(args)...),
         order_(StringToStorageOrder(
             this->template GetSingleArgument<std::string>("order", "NCHW"))),
         OP_SINGLE_ARG(int, "group", group_, 1) {
@@ -39,8 +40,9 @@ class ChannelShuffleGradientOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  ChannelShuffleGradientOp(const OperatorDef& operator_def, Workspace* ws)
-      : Operator<Context>(operator_def, ws),
+  template <class... Args>
+  explicit ChannelShuffleGradientOp(Args&&... args)
+      : Operator<Context>(std::forward<Args>(args)...),
         order_(StringToStorageOrder(
             this->template GetSingleArgument<std::string>("order", "NCHW"))),
         OP_SINGLE_ARG(int, "group", group_, 1) {
index 532938c..9bdd3d3 100644 (file)
@@ -11,8 +11,9 @@ template <class Context>
 class ChannelStatsOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  ChannelStatsOp(const OperatorDef& operator_def, Workspace* ws)
-      : Operator<Context>(operator_def, ws) {}
+  template <class... Args>
+  explicit ChannelStatsOp(Args&&... args)
+      : Operator<Context>(std::forward<Args>(args)...) {}
   ~ChannelStatsOp() {}
 
   bool RunOnDevice() override {