forked from llvm/torch-mlir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TorchOps.cpp
38 lines (33 loc) · 1.62 KB
/
TorchOps.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//===- TorchOps.cpp - C Interface for torch ops ---------------------------===//
//
// 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
// Also available under a BSD-style license. See LICENSE.
//
//===----------------------------------------------------------------------===//
#include "torch-mlir-c/TorchOps.h"
#include "mlir/CAPI/IR.h"
#include "mlir/CAPI/Support.h"
#include "mlir/IR/BuiltinTypes.h"
#include "torch-mlir/Dialect/Torch/IR/TorchOps.h"
using namespace mlir;
using namespace mlir::torch;
//===----------------------------------------------------------------------===//
// Utilities
//===----------------------------------------------------------------------===//
MlirValue torchMlirAdjustStaticInformation(MlirBlock block_,
MlirOperation insertBefore_,
MlirValue value_,
MlirType desiredType_,
bool userAllowsRefinement) {
Block *block = unwrap(block_);
Operation *insertBefore = unwrap(insertBefore_);
OpBuilder builder(unwrap(mlirTypeGetContext(desiredType_)));
builder.setInsertionPoint(block, insertBefore ? insertBefore->getIterator()
: block->end());
Value value = unwrap(value_);
Type desiredType = unwrap(desiredType_);
return wrap(Torch::adjustStaticInformation(
builder, value.getLoc(), value, desiredType, userAllowsRefinement));
}