Replace a usage of std::vector with SmallVector to allow constructing with non...
authorRiver Riddle <riverriddle@google.com>
Thu, 30 May 2019 21:58:28 +0000 (14:58 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 03:11:22 +0000 (20:11 -0700)
--

PiperOrigin-RevId: 250769027

mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp
mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp

index cc0d7f9..2c06526 100644 (file)
@@ -115,7 +115,7 @@ public:
   struct FunctionToSpecialize {
     mlir::Function *function;
     std::string mangledName;
-    std::vector<mlir::Type> argumentsType;
+    SmallVector<mlir::Type, 4> argumentsType;
   };
 
   void runOnModule() override {
@@ -308,10 +308,8 @@ public:
         if (!mangledCallee) {
           // Can't find the target, this is where we queue the request for the
           // callee and stop the inference for the current function now.
-          std::vector<mlir::Type> funcArgs(op->operand_type_begin(),
-                                           op->operand_type_end());
-          funcWorklist.push_back(
-              {callee, std::move(mangledName), std::move(funcArgs)});
+          funcWorklist.push_back({callee, std::move(mangledName),
+                                  llvm::to_vector<4>(op->getOperandTypes())});
           return mlir::success();
         }
         // Found a specialized callee! Let's turn this into a normal call
index 3bd5d26..c9da85f 100644 (file)
@@ -115,7 +115,7 @@ public:
   struct FunctionToSpecialize {
     mlir::Function *function;
     std::string mangledName;
-    std::vector<mlir::Type> argumentsType;
+    SmallVector<mlir::Type, 4> argumentsType;
   };
 
   void runOnModule() override {
@@ -312,10 +312,8 @@ public:
         if (!mangledCallee) {
           // Can't find the target, this is where we queue the request for the
           // callee and stop the inference for the current function now.
-          std::vector<mlir::Type> funcArgs(op->operand_type_begin(),
-                                           op->operand_type_end());
-          funcWorklist.push_back(
-              {callee, std::move(mangledName), std::move(funcArgs)});
+          funcWorklist.push_back({callee, std::move(mangledName),
+                                  llvm::to_vector<4>(op->getOperandTypes())});
           return mlir::success();
         }
         // Found a specialized callee! Let's turn this into a normal call