Revert D14078519: [codemod][caffe2] [clangr] refactor caffe2 operator constructors...
authorSebastian Messmer <messmer@fb.com>
Thu, 28 Feb 2019 22:58:12 +0000 (14:58 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 28 Feb 2019 23:09:28 +0000 (15:09 -0800)
Differential Revision:
D14078519

Original commit changeset: b0ca31a52e4a

fbshipit-source-id: 713ae108d3dd6f33abdbf98a5f213e57e2b64642

25 files changed:
caffe2/operators/loss_op.h
caffe2/operators/lpnorm_op.h
caffe2/operators/lstm_unit_op.h
caffe2/operators/map_ops.h
caffe2/operators/margin_ranking_criterion_op.h
caffe2/operators/matmul_op.h
caffe2/operators/mean_op.h
caffe2/operators/mem_query_op.cu
caffe2/operators/minmax_ops.h
caffe2/operators/mod_op.h
caffe2/operators/moments_op.h
caffe2/operators/ngram_ops.h
caffe2/operators/normalize_op.h
caffe2/operators/numpy_tile_op.h
caffe2/operators/one_hot_ops.cc
caffe2/operators/one_hot_ops.h
caffe2/operators/onnx_while_op.h
caffe2/operators/onnxifi_op.h
caffe2/operators/operator_fallback_gpu.h
caffe2/operators/operator_fallback_gpu_test.cc
caffe2/operators/order_switch_ops_cudnn.cc
caffe2/operators/pack_rnn_sequence_op.h
caffe2/operators/pack_segments.h
caffe2/operators/pad_op.h
caffe2/operators/partition_ops.h

index 9ab9f16..aa61a89 100644 (file)
@@ -15,18 +15,16 @@ namespace caffe2 {
 template <typename T, class Context>
 class AveragedLoss final : public SumElementsOp<T, Context> {
  public:
-  template <class... Args>
-  explicit AveragedLoss(Args&&... args)
-      : SumElementsOp<T, Context>(std::forward<Args>(args)...) {}
+  AveragedLoss(const OperatorDef& operator_def, Workspace* ws)
+      : SumElementsOp<T, Context>(operator_def, ws, true) {}
   ~AveragedLoss() {}
 };
 
 template <typename T, class Context>
 class AveragedLossGradient final : public SumElementsGradientOp<T, Context> {
  public:
-  template <class... Args>
-  explicit AveragedLossGradient(Args&&... args)
-      : SumElementsGradientOp<T, Context>(std::forward<Args>(args)...) {}
+  AveragedLossGradient(const OperatorDef& operator_def, Workspace* ws)
+      : SumElementsGradientOp<T, Context>(operator_def, ws, true) {}
   ~AveragedLossGradient() {}
 };
 
index be9e46c..0a5c372 100644 (file)
@@ -11,9 +11,8 @@ template <typename T, class Context>
 class LpNormOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit LpNormOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  LpNormOp(const OperatorDef& def, Workspace* ws)
+      : Operator<Context>(def, ws),
         OP_SINGLE_ARG(int, "p", p_, 2),
         OP_SINGLE_ARG(bool, "average", average_, false) {
     CAFFE_ENFORCE(p_ == 1 || p_ == 2, "p should be either 1 or 2.");
@@ -30,9 +29,8 @@ template <typename T, class Context>
 class LpNormGradientOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit LpNormGradientOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  LpNormGradientOp(const OperatorDef& def, Workspace* ws)
+      : Operator<Context>(def, ws),
         OP_SINGLE_ARG(int, "p", p_, 2),
         OP_SINGLE_ARG(bool, "average", average_, false) {
     CAFFE_ENFORCE(p_ == 1 || p_ == 2, "p should be either 1 or 2.");
index e4cdee8..095e550 100644 (file)
@@ -137,15 +137,18 @@ void LSTMUnitGradient(
 template <typename Context>
 class LSTMUnitOp : public Operator<Context> {
  public:
-  template <class... Args>
-  explicit LSTMUnitOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
-        forget_bias_(static_cast<float>(
-            this->template GetSingleArgument<float>("forget_bias", 0.0))),
-        sequence_lengths_(
-            this->template GetSingleArgument<bool>("sequence_lengths", true)),
-        drop_states_(
-            this->template GetSingleArgument<bool>("drop_states", false)) {}
+  LSTMUnitOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
+        forget_bias_(
+            static_cast<float>(this->template GetSingleArgument<float>(
+                "forget_bias",
+                0.0))),
+        sequence_lengths_(this->template GetSingleArgument<bool>(
+            "sequence_lengths",
+            true)),
+        drop_states_(this->template GetSingleArgument<bool>(
+            "drop_states",
+            false)) {}
   USE_OPERATOR_CONTEXT_FUNCTIONS;
   using Operator<Context>::Operator;
 
@@ -215,15 +218,18 @@ class LSTMUnitOp : public Operator<Context> {
 template <typename Context>
 class LSTMUnitGradientOp : public Operator<Context> {
  public:
-  template <class... Args>
-  explicit LSTMUnitGradientOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
-        forget_bias_(static_cast<float>(
-            this->template GetSingleArgument<float>("forget_bias", 0.0))),
-        sequence_lengths_(
-            this->template GetSingleArgument<bool>("sequence_lengths", true)),
-        drop_states_(
-            this->template GetSingleArgument<bool>("drop_states", false)) {}
+  LSTMUnitGradientOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
+        forget_bias_(
+            static_cast<float>(this->template GetSingleArgument<float>(
+                "forget_bias",
+                0.0))),
+        sequence_lengths_(this->template GetSingleArgument<bool>(
+            "sequence_lengths",
+            true)),
+        drop_states_(this->template GetSingleArgument<bool>(
+            "drop_states",
+            false)) {}
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
   template <typename T>
index b959767..0a547c0 100644 (file)
@@ -48,9 +48,8 @@ template <class Context>
 class CreateMapOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit CreateMapOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  CreateMapOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
   ~CreateMapOp() {}
 
   bool RunOnDevice() override {
@@ -100,9 +99,8 @@ template <class Context>
 class KeyValueToMapOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit KeyValueToMapOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  KeyValueToMapOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
   ~KeyValueToMapOp() {}
 
   bool RunOnDevice() override {
@@ -153,9 +151,8 @@ template <class Context>
 class MapToKeyValueOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit MapToKeyValueOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  MapToKeyValueOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
   ~MapToKeyValueOp() {}
 
   bool RunOnDevice() override {
index 050da75..933db52 100644 (file)
@@ -10,9 +10,8 @@ namespace caffe2 {
 template <class Context>
 class MarginRankingCriterionOp final : public Operator<Context> {
  public:
-  template <class... Args>
-  explicit MarginRankingCriterionOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  MarginRankingCriterionOp(const OperatorDef& def, Workspace* ws)
+      : Operator<Context>(def, ws),
         OP_SINGLE_ARG(float, "margin", margin_, 1.0) {}
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
@@ -25,9 +24,8 @@ class MarginRankingCriterionOp final : public Operator<Context> {
 template <class Context>
 class MarginRankingCriterionGradientOp final : public Operator<Context> {
  public:
-  template <class... Args>
-  explicit MarginRankingCriterionGradientOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  MarginRankingCriterionGradientOp(const OperatorDef& def, Workspace* ws)
+      : Operator<Context>(def, ws),
         OP_SINGLE_ARG(float, "margin", margin_, 1.0) {}
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
index 57fd542..b340773 100644 (file)
@@ -11,9 +11,8 @@ template <typename T, class Context, class Engine = DefaultEngine>
 class MatMulOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit MatMulOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  MatMulOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
         axis_a_(this->template GetSingleArgument<int>("axis_a", 1)),
         axis_b_(this->template GetSingleArgument<int>("axis_b", 1)),
         trans_a_(this->template GetSingleArgument<int>("trans_a", 0)),
index f16914f..8e37ba1 100644 (file)
@@ -79,9 +79,8 @@ class MeanGradientOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  template <class... Args>
-  explicit MeanGradientOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  MeanGradientOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
 
   template <typename T>
   bool DoRunWithType() {
index f53402c..a9ea235 100644 (file)
@@ -6,8 +6,8 @@ namespace {
 
 class GetGPUMemoryUsageOp final : public Operator<CUDAContext> {
  public:
-  template<class... Args> explicit GetGPUMemoryUsageOp(Args&&... args)
-      : Operator<CUDAContext>(std::forward<Args>(args)...) {}
+  GetGPUMemoryUsageOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<CUDAContext>(operator_def, ws) {}
   ~GetGPUMemoryUsageOp() override {}
 
   bool RunOnDevice() override {
index 2191a96..5668460 100644 (file)
@@ -117,9 +117,8 @@ class SelectGradientOpBase : public Operator<Context> {
 template <typename T, class Context>
 class MaxGradientOp final : public SelectGradientOpBase<T, Context> {
  public:
-  template <class... Args>
-  explicit MaxGradientOp(Args&&... args)
-      : SelectGradientOpBase<T, Context>(std::forward<Args>(args)...) {}
+  MaxGradientOp(const OperatorDef& operator_def, Workspace* ws)
+      : SelectGradientOpBase<T, Context>(operator_def, ws) {}
 
   ~MaxGradientOp() = default;
 };
@@ -127,9 +126,8 @@ class MaxGradientOp final : public SelectGradientOpBase<T, Context> {
 template <typename T, class Context>
 class MinGradientOp final : public SelectGradientOpBase<T, Context> {
  public:
-  template <class... Args>
-  explicit MinGradientOp(Args&&... args)
-      : SelectGradientOpBase<T, Context>(std::forward<Args>(args)...) {}
+  MinGradientOp(const OperatorDef& operator_def, Workspace* ws)
+      : SelectGradientOpBase<T, Context>(operator_def, ws) {}
 
   ~MinGradientOp() = default;
 };
index a8f86bc..65adcf9 100644 (file)
@@ -11,9 +11,8 @@ template <class Context>
 class ModOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit ModOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {
+  ModOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {
     divisor_ = this->template GetSingleArgument<int64_t>("divisor", 0);
     CAFFE_ENFORCE_NE(divisor_, 0, "divisor must not be 0");
     sign_follow_divisor_ =
index 10e2ddb..9ce1730 100644 (file)
@@ -15,9 +15,8 @@ class MomentsOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  template <class... Args>
-  explicit MomentsOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  MomentsOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
         axes_(this->template GetRepeatedArgument<int>("axes")),
         OP_SINGLE_ARG(bool, "keepdims", keep_dims_, true) {}
 
@@ -77,9 +76,8 @@ class MomentsGradientOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  template <class... Args>
-  explicit MomentsGradientOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  MomentsGradientOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
         axes_(this->template GetRepeatedArgument<int>("axes")) {}
 
   bool RunOnDevice() override {
index 162338a..2f8c513 100644 (file)
@@ -12,9 +12,8 @@ class NGramFromCategoricalOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  template <class... Args>
-  explicit NGramFromCategoricalOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  NGramFromCategoricalOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
         col_ids_(this->template GetRepeatedArgument<int>("col_ids")),
         categorical_limits_(
             this->template GetRepeatedArgument<int>("categorical_limits")),
index 065484d..3a0995c 100644 (file)
@@ -13,9 +13,8 @@ template <typename T, class Context>
 class NormalizeOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit NormalizeOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  NormalizeOp(const OperatorDef& def, Workspace* ws)
+      : Operator<Context>(def, ws) {}
 
   bool RunOnDevice() override {
     const auto& x = Input(0);
@@ -43,9 +42,8 @@ template <typename T, class Context>
 class NormalizeGradientOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit NormalizeGradientOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  NormalizeGradientOp(const OperatorDef& def, Workspace* ws)
+      : Operator<Context>(def, ws) {}
 
   bool RunOnDevice() override {
     const auto& x = Input(0);
index 1301298..874eaa1 100644 (file)
@@ -14,9 +14,8 @@ template <class Context>
 class NumpyTileOp : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit NumpyTileOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  NumpyTileOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
   ~NumpyTileOp() {}
 
   bool RunOnDevice() override {
index 0dd0aaf..09eb673 100644 (file)
@@ -169,9 +169,8 @@ bool BatchBucketOneHotOp<CPUContext>::RunOnDevice() {
 
 class SegmentOneHotOp : public Operator<CPUContext> {
  public:
-  template <class... Args>
-  explicit SegmentOneHotOp(Args&&... args)
-      : Operator(std::forward<Args>(args)...) {}
+  SegmentOneHotOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator(operator_def, ws) {}
 
   bool RunOnDevice() override {
     auto& lengths = Input(0);
index d61c0d2..ba047cb 100644 (file)
@@ -13,9 +13,8 @@ class OneHotOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
 
-  template <class... Args>
-  explicit OneHotOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  OneHotOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
 
   bool RunOnDevice() override {
     auto& indices = Input(0);
@@ -56,9 +55,8 @@ template <class Context>
 class BatchOneHotOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit BatchOneHotOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  BatchOneHotOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
 
   bool RunOnDevice() override {
     return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(this, Input(X));
@@ -81,9 +79,8 @@ template <class Context>
 class BatchBucketOneHotOp final : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit BatchBucketOneHotOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  BatchBucketOneHotOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
 
   bool RunOnDevice() override;
 
index 7b4c4ec..eeb45bb 100644 (file)
@@ -11,19 +11,15 @@ namespace caffe2 {
 template <class Context>
 class ONNXWhileOp final : public Operator<Context> {
  public:
-  explicit ONNXWhileOp(const OperatorDef& operator_def, Workspace* ws)
+  ONNXWhileOp(const OperatorDef& operator_def, Workspace* ws)
       : Operator<Context>(operator_def, ws),
         parent_ws_(ws),
         has_trip_count_(
             this->template GetSingleArgument<int64_t>("has_trip_count", 0)),
         has_cond_(this->template GetSingleArgument<int64_t>("has_cond", 0)),
-        save_scopes_(
-            this->template GetSingleArgument<int64_t>("save_scopes", 0)),
-        disable_scopes_(
-            this->template GetSingleArgument<int64_t>("disable_scopes", 0)),
-        num_loop_carried_deps_(this->template GetSingleArgument<int64_t>(
-            "num_loop_carried_deps",
-            -1)) {
+        save_scopes_(this->template GetSingleArgument<int64_t>("save_scopes", 0)),
+        disable_scopes_(this->template GetSingleArgument<int64_t>("disable_scopes", 0)),
+        num_loop_carried_deps_(this->template GetSingleArgument<int64_t>("num_loop_carried_deps", -1)) {
     CAFFE_ENFORCE(
         this->template HasSingleArgumentOfType<NetDef>("body"),
         "body net must be specified in ONNXWhile operator");
index b81f5b9..1fb5806 100644 (file)
@@ -25,7 +25,7 @@ class OnnxifiOp final : public Operator<Context> {
 
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  explicit OnnxifiOp(const OperatorDef& operator_def, Workspace* ws)
+  OnnxifiOp(const OperatorDef& operator_def, Workspace* ws)
       : Operator<Context>(operator_def, ws) {
     lib_ = onnx::initOnnxifiLibrary();
     backend_graph_map_ptr_ = onnx::getOnnxBackendGraphMap();
index 72b430f..ad55ee7 100644 (file)
@@ -42,7 +42,7 @@ template <typename SkipOutputCopy>
 class GPUFallbackOpEx final : public Operator<CUDAContext> {
  public:
   USE_OPERATOR_FUNCTIONS(CUDAContext);
-  explicit GPUFallbackOpEx(const OperatorDef& def, Workspace* ws)
+  GPUFallbackOpEx(const OperatorDef& def, Workspace* ws)
       : Operator<CUDAContext>(def, ws) {
     CAFFE_ENFORCE_EQ(def.device_option().device_type(), PROTO_CUDA);
     OperatorDef base_def_(def);
index e41e9b4..5606bac 100644 (file)
@@ -9,9 +9,8 @@ namespace caffe2 {
 
 class IncrementByOneOp final : public Operator<CPUContext> {
  public:
-  template <class... Args>
-  explicit IncrementByOneOp(Args&&... args)
-      : Operator<CPUContext>(std::forward<Args>(args)...) {}
+  IncrementByOneOp(const OperatorDef& def, Workspace* ws)
+      : Operator<CPUContext>(def, ws) {}
   bool RunOnDevice() override {
     const auto& in = Input(0);
 
index 83511f3..6d4f7c5 100644 (file)
@@ -16,10 +16,8 @@ class CuDNNOrderSwithOpBase : public Operator<CUDAContext> {
  public:
   USE_OPERATOR_FUNCTIONS(CUDAContext);
 
-  template <class... Args>
-  explicit CuDNNOrderSwithOpBase(Args&&... args)
-      : Operator<CUDAContext>(std::forward<Args>(args)...),
-        cudnn_wrapper_(&context_) {
+  CuDNNOrderSwithOpBase(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<CUDAContext>(operator_def, ws), cudnn_wrapper_(&context_) {
     CUDNN_ENFORCE(cudnnCreateTensorDescriptor(&X_desc_));
     CUDNN_ENFORCE(cudnnCreateTensorDescriptor(&Y_desc_));
   }
@@ -75,9 +73,8 @@ class CuDNNOrderSwithOpBase : public Operator<CUDAContext> {
 
 class CuDNNNHWC2NCHWOp final : public CuDNNOrderSwithOpBase {
  public:
-  template <class... Args>
-  explicit CuDNNNHWC2NCHWOp(Args&&... args)
-      : CuDNNOrderSwithOpBase(std::forward<Args>(args)...) {}
+  CuDNNNHWC2NCHWOp(const OperatorDef& operator_def, Workspace* ws)
+      : CuDNNOrderSwithOpBase(operator_def, ws) {}
 
   bool RunOnDevice() override {
     return DispatchHelper<TensorTypes<float, at::Half>>::call(this, Input(0));
@@ -119,9 +116,8 @@ class CuDNNNHWC2NCHWOp final : public CuDNNOrderSwithOpBase {
 
 class CuDNNNCHW2NHWCOp final : public CuDNNOrderSwithOpBase {
  public:
-  template <class... Args>
-  explicit CuDNNNCHW2NHWCOp(Args&&... args)
-      : CuDNNOrderSwithOpBase(std::forward<Args>(args)...) {}
+  CuDNNNCHW2NHWCOp(const OperatorDef& operator_def, Workspace* ws)
+      : CuDNNOrderSwithOpBase(operator_def, ws) {}
 
   bool RunOnDevice() override {
     return DispatchHelper<TensorTypes<float, at::Half>>::call(this, Input(0));
index 0dc597d..a256444 100644 (file)
@@ -13,9 +13,8 @@ template <class Context, bool Forward>
 class PackRNNSequenceOpBase : public Operator<Context> {
  public:
   USE_OPERATOR_CONTEXT_FUNCTIONS;
-  template <class... Args>
-  explicit PackRNNSequenceOpBase(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...) {}
+  PackRNNSequenceOpBase(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws) {}
 
   bool RunOnDevice() override {
     return DispatchHelper<TensorTypes<int32_t, int64_t, float, double>>::call(
index 2907fee..6315c59 100644 (file)
@@ -18,9 +18,8 @@ class PackSegmentsOp final : public Operator<Context> {
   USE_OPERATOR_CONTEXT_FUNCTIONS;
   USE_DISPATCH_HELPER;
 
-  template <class... Args>
-  explicit PackSegmentsOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  PackSegmentsOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
         max_length_(this->template GetSingleArgument<int>("max_length", -1)),
         pad_minf_(this->template GetSingleArgument<bool>("pad_minf", false)),
         return_presence_mask_(this->template GetSingleArgument<bool>(
@@ -64,9 +63,8 @@ class UnpackSegmentsOp final : public Operator<Context> {
   USE_OPERATOR_CONTEXT_FUNCTIONS;
   USE_DISPATCH_HELPER;
 
-  template <class... Args>
-  explicit UnpackSegmentsOp(Args&&... args)
-      : Operator<Context>(std::forward<Args>(args)...),
+  UnpackSegmentsOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<Context>(operator_def, ws),
         max_length_(this->template GetSingleArgument<int>("max_length", -1)) {}
 
   bool RunOnDevice() override {
index fc13899..d777192 100644 (file)
@@ -22,9 +22,8 @@ template <typename T, class Context>
 class PadImageOp final : public ConvPoolOpBase<Context> {
  public:
   USE_CONV_POOL_BASE_FUNCTIONS(Context);
-  template <class... Args>
-  explicit PadImageOp(Args&&... args)
-      : ConvPoolOpBase<Context>(std::forward<Args>(args)...),
+  PadImageOp(const OperatorDef& operator_def, Workspace* ws)
+      : ConvPoolOpBase<Context>(operator_def, ws),
         mode_(StringToPadMode(
             this->template GetSingleArgument<string>("mode", "constant"))),
         value_(static_cast<T>(
@@ -63,9 +62,8 @@ template <typename T, class Context>
 class PadImageGradientOp final : public ConvPoolOpBase<Context> {
  public:
   USE_CONV_POOL_BASE_FUNCTIONS(Context);
-  template <class... Args>
-  explicit PadImageGradientOp(Args&&... args)
-      : ConvPoolOpBase<Context>(std::forward<Args>(args)...),
+  PadImageGradientOp(const OperatorDef& operator_def, Workspace* ws)
+      : ConvPoolOpBase<Context>(operator_def, ws),
         mode_(StringToPadMode(
             this->template GetSingleArgument<string>("mode", "constant"))) {
     CAFFE_ENFORCE(
index fa8a27c..210f8c3 100644 (file)
@@ -18,9 +18,8 @@ class GatherByKeyOp : public Operator<CPUContext> {
  public:
   USE_DISPATCH_HELPER;
   USE_OPERATOR_FUNCTIONS(CPUContext);
-  template <class... Args>
-  explicit GatherByKeyOp(Args&&... args)
-      : Operator<CPUContext>(std::forward<Args>(args)...) {}
+  GatherByKeyOp(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<CPUContext>(operator_def, ws) {}
 
  private:
   bool RunOnDevice() override {
@@ -106,9 +105,8 @@ class PartitionOpBase : public Operator<CPUContext> {
  public:
   USE_OPERATOR_FUNCTIONS(CPUContext);
 
-  template <class... Args>
-  explicit PartitionOpBase(Args&&... args)
-      : Operator<CPUContext>(std::forward<Args>(args)...),
+  PartitionOpBase(const OperatorDef& operator_def, Workspace* ws)
+      : Operator<CPUContext>(operator_def, ws),
         OP_SINGLE_ARG(int, "pack_first_input", pack_first_input_, 0) {}
 
  protected:
@@ -209,9 +207,8 @@ class PartitionOp : public PartitionOpBase {
  public:
   USE_DISPATCH_HELPER;
 
-  template <class... Args>
-  explicit PartitionOp(Args&&... args)
-      : PartitionOpBase(std::forward<Args>(args)...) {}
+  PartitionOp(const OperatorDef& operator_def, Workspace* ws)
+      : PartitionOpBase(operator_def, ws) {}
 
   bool RunOnDevice() override {
     return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(this, Input(0));
@@ -231,9 +228,8 @@ class LengthsPartitionOp : public PartitionOpBase {
  public:
   USE_DISPATCH_HELPER;
 
-  template <class... Args>
-  explicit LengthsPartitionOp(Args&&... args)
-      : PartitionOpBase(std::forward<Args>(args)...) {}
+  LengthsPartitionOp(const OperatorDef& operator_def, Workspace* ws)
+      : PartitionOpBase(operator_def, ws) {}
 
   bool RunOnDevice() override {
     return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(this, Input(1));