xref: /llvm-project/mlir/include/mlir/Dialect/Math/IR/MathBase.td (revision 863c346209e27d22157fad21d0fd730e710a3441)
1//===- MathBase.td - Base definitions for math 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#ifndef MATH_BASE
9#define MATH_BASE
10include "mlir/IR/OpBase.td"
11def Math_Dialect : Dialect {
12  let name = "math";
13  let cppNamespace = "::mlir::math";
14  let description = [{
15    The math dialect is intended to hold mathematical operations on integer and
16    floating types beyond simple arithmetics. Each operation works on scalar, vector
17    or tensor type. On vector and tensor type operations apply elementwise unless
18    explicitly specified otherwise. As an example, the floating point absolute value
19    can be expressed as:
20
21    ```mlir
22    // Scalar absolute value.
23    %a = math.absf %b : f64
24
25    // Vector elementwise absolute value.
26    %f = math.absf %g : vector<4xf32>
27
28    // Tensor elementwise absolute value.
29    %x = math.absf %y : tensor<4x?xf8>
30    ```
31  }];
32  let hasConstantMaterializer = 1;
33  let dependentDialects = [
34    "::mlir::arith::ArithDialect"
35  ];
36}
37#endif // MATH_BASE
38