2018-07-08 20:51:38 -07:00
|
|
|
//===- Builders.cpp - Helpers for constructing MLIR Classes ---------------===//
|
|
|
|
//
|
|
|
|
// Copyright 2019 The MLIR Authors.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
#include "mlir/IR/Builders.h"
|
2018-07-10 10:59:53 -07:00
|
|
|
#include "mlir/IR/AffineExpr.h"
|
|
|
|
#include "mlir/IR/AffineMap.h"
|
|
|
|
#include "mlir/IR/Attributes.h"
|
2018-08-07 14:24:38 -07:00
|
|
|
#include "mlir/IR/IntegerSet.h"
|
2018-08-27 21:05:16 -07:00
|
|
|
#include "mlir/IR/Location.h"
|
2018-07-08 20:51:38 -07:00
|
|
|
#include "mlir/IR/Module.h"
|
|
|
|
#include "mlir/IR/Types.h"
|
|
|
|
using namespace mlir;
|
|
|
|
|
|
|
|
Builder::Builder(Module *module) : context(module->getContext()) {}
|
|
|
|
|
2018-07-10 10:59:53 -07:00
|
|
|
Identifier Builder::getIdentifier(StringRef str) {
|
|
|
|
return Identifier::get(str, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
Module *Builder::createModule() { return new Module(context); }
|
|
|
|
|
2018-08-27 21:05:16 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Locations.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-11-08 12:28:35 -08:00
|
|
|
UnknownLoc Builder::getUnknownLoc() { return UnknownLoc::get(context); }
|
2018-08-27 21:05:16 -07:00
|
|
|
|
|
|
|
UniquedFilename Builder::getUniquedFilename(StringRef filename) {
|
|
|
|
return UniquedFilename::get(filename, context);
|
|
|
|
}
|
|
|
|
|
2018-11-08 12:28:35 -08:00
|
|
|
FileLineColLoc Builder::getFileLineColLoc(UniquedFilename filename,
|
|
|
|
unsigned line, unsigned column) {
|
2018-08-27 21:05:16 -07:00
|
|
|
return FileLineColLoc::get(filename, line, column, context);
|
|
|
|
}
|
|
|
|
|
2018-11-09 11:27:28 -08:00
|
|
|
Location Builder::getFusedLoc(ArrayRef<Location> locs, Attribute metadata) {
|
|
|
|
return FusedLoc::get(locs, metadata, context);
|
|
|
|
}
|
|
|
|
|
2018-07-10 10:59:53 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-07-08 20:51:38 -07:00
|
|
|
// Types.
|
2018-07-10 10:59:53 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
FloatType Builder::getBF16Type() { return Type::getBF16(context); }
|
2018-07-08 20:51:38 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
FloatType Builder::getF16Type() { return Type::getF16(context); }
|
2018-07-08 20:51:38 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
FloatType Builder::getF32Type() { return Type::getF32(context); }
|
2018-07-08 20:51:38 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
FloatType Builder::getF64Type() { return Type::getF64(context); }
|
2018-07-08 20:51:38 -07:00
|
|
|
|
2018-11-08 04:04:13 -08:00
|
|
|
IndexType Builder::getIndexType() { return Type::getIndex(context); }
|
2018-07-08 20:51:38 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFControlType() { return Type::getTFControl(context); }
|
2018-07-27 11:07:12 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFResourceType() { return Type::getTFResource(context); }
|
2018-09-19 10:28:46 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFVariantType() { return Type::getTFVariant(context); }
|
2018-09-19 21:15:43 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFComplex64Type() {
|
2018-09-20 11:59:17 -07:00
|
|
|
return Type::getTFComplex64(context);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFComplex128Type() {
|
2018-09-20 11:59:17 -07:00
|
|
|
return Type::getTFComplex128(context);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFF32REFType() { return Type::getTFF32REF(context); }
|
2018-09-26 22:10:45 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
OtherType Builder::getTFStringType() { return Type::getTFString(context); }
|
2018-08-01 12:55:27 -07:00
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
IntegerType Builder::getIntegerType(unsigned width) {
|
2018-07-08 20:51:38 -07:00
|
|
|
return Type::getInteger(width, context);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
FunctionType Builder::getFunctionType(ArrayRef<Type> inputs,
|
|
|
|
ArrayRef<Type> results) {
|
2018-07-08 20:51:38 -07:00
|
|
|
return FunctionType::get(inputs, results, context);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
MemRefType Builder::getMemRefType(ArrayRef<int> shape, Type elementType,
|
|
|
|
ArrayRef<AffineMap> affineMapComposition,
|
|
|
|
unsigned memorySpace) {
|
2018-08-10 11:56:47 -07:00
|
|
|
return MemRefType::get(shape, elementType, affineMapComposition, memorySpace);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
VectorType Builder::getVectorType(ArrayRef<int> shape, Type elementType) {
|
2018-07-08 20:51:38 -07:00
|
|
|
return VectorType::get(shape, elementType);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
RankedTensorType Builder::getTensorType(ArrayRef<int> shape, Type elementType) {
|
2018-07-08 20:51:38 -07:00
|
|
|
return RankedTensorType::get(shape, elementType);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
UnrankedTensorType Builder::getTensorType(Type elementType) {
|
2018-07-08 20:51:38 -07:00
|
|
|
return UnrankedTensorType::get(elementType);
|
|
|
|
}
|
2018-07-10 10:59:53 -07:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Attributes.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
BoolAttr Builder::getBoolAttr(bool value) {
|
2018-07-10 10:59:53 -07:00
|
|
|
return BoolAttr::get(value, context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
IntegerAttr Builder::getIntegerAttr(int64_t value) {
|
2018-07-10 10:59:53 -07:00
|
|
|
return IntegerAttr::get(value, context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
FloatAttr Builder::getFloatAttr(double value) {
|
2018-10-20 18:31:49 -07:00
|
|
|
return FloatAttr::get(APFloat(value), context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
FloatAttr Builder::getFloatAttr(const APFloat &value) {
|
2018-07-10 10:59:53 -07:00
|
|
|
return FloatAttr::get(value, context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
StringAttr Builder::getStringAttr(StringRef bytes) {
|
2018-07-10 10:59:53 -07:00
|
|
|
return StringAttr::get(bytes, context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
ArrayAttr Builder::getArrayAttr(ArrayRef<Attribute> value) {
|
2018-07-10 10:59:53 -07:00
|
|
|
return ArrayAttr::get(value, context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
AffineMapAttr Builder::getAffineMapAttr(AffineMap map) {
|
2018-10-09 16:39:24 -07:00
|
|
|
return AffineMapAttr::get(map);
|
2018-07-18 16:29:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-25 22:13:03 -07:00
|
|
|
IntegerSetAttr Builder::getIntegerSetAttr(IntegerSet set) {
|
|
|
|
return IntegerSetAttr::get(set);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
TypeAttr Builder::getTypeAttr(Type type) {
|
2018-08-03 01:54:46 -07:00
|
|
|
return TypeAttr::get(type, context);
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:46:10 -07:00
|
|
|
FunctionAttr Builder::getFunctionAttr(const Function *value) {
|
2018-08-19 21:17:22 -07:00
|
|
|
return FunctionAttr::get(value, context);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
ElementsAttr Builder::getSplatElementsAttr(VectorOrTensorType type,
|
2018-10-25 15:46:10 -07:00
|
|
|
Attribute elt) {
|
2018-10-10 08:57:51 -07:00
|
|
|
return SplatElementsAttr::get(type, elt);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
ElementsAttr Builder::getDenseElementsAttr(VectorOrTensorType type,
|
2018-10-25 15:46:10 -07:00
|
|
|
ArrayRef<char> data) {
|
2018-10-18 13:54:44 -07:00
|
|
|
return DenseElementsAttr::get(type, data);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
ElementsAttr Builder::getSparseElementsAttr(VectorOrTensorType type,
|
2018-10-25 15:46:10 -07:00
|
|
|
DenseIntElementsAttr indices,
|
|
|
|
DenseElementsAttr values) {
|
2018-10-23 13:44:04 -07:00
|
|
|
return SparseElementsAttr::get(type, indices, values);
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:59:22 -07:00
|
|
|
ElementsAttr Builder::getOpaqueElementsAttr(VectorOrTensorType type,
|
2018-10-25 15:46:10 -07:00
|
|
|
StringRef bytes) {
|
2018-10-23 13:44:04 -07:00
|
|
|
return OpaqueElementsAttr::get(type, bytes);
|
Add support to constant sparse tensor / vector attribute
The SparseElementsAttr uses (COO) Coordinate List encoding to represents a
sparse tensor / vector. Specifically, the coordinates and values are stored as
two dense elements attributes. The first dense elements attribute is a 2-D
attribute with shape [N, ndims], which contains the indices of the elements
with nonzero values in the constant vector/tensor. The second elements
attribute is a 1-D attribute list with shape [N], which supplies the values for
each element in the first elements attribute. ndims is the rank of the
vector/tensor and N is the total nonzero elements.
The syntax is:
`sparse<` (tensor-type | vector-type)`, ` indices-attribute-list, values-attribute-list `>`
Example: a sparse tensor
sparse<vector<3x4xi32>, [[0, 0], [1, 2]], [1, 2]> represents the dense tensor
[[1, 0, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 0]]
PiperOrigin-RevId: 217764319
2018-10-18 14:02:20 -07:00
|
|
|
}
|
|
|
|
|
2018-07-10 10:59:53 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-08-07 14:24:38 -07:00
|
|
|
// Affine Expressions, Affine Maps, and Integet Sets.
|
2018-07-10 10:59:53 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getAffineMap(unsigned dimCount, unsigned symbolCount,
|
|
|
|
ArrayRef<AffineExpr> results,
|
|
|
|
ArrayRef<AffineExpr> rangeSizes) {
|
2018-10-08 13:47:18 -07:00
|
|
|
return AffineMap::get(dimCount, symbolCount, results, rangeSizes);
|
2018-07-10 10:59:53 -07:00
|
|
|
}
|
|
|
|
|
2018-10-08 13:47:18 -07:00
|
|
|
AffineExpr Builder::getAffineDimExpr(unsigned position) {
|
2018-10-08 10:20:25 -07:00
|
|
|
return mlir::getAffineDimExpr(position, context);
|
2018-07-10 10:59:53 -07:00
|
|
|
}
|
|
|
|
|
2018-10-08 13:47:18 -07:00
|
|
|
AffineExpr Builder::getAffineSymbolExpr(unsigned position) {
|
2018-10-08 10:20:25 -07:00
|
|
|
return mlir::getAffineSymbolExpr(position, context);
|
2018-07-10 10:59:53 -07:00
|
|
|
}
|
|
|
|
|
2018-10-08 13:47:18 -07:00
|
|
|
AffineExpr Builder::getAffineConstantExpr(int64_t constant) {
|
2018-10-08 10:20:25 -07:00
|
|
|
return mlir::getAffineConstantExpr(constant, context);
|
2018-07-10 10:59:53 -07:00
|
|
|
}
|
|
|
|
|
2018-10-10 09:45:59 -07:00
|
|
|
IntegerSet Builder::getIntegerSet(unsigned dimCount, unsigned symbolCount,
|
|
|
|
ArrayRef<AffineExpr> constraints,
|
|
|
|
ArrayRef<bool> isEq) {
|
2018-10-25 08:33:02 -07:00
|
|
|
return IntegerSet::get(dimCount, symbolCount, constraints, isEq);
|
2018-08-07 14:24:38 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getConstantAffineMap(int64_t val) {
|
2018-10-03 15:39:12 -07:00
|
|
|
return AffineMap::get(/*dimCount=*/0, /*symbolCount=*/0,
|
2018-10-08 13:47:18 -07:00
|
|
|
{getAffineConstantExpr(val)}, {});
|
2018-08-24 23:38:14 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getDimIdentityMap() {
|
2018-10-08 10:20:25 -07:00
|
|
|
return AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0,
|
2018-10-08 13:47:18 -07:00
|
|
|
{getAffineDimExpr(0)}, {});
|
2018-08-24 23:38:14 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getMultiDimIdentityMap(unsigned rank) {
|
2018-10-08 13:47:18 -07:00
|
|
|
SmallVector<AffineExpr, 4> dimExprs;
|
2018-10-08 11:10:11 -07:00
|
|
|
dimExprs.reserve(rank);
|
|
|
|
for (unsigned i = 0; i < rank; ++i)
|
|
|
|
dimExprs.push_back(getAffineDimExpr(i));
|
2018-10-08 13:47:18 -07:00
|
|
|
return AffineMap::get(/*dimCount=*/rank, /*symbolCount=*/0, dimExprs, {});
|
2018-10-08 11:10:11 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getSymbolIdentityMap() {
|
2018-10-08 10:20:25 -07:00
|
|
|
return AffineMap::get(/*dimCount=*/0, /*symbolCount=*/1,
|
2018-10-08 13:47:18 -07:00
|
|
|
{getAffineSymbolExpr(0)}, {});
|
2018-08-24 23:38:14 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getSingleDimShiftAffineMap(int64_t shift) {
|
2018-10-03 15:34:57 -07:00
|
|
|
// expr = d0 + shift.
|
2018-10-08 10:20:25 -07:00
|
|
|
auto expr = getAffineDimExpr(0) + shift;
|
2018-10-08 13:47:18 -07:00
|
|
|
return AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0, {expr}, {});
|
2018-09-28 12:17:26 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) {
|
2018-10-08 13:47:18 -07:00
|
|
|
SmallVector<AffineExpr, 4> shiftedResults;
|
2018-10-09 16:39:24 -07:00
|
|
|
shiftedResults.reserve(map.getNumResults());
|
|
|
|
for (auto resultExpr : map.getResults()) {
|
2018-10-09 10:59:27 -07:00
|
|
|
shiftedResults.push_back(resultExpr + shift);
|
2018-09-28 12:17:26 -07:00
|
|
|
}
|
2018-10-09 16:39:24 -07:00
|
|
|
return AffineMap::get(map.getNumDims(), map.getNumSymbols(), shiftedResults,
|
|
|
|
map.getRangeSizes());
|
2018-09-28 12:17:26 -07:00
|
|
|
}
|
|
|
|
|
2018-07-19 09:52:39 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-07-24 10:15:13 -07:00
|
|
|
// CFG function elements.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-08-24 21:13:19 -07:00
|
|
|
/// Add new basic block and set the insertion point to the end of it. If an
|
|
|
|
/// 'insertBefore' basic block is passed, the block will be placed before the
|
|
|
|
/// specified block. If not, the block will be appended to the end of the
|
|
|
|
/// current function.
|
|
|
|
BasicBlock *CFGFuncBuilder::createBlock(BasicBlock *insertBefore) {
|
2018-07-24 10:15:13 -07:00
|
|
|
BasicBlock *b = new BasicBlock();
|
2018-08-24 21:13:19 -07:00
|
|
|
|
|
|
|
// If we are supposed to insert before a specific block, do so, otherwise add
|
|
|
|
// the block to the end of the function.
|
|
|
|
if (insertBefore)
|
|
|
|
function->getBlocks().insert(CFGFunction::iterator(insertBefore), b);
|
|
|
|
else
|
|
|
|
function->push_back(b);
|
|
|
|
|
2018-07-24 10:15:13 -07:00
|
|
|
setInsertionPoint(b);
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2018-08-07 09:12:35 -07:00
|
|
|
/// Create an operation given the fields represented as an OperationState.
|
|
|
|
OperationInst *CFGFuncBuilder::createOperation(const OperationState &state) {
|
|
|
|
SmallVector<CFGValue *, 8> operands;
|
|
|
|
operands.reserve(state.operands.size());
|
|
|
|
for (auto elt : state.operands)
|
|
|
|
operands.push_back(cast<CFGValue>(elt));
|
|
|
|
|
2018-08-23 14:32:25 -07:00
|
|
|
auto *op = OperationInst::create(state.location, state.name, operands,
|
|
|
|
state.types, state.attributes, context);
|
2018-08-07 09:12:35 -07:00
|
|
|
block->getOperations().insert(insertPoint, op);
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
2018-07-24 10:15:13 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Statements.
|
2018-07-19 09:52:39 -07:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-08-07 09:12:35 -07:00
|
|
|
/// Create an operation given the fields represented as an OperationState.
|
|
|
|
OperationStmt *MLFuncBuilder::createOperation(const OperationState &state) {
|
|
|
|
SmallVector<MLValue *, 8> operands;
|
|
|
|
operands.reserve(state.operands.size());
|
|
|
|
for (auto elt : state.operands)
|
|
|
|
operands.push_back(cast<MLValue>(elt));
|
|
|
|
|
2018-08-23 14:32:25 -07:00
|
|
|
auto *op = OperationStmt::create(state.location, state.name, operands,
|
|
|
|
state.types, state.attributes, context);
|
2018-08-07 09:12:35 -07:00
|
|
|
block->getStatements().insert(insertPoint, op);
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
2018-10-04 17:15:30 -07:00
|
|
|
/// Create an operation given the fields.
|
2018-11-08 12:28:35 -08:00
|
|
|
OperationStmt *MLFuncBuilder::createOperation(Location location,
|
2018-10-09 22:08:52 -07:00
|
|
|
OperationName name,
|
2018-10-04 17:15:30 -07:00
|
|
|
ArrayRef<MLValue *> operands,
|
2018-10-30 14:59:22 -07:00
|
|
|
ArrayRef<Type> types,
|
2018-10-04 17:15:30 -07:00
|
|
|
ArrayRef<NamedAttribute> attrs) {
|
|
|
|
auto *op = OperationStmt::create(location, name, operands, types, attrs,
|
|
|
|
getContext());
|
|
|
|
block->getStatements().insert(insertPoint, op);
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
2018-11-08 12:28:35 -08:00
|
|
|
ForStmt *MLFuncBuilder::createFor(Location location,
|
2018-08-24 23:38:14 -07:00
|
|
|
ArrayRef<MLValue *> lbOperands,
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap lbMap,
|
2018-08-24 23:38:14 -07:00
|
|
|
ArrayRef<MLValue *> ubOperands,
|
2018-10-09 16:39:24 -07:00
|
|
|
AffineMap ubMap, int64_t step) {
|
|
|
|
auto *stmt =
|
|
|
|
ForStmt::create(location, lbOperands, lbMap, ubOperands, ubMap, step);
|
2018-08-23 14:32:25 -07:00
|
|
|
block->getStatements().insert(insertPoint, stmt);
|
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
|
2018-11-08 12:28:35 -08:00
|
|
|
ForStmt *MLFuncBuilder::createFor(Location location, int64_t lb, int64_t ub,
|
2018-09-13 08:12:38 -07:00
|
|
|
int64_t step) {
|
2018-10-09 16:39:24 -07:00
|
|
|
auto lbMap = AffineMap::getConstantMap(lb, context);
|
|
|
|
auto ubMap = AffineMap::getConstantMap(ub, context);
|
2018-09-13 08:12:38 -07:00
|
|
|
return createFor(location, {}, lbMap, {}, ubMap, step);
|
|
|
|
}
|
|
|
|
|
2018-11-08 12:28:35 -08:00
|
|
|
IfStmt *MLFuncBuilder::createIf(Location location, ArrayRef<MLValue *> operands,
|
|
|
|
IntegerSet set) {
|
2018-08-28 15:26:20 -07:00
|
|
|
auto *stmt = IfStmt::create(location, operands, set);
|
2018-07-31 23:14:16 -07:00
|
|
|
block->getStatements().insert(insertPoint, stmt);
|
2018-07-19 09:52:39 -07:00
|
|
|
return stmt;
|
|
|
|
}
|