//===----------------------------------------------------------------------===// // // Part of the LLVM Project, 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 // //===----------------------------------------------------------------------===// #include "npcomp/Dialect/TorchConversion/IR/TorchConversionOps.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" #include "npcomp/Dialect/Torch/IR/TorchTypes.h" #include "llvm/ADT/StringMap.h" using namespace mlir; using namespace mlir::NPCOMP; using namespace mlir::NPCOMP::TorchConversion; //===----------------------------------------------------------------------===// // ToBuiltinTensorOp //===----------------------------------------------------------------------===// LogicalResult ToBuiltinTensorOp::inferReturnTypes( MLIRContext *context, Optional location, ValueRange operands, DictionaryAttr attributes, RegionRange regions, SmallVectorImpl &inferredReturnTypes) { auto resultType = operands[0].getType().cast().toBuiltinTensor(); if (!resultType) return failure(); inferredReturnTypes.push_back(resultType); return success(); } //===----------------------------------------------------------------------===// // FromBuiltinTensorOp //===----------------------------------------------------------------------===// LogicalResult FromBuiltinTensorOp::inferReturnTypes( MLIRContext *context, Optional location, ValueRange operands, DictionaryAttr attributes, RegionRange regions, SmallVectorImpl &inferredReturnTypes) { inferredReturnTypes.push_back(Torch::ValueTensorType::getFromShaped( operands[0].getType().cast())); return success(); } #define GET_OP_CLASSES #include "npcomp/Dialect/TorchConversion/IR/TorchConversionOps.cpp.inc"