1//===- TensorBase.td - Base definitions for tensor dialect -*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef TENSOR_BASE 10#define TENSOR_BASE 11 12include "mlir/IR/OpBase.td" 13 14def Tensor_Dialect : Dialect { 15 let name = "tensor"; 16 let cppNamespace = "::mlir::tensor"; 17 18 let description = [{ 19 The `tensor` dialect is intended to hold core tensor creation and 20 manipulation ops, which are not strongly associated with any particular 21 other dialect or domain abstraction. The aim for ops in this dialect is 22 that they make sense for any tensor element type. When this is not the 23 case, the op is left to live in other dialects. Examples of element types 24 that could be supported by the `tensor` dialect include: 25 26 - representing large, dense aggregations of primitive types, suitable for 27 high-performance numerical computing. 28 - representing shapes in the `shape` dialect, which consist of small 1D 29 tensors of `index` data type. 30 - representing aggregations of strings or “variant” types. 31 - representing large, sparse aggregations of primitive types, suitable for 32 high-performance numerical computing. 33 34 Because of this broad element type support and because of the existence of 35 more dedicated dialects, such as the `sparse_tensor` and `linalg` dialects, 36 we prefer for now to keep the `tensor` dialect as small as possible. The 37 expectation is that at some point in the future, the `tensor` dialect’s 38 scope may be broadened through a careful discussion of the tradeoffs. 39 40 On the `tensor` type itself, note that it is actually a builtin type (it 41 lives in the builtin dialect), and does not live in this dialect. 42 Furthermore, a `tensor` is an immutable object. For example, this means 43 that a copy will always be made of the `tensor` object when it is passed to 44 the `dest` operand used by some ops in this dialect. As an optimization, 45 an implementation can eliminate these copies during lowering when they 46 are redundant and perform in-place mutation, see the [Destination-Passing 47 Style]( 48 https://mlir.llvm.org/docs/Bufferization/#destination-passing-style) 49 documentation for more information. 50 }]; 51 52 let hasCanonicalizer = 1; 53 let hasConstantMaterializer = 1; 54 let dependentDialects = [ 55 "affine::AffineDialect", 56 "arith::ArithDialect", 57 "complex::ComplexDialect", 58 ]; 59} 60 61#endif // TENSOR_BASE 62