Temp fix for TileOp backward compatibility (#18026)
authorXiaomeng Yang <yangxm@fb.com>
Thu, 14 Mar 2019 20:48:13 +0000 (13:48 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 14 Mar 2019 20:54:29 +0000 (13:54 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18026

Temp fix for TileOp backward compatibility

Reviewed By: kittipatv

Differential Revision: D14463672

fbshipit-source-id: 1f3ec550245cb63f1bc4f26196b9334cfe5d0705

caffe2/operators/tile_op.cc
caffe2/operators/tile_op.h

index 11d096e..56c858a 100644 (file)
@@ -24,6 +24,15 @@ bool TileOp<CPUContext>::DoRunWithType<std::string>() {
         Input(1).dim() == 1 && Input(1).numel() == 1,
         "Input `tiles` should be a vector of size 1.");
     tiles_ = GetArgFromTensor(Input(1));
+
+    // Because of a bug in original code, temporarily adds this part to keep
+    // backward compatibility.
+    // TODO(yangxm): Remove this part when prod runtime upgraded with fixed
+    // model config.
+    if (Input(1).IsType<std::int64_t>()) {
+      axis_ = 0;
+    }
+
     if (InputSize() > 2) {
       CAFFE_ENFORCE(
           Input(2).dim() == 1 && Input(2).numel() == 1,
index 71f0bde..ad0b924 100644 (file)
@@ -45,6 +45,15 @@ class TileOp final : public Operator<Context> {
           Input(1).dim() == 1 && Input(1).numel() == 1,
           "Input `tiles` should be a vector of size 1.");
       tiles_ = GetArgFromTensor(Input(1));
+
+      // Because of a bug in original code, temporarily adds this part to keep
+      // backward compatibility.
+      // TODO(yangxm): Remove this part when prod runtime upgraded with fixed
+      // model config.
+      if (Input(1).template IsType<std::int64_t>()) {
+        axis_ = 0;
+      }
+
       if (InputSize() > 2) {
         CAFFE_ENFORCE(
             Input(2).dim() == 1 && Input(2).numel() == 1,