Math
math
The math dialect is intended to hold mathematical operations on integer and floating types beyond simple arithmetics.
See external documentation.
signlessIntegerLike = ContainerOf(AnyOf([SignlessIntegerConstraint, IndexType]))
module-attribute
floatingPointLike = ContainerOf(AnyFloatConstr)
module-attribute
Math = Dialect('math', [AbsFOp, AbsIOp, AcosOp, AcoshOp, AsinOp, AsinhOp, Atan2Op, AtanOp, AtanhOp, CbrtOp, CeilOp, CopySignOp, CosOp, CoshOp, CountLeadingZerosOp, CountTrailingZerosOp, CtPopOp, ErfOp, Exp2Op, ExpM1Op, ExpOp, FPowIOp, FloorOp, FmaOp, IPowIOp, Log10Op, Log1pOp, Log2Op, LogOp, PowFOp, RoundEvenOp, RoundOp, RsqrtOp, SinOp, SinhOp, SqrtOp, TanOp, TanhOp, TruncOp])
module-attribute
SignlessIntegerLikeUnaryMathOperation
Bases: IRDLOperation, ABC
A generic signless integer-like unary math operation.
Source code in xdsl/dialects/math.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
T: ClassVar = VarConstraint('T', signlessIntegerLike)
class-attribute
instance-attribute
operand = operand_def(T)
class-attribute
instance-attribute
result = result_def(T)
class-attribute
instance-attribute
assembly_format = '$operand attr-dict `:` type($result)'
class-attribute
instance-attribute
__init__(operand: Operation | SSAValue)
Source code in xdsl/dialects/math.py
47 48 49 50 51 52 | |
FloatingPointLikeUnaryMathOperation
Bases: IRDLOperation, ABC
A generic floating-point-like unary math operation with fastmath flags.
Source code in xdsl/dialects/math.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
T: ClassVar = VarConstraint('T', floatingPointLike)
class-attribute
instance-attribute
operand = operand_def(T)
class-attribute
instance-attribute
result = result_def(T)
class-attribute
instance-attribute
fastmath = prop_def(FastMathFlagsAttr, default_value=(FastMathFlagsAttr('none')))
class-attribute
instance-attribute
assembly_format = '$operand (`fastmath` `` $fastmath^)? attr-dict `:` type($result)'
class-attribute
instance-attribute
__init__(operand: Operation | SSAValue, fastmath: FastMathFlagsAttr | None = None)
Source code in xdsl/dialects/math.py
67 68 69 70 71 72 73 74 75 | |
SignlessIntegerLikeBinaryMathOperation
Bases: IRDLOperation, ABC
A generic signless integer-like binary math operation.
Source code in xdsl/dialects/math.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
T: ClassVar = VarConstraint('T', signlessIntegerLike)
class-attribute
instance-attribute
lhs = operand_def(T)
class-attribute
instance-attribute
rhs = operand_def(T)
class-attribute
instance-attribute
result = result_def(T)
class-attribute
instance-attribute
assembly_format = '$lhs `,` $rhs attr-dict `:` type($result)'
class-attribute
instance-attribute
__init__(lhs: Operation | SSAValue, rhs: Operation | SSAValue)
Source code in xdsl/dialects/math.py
89 90 91 92 93 94 95 96 97 | |
FloatingPointLikeBinaryMathOperation
Bases: IRDLOperation, ABC
A generic floating-point-like binary math operation.
Source code in xdsl/dialects/math.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
T: ClassVar = VarConstraint('T', floatingPointLike)
class-attribute
instance-attribute
lhs = operand_def(T)
class-attribute
instance-attribute
rhs = operand_def(T)
class-attribute
instance-attribute
result = result_def(T)
class-attribute
instance-attribute
fastmath = prop_def(FastMathFlagsAttr, default_value=(FastMathFlagsAttr('none')))
class-attribute
instance-attribute
assembly_format = '$lhs `,` $rhs (`fastmath` `` $fastmath^)? attr-dict `:` type($result)'
class-attribute
instance-attribute
__init__(lhs: Operation | SSAValue, rhs: Operation | SSAValue, fastmath: FastMathFlagsAttr | None = None)
Source code in xdsl/dialects/math.py
115 116 117 118 119 120 121 122 123 124 125 | |
AbsFOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The absf operation computes the absolute value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar absolute value. %a = math.absf %b : f64
Source code in xdsl/dialects/math.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
name = 'math.absf'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AbsIOp
dataclass
Bases: SignlessIntegerLikeUnaryMathOperation
The absi operation computes the absolute value. It takes one operand of integer type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar absolute value. %a = math.absi %b : i64
Source code in xdsl/dialects/math.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
name = 'math.absi'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AcosOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Arcus cosine of the specified value
The acos operation computes the arcus cosine of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Scalar arcus cosine value. %a = math.acos %b : f64
Source code in xdsl/dialects/math.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
name = 'math.acos'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AcoshOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Hyperbolic arcus cosine of the given value
The acosh operation computes the arcus cosine of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Hyperbolic arcus cosine of scalar value. %a = math.acosh %b : f64
Source code in xdsl/dialects/math.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
name = 'math.acosh'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AsinOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Arcus sine of the given value
The asin operation computes the arcus sine of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Arcus sine of scalar value. %a = math.asin %b : f64
Source code in xdsl/dialects/math.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
name = 'math.asin'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AsinhOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Hyperbolic arcus sine of the given value
The asinh operation computes the hyperbolic arcus sine of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Hyperbolic arcus sine of scalar value. %a = math.asinh %b : f64
Source code in xdsl/dialects/math.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
name = 'math.asinh'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AtanhOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Hyperbolic arcus tangent of the given value
The atanh operation computes the hyperbolic arcus tangent of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Hyperbolic arcus tangent of scalar value. %a = math.atanh %b : f64
Source code in xdsl/dialects/math.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
name = 'math.atanh'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
Atan2Op
dataclass
Bases: FloatingPointLikeBinaryMathOperation
The atan2 operation takes two operands and returns one result, all of which must be of the same type. The operands must be of floating point type (i.e., scalar, tensor or vector).
The 2-argument arcus tangent atan2(y, x) returns the angle in the
Euclidian plane between the positive x-axis and the ray through the point
(x, y). It is a generalization of the 1-argument arcus tangent which
returns the angle on the basis of the ratio y/x.
See also wikipedia.
Example:
// Scalar variant. %a = math.atan2 %b, %c : f32
Source code in xdsl/dialects/math.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
name = 'math.atan2'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
AtanOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The atan operation computes the arcus tangent of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Arcus tangent of scalar value. %a = math.atan %b : f64
Source code in xdsl/dialects/math.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
name = 'math.atan'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CbrtOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The cbrt operation computes the cube root. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar cube root value. %a = math.cbrt %b : f64
Note: This op is not equivalent to powf(..., 1/3.0).
Source code in xdsl/dialects/math.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
name = 'math.cbrt'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CeilOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The ceil operation computes the ceiling of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar ceiling value. %a = math.ceil %b : f64
Source code in xdsl/dialects/math.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
name = 'math.ceil'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CopySignOp
dataclass
Bases: FloatingPointLikeBinaryMathOperation
The copysign returns a value with the magnitude of the first operand and the sign of the second operand. It takes two operands and returns one result of the same type. The operands must be of floating point type (i.e., scalar, tensor or vector). It has no standard attributes.
Example:
// Scalar copysign value. %a = math.copysign %b, %c : f64
Source code in xdsl/dialects/math.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
name = 'math.copysign'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CosOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The cos operation computes the cosine of a given value. It takes one
operand of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar cosine value. %a = math.cos %b : f64
Source code in xdsl/dialects/math.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
name = 'math.cos'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CoshOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The cosh operation computes the hyperbolic cosine. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar hyperbolic cosine value. %a = math.cosh %b : f64
Source code in xdsl/dialects/math.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
name = 'math.cosh'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CountLeadingZerosOp
dataclass
Bases: SignlessIntegerLikeUnaryMathOperation
The ctlz operation computes the number of leading zeros of an integer value. It operates on scalar, tensor or vector.
Example:
// Scalar ctlz function value. %a = math.ctlz %b : i32
Source code in xdsl/dialects/math.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
name = 'math.ctlz'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CountTrailingZerosOp
dataclass
Bases: SignlessIntegerLikeUnaryMathOperation
The cttz operation computes the number of trailing zeros of an integer value. It operates on scalar, tensor or vector.
Example:
// Scalar cttz function value. %a = math.cttz %b : i32
Source code in xdsl/dialects/math.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
name = 'math.cttz'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
CtPopOp
dataclass
Bases: SignlessIntegerLikeUnaryMathOperation
The ctpop operation computes the number of set bits of an integer value. It operates on scalar, tensor or vector.
Example:
// Scalar ctpop function value. %a = math.ctpop %b : i32
Source code in xdsl/dialects/math.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
name = 'math.ctpop'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
ErfOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The erf operation computes the error function. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar error function value. %a = math.erf %b : f64
Source code in xdsl/dialects/math.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
name = 'math.erf'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
Exp2Op
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The exp operation takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar natural exponential. %a = math.exp2 %b : f64
Source code in xdsl/dialects/math.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
name = 'math.exp2'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
ExpM1Op
dataclass
Bases: FloatingPointLikeUnaryMathOperation
expm1(x) := exp(x) - 1
The expm1 operation takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar natural exponential minus 1. %a = math.expm1 %b : f64
Source code in xdsl/dialects/math.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
name = 'math.expm1'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
ExpOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The exp operation takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar natural exponential. %a = math.exp %b : f64
Source code in xdsl/dialects/math.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
name = 'math.exp'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
FPowIOp
Bases: IRDLOperation
The fpowi operation takes a base operand of floating point type
(i.e. scalar, tensor or vector) and a power operand of integer type
(also scalar, tensor or vector) and returns one result of the same type
as base. The result is base raised to the power of power.
The operation is elementwise for non-scalars, e.g.:
%v = math.fpowi %base, %power : vector<2xf32>, vector<2xi32>
The result is a vector of:
[
Example:
// Scalar exponentiation. %a = math.fpowi %base, %power : f64, i32
Source code in xdsl/dialects/math.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
name = 'math.fpowi'
class-attribute
instance-attribute
T: ClassVar = VarConstraint('T1', floatingPointLike)
class-attribute
instance-attribute
fastmath = prop_def(FastMathFlagsAttr, default_value=(FastMathFlagsAttr('none')))
class-attribute
instance-attribute
lhs = operand_def(T)
class-attribute
instance-attribute
rhs = operand_def(signlessIntegerLike)
class-attribute
instance-attribute
result = result_def(T)
class-attribute
instance-attribute
traits = traits_def(Pure())
class-attribute
instance-attribute
assembly_format = '$lhs `,` $rhs (`fastmath` `` $fastmath^)? attr-dict `:` type($lhs) `,` type($rhs)'
class-attribute
instance-attribute
__init__(lhs: Operation | SSAValue, rhs: Operation | SSAValue, fastmath: FastMathFlagsAttr | None = None)
Source code in xdsl/dialects/math.py
554 555 556 557 558 559 560 561 562 563 564 565 | |
FloorOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The floor operation computes the floor of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar floor value. %a = math.floor %b : f64
Source code in xdsl/dialects/math.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
name = 'math.floor'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
FmaOp
Bases: IRDLOperation
The fma operation takes three operands and returns one result, each of these is required to be the same type. Operands must be of floating point type (i.e., scalar, tensor or vector).
Example:
// Scalar fused multiply-add: d = a*b + c %d = math.fma %a, %b, %c : f64
The semantics of the operation correspond to those of the llvm.fma
intrinsic. In the
particular case of lowering to LLVM, this is guaranteed to lower
to the llvm.fma.* intrinsic.
Source code in xdsl/dialects/math.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
T: ClassVar = VarConstraint('T', floatingPointLike)
class-attribute
instance-attribute
name = 'math.fma'
class-attribute
instance-attribute
fastmath = prop_def(FastMathFlagsAttr, default_value=(FastMathFlagsAttr('none')))
class-attribute
instance-attribute
a = operand_def(T)
class-attribute
instance-attribute
b = operand_def(T)
class-attribute
instance-attribute
c = operand_def(T)
class-attribute
instance-attribute
result = result_def(T)
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
assembly_format = '$a `,` $b `,` $c (`fastmath` `` $fastmath^)? attr-dict `:` type($result)'
class-attribute
instance-attribute
__init__(a: Operation | SSAValue, b: Operation | SSAValue, c: Operation | SSAValue, fastmath: FastMathFlagsAttr | None = None)
Source code in xdsl/dialects/math.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
IPowIOp
dataclass
Bases: SignlessIntegerLikeBinaryMathOperation
The ipowi operation takes two operands of integer type (i.e., scalar, tensor or vector) and returns one result of the same type. Operands must have the same type.
Example: // Scalar signed integer exponentiation. %a = math.ipowi %b, %c : i32
Source code in xdsl/dialects/math.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
name = 'math.ipowi'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
Log10Op
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Computes the base-10 logarithm of the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar log10 operation. %y = math.log10 %x : f64
Source code in xdsl/dialects/math.py
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
name = 'math.log10'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
Log1pOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Computes the base-e logarithm of one plus the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
log1p(x) := log(1 + x)
Example:
// Scalar log1p operation. %y = math.log1p %x : f64
Source code in xdsl/dialects/math.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |
name = 'math.log1p'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
Log2Op
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Computes the base-2 logarithm of the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar log2 operation. %y = math.log2 %x : f64
Source code in xdsl/dialects/math.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
name = 'math.log2'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
LogOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
Computes the base-e logarithm of the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar log operation. %y = math.log %x : f64
Source code in xdsl/dialects/math.py
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
name = 'math.log'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
PowFOp
dataclass
Bases: FloatingPointLikeBinaryMathOperation
The powf operation takes two operands of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. Operands must have the same type.
Example:
// Scalar exponentiation. %a = math.powf %b, %c : f64
Source code in xdsl/dialects/math.py
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
name = 'math.powf'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
RoundEvenOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The roundeven operation returns the operand rounded to the nearest integer value in floating-point format. It takes one operand of floating point type (i.e., scalar, tensor or vector) and produces one result of the same type. The operation rounds the argument to the nearest integer value in floating-point format, rounding halfway cases to even, regardless of the current rounding direction.
Example:
// Scalar round operation. %a = math.roundeven %b : f64
Source code in xdsl/dialects/math.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | |
name = 'math.roundeven'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
RoundOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The round operation returns the operand rounded to the nearest integer value in floating-point format. It takes one operand of floating point type (i.e., scalar, tensor or vector) and produces one result of the same type. The operation rounds the argument to the nearest integer value in floating-point format, rounding halfway cases away from zero, regardless of the current rounding direction.
Example:
// Scalar round operation. %a = math.round %b : f64
Source code in xdsl/dialects/math.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | |
name = 'math.round'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
RsqrtOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The rsqrt operation computes the reciprocal of the square root. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Scalar reciprocal square root value. %a = math.rsqrt %b : f64
Source code in xdsl/dialects/math.py
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | |
name = 'math.rsqrt'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
SinOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The sin operation computes the sine of a given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar sine value. %a = math.sin %b : f64
Source code in xdsl/dialects/math.py
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | |
name = 'math.sin'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
SinhOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The sinh operation computes the hyperbolic sine. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar hyperbolic sine value. %a = math.sinh %b : f64
Source code in xdsl/dialects/math.py
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
name = 'math.sinh'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
SqrtOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The sqrt operation computes the square root. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example: // Scalar square root value. %a = math.sqrt %b : f64
Source code in xdsl/dialects/math.py
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | |
name = 'math.sqrt'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
TanOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The tan operation computes the tangent. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar tangent value. %a = math.tan %b : f64
Source code in xdsl/dialects/math.py
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
name = 'math.tan'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
TanhOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The tanh operation computes the hyperbolic tangent. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type. It has no standard attributes.
Example:
// Scalar hyperbolic tangent value. %a = math.tanh %b : f64
Source code in xdsl/dialects/math.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |
name = 'math.tanh'
class-attribute
instance-attribute
traits = traits_def(Pure(), SameOperandsAndResultType())
class-attribute
instance-attribute
TruncOp
dataclass
Bases: FloatingPointLikeUnaryMathOperation
The trunc operation returns the operand rounded to the nearest integer value in floating-point format. It takes one operand of floating point type (i.e., scalar, tensor or vector) and produces one result of the same type. The operation always rounds to the nearest integer not larger in magnitude than the operand, regardless of the current rounding direction.
Example:
// Scalar trunc operation. %a = math.trunc %b : f64
Source code in xdsl/dialects/math.py
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 | |