|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +"""TVM Script TIR Op""" |
| 18 | + |
| 19 | +from . import _ffi_api |
| 20 | + |
| 21 | + |
| 22 | +from tvm.tir.op import abs, popcount, nextafter, copysign, fmod |
| 23 | +from tvm.tir.op import ( |
| 24 | + floor, |
| 25 | + floordiv, |
| 26 | + floormod, |
| 27 | + ceil, |
| 28 | + round, |
| 29 | + trunc, |
| 30 | + truncdiv, |
| 31 | + truncmod, |
| 32 | + nearbyint, |
| 33 | +) |
| 34 | +from tvm.tir.op import ( |
| 35 | + hypot, |
| 36 | + ldexp, |
| 37 | + power, |
| 38 | + exp, |
| 39 | + exp2, |
| 40 | + exp10, |
| 41 | + erf, |
| 42 | + sqrt, |
| 43 | + rsqrt, |
| 44 | + log, |
| 45 | + log2, |
| 46 | + log10, |
| 47 | + log1p, |
| 48 | + sigmoid, |
| 49 | +) |
| 50 | +from tvm.tir.op import isnan, isfinite, isinf |
| 51 | +from tvm.tir.op import cos, cosh, sin, sinh, tan, tanh |
| 52 | +from tvm.tir.op import acos, acosh, asin, asinh, atan, atanh |
| 53 | +from tvm.tir.op import atan2, clz, comm_reducer, infinity, reinterpret |
| 54 | +from tvm.tir.op import min_value, max_value, if_then_else |
| 55 | +from tvm.tir.op import call_packed, call_extern |
| 56 | +from tvm.tir.expr import Select, Ramp, Broadcast, Shuffle |
| 57 | +from tvm.tir.generic import cast |
| 58 | + |
| 59 | + |
| 60 | +def boolean(expr): |
| 61 | + return _ffi_api.PrimType("bool", expr) |
| 62 | + |
| 63 | + |
| 64 | +def int8(expr): |
| 65 | + return _ffi_api.PrimType("int8", expr) |
| 66 | + |
| 67 | + |
| 68 | +def int16(expr): |
| 69 | + return _ffi_api.PrimType("int16", expr) |
| 70 | + |
| 71 | + |
| 72 | +def int32(expr): |
| 73 | + return _ffi_api.PrimType("int32", expr) |
| 74 | + |
| 75 | + |
| 76 | +def int64(expr): |
| 77 | + return _ffi_api.PrimType("int64", expr) |
| 78 | + |
| 79 | + |
| 80 | +def uint8(expr): |
| 81 | + return _ffi_api.PrimType("uint8", expr) |
| 82 | + |
| 83 | + |
| 84 | +def uint16(expr): |
| 85 | + return _ffi_api.PrimType("uint16", expr) |
| 86 | + |
| 87 | + |
| 88 | +def uint32(expr): |
| 89 | + return _ffi_api.PrimType("uint32", expr) |
| 90 | + |
| 91 | + |
| 92 | +def uint64(expr): |
| 93 | + return _ffi_api.PrimType("uint64", expr) |
| 94 | + |
| 95 | + |
| 96 | +def float8(expr): |
| 97 | + return _ffi_api.PrimType("float8", expr) |
| 98 | + |
| 99 | + |
| 100 | +def float16(expr): |
| 101 | + return _ffi_api.PrimType("float16", expr) |
| 102 | + |
| 103 | + |
| 104 | +def float32(expr): |
| 105 | + return _ffi_api.PrimType("float32", expr) |
| 106 | + |
| 107 | + |
| 108 | +def float64(expr): |
| 109 | + return _ffi_api.PrimType("float64", expr) |
| 110 | + |
| 111 | + |
| 112 | +def min(a, b, span=None): |
| 113 | + """Compute the minimum value of two expressions. |
| 114 | +
|
| 115 | + Parameters |
| 116 | + ---------- |
| 117 | + a : PrimExpr |
| 118 | + The left hand operand |
| 119 | +
|
| 120 | + b : PrimExpr |
| 121 | + The right hand operand |
| 122 | +
|
| 123 | + span : Optional[Span] |
| 124 | + The location of this operator in the source. |
| 125 | +
|
| 126 | + Returns |
| 127 | + ------- |
| 128 | + res : PrimExpr |
| 129 | + The result expression. |
| 130 | +
|
| 131 | + Note |
| 132 | + ---- |
| 133 | + This is the default integer division behavior in C. |
| 134 | + """ |
| 135 | + return _ffi_api.min(a, b, span) # type: ignore |
| 136 | + |
| 137 | + |
| 138 | +def max(a, b, span=None): |
| 139 | + """Compute the maximum value of two expressions. |
| 140 | +
|
| 141 | + Parameters |
| 142 | + ---------- |
| 143 | + a : PrimExpr |
| 144 | + The left hand operand |
| 145 | +
|
| 146 | + b : PrimExpr |
| 147 | + The right hand operand |
| 148 | +
|
| 149 | + span : Optional[Span] |
| 150 | + The location of this operator in the source. |
| 151 | +
|
| 152 | + Returns |
| 153 | + ------- |
| 154 | + res : PrimExpr |
| 155 | + The result expression. |
| 156 | +
|
| 157 | + Note |
| 158 | + ---- |
| 159 | + This is the default integer division behavior in C. |
| 160 | + """ |
| 161 | + return _ffi_api.max(a, b, span) # type: ignore |
0 commit comments