forked from llvm/torch-mlir
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MLIR][ONNX] Add OnnxToTorch support for Maxpool Op (llvm#2695)
Add Maxpool ONNX op support. Add Utils.h/cpp files to create a constant int list for ONNX.
- Loading branch information
Showing
5 changed files
with
215 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===------------------------------------------------------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// Also available under a BSD-style license. See LICENSE. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TORCHMLIR_CONVERSION_TORCHONNXTOTORCH_UTILS_H | ||
#define TORCHMLIR_CONVERSION_TORCHONNXTOTORCH_UTILS_H | ||
|
||
#include "torch-mlir/Conversion/TorchOnnxToTorch/Patterns.h" | ||
|
||
namespace mlir::torch::onnx_c { | ||
|
||
Value createConstantIntList(OpBinder binder, | ||
ConversionPatternRewriter &rewriter, | ||
SmallVector<int64_t> cstInput); | ||
|
||
} // namespace mlir::torch::onnx_c | ||
|
||
#endif // TORCHMLIR_CONVERSION_TORCHONNXTOTORCH_UTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//===------------------------------------------------------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// Also available under a BSD-style license. See LICENSE. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "torch-mlir/Conversion/TorchOnnxToTorch/Utils.h" | ||
|
||
using namespace mlir; | ||
using namespace mlir::torch; | ||
using namespace mlir::torch::onnx_c; | ||
|
||
Value mlir::torch::onnx_c::createConstantIntList( | ||
OpBinder binder, ConversionPatternRewriter &rewriter, | ||
SmallVector<int64_t> cstInput) { | ||
SmallVector<Value> cstValue; | ||
for (int64_t i : cstInput) { | ||
cstValue.push_back(rewriter.create<Torch::ConstantIntOp>( | ||
binder.getLoc(), rewriter.getI64IntegerAttr(i))); | ||
} | ||
return rewriter.create<Torch::PrimListConstructOp>( | ||
binder.getLoc(), | ||
Torch::ListType::get(Torch::IntType::get(binder.op->getContext())), | ||
cstValue); | ||
} |
Oops, something went wrong.