tvm
Loading...
Searching...
No Matches
elemwise.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
24#ifndef TVM_TOPI_ELEMWISE_H_
25#define TVM_TOPI_ELEMWISE_H_
26
27#include <tvm/ir/prim/expr.h>
28#include <tvm/ir/prim/op.h>
29#include <tvm/tirx/op/math.h>
30#include <tvm/tirx/op/memory.h>
31#include <tvm/topi/tags.h>
32
33#include <algorithm>
34#include <string>
35
36#include "broadcast.h"
37
38namespace tvm {
39namespace topi {
40using namespace tvm::te;
41
42// Unary intrinsic operators
43#define TOPI_DECLARE_UNARY_OP(OpName, ExprFunc) \
44 inline Tensor OpName(const Tensor& x, std::string name = "T_" #OpName, \
45 std::string tag = kElementWise) { \
46 return compute( \
47 x->shape, [&](const ffi::Array<PrimVar>& i) { return ExprFunc(x(i)); }, name, tag); \
48 }
49
77
82inline Tensor fast_tanh_float(const Tensor& in, std::string name, std::string tag) {
83 using namespace tvm::prim;
84 // Clamp the inputs to the range [-9, 9] since anything outside
85 // this range is +/-1.0f in single-precision.
86 PrimType input_type = in->GetDataType();
87 auto x = maximum(MakeConst(input_type, -9.0), minimum(MakeConst(input_type, 9.0), in));
88
89 // The monomial coefficients of the numerator polynomial (odd).
90 auto alpha_1 = MakeConst(input_type, 4.89352455891786e-03);
91 auto alpha_3 = MakeConst(input_type, 6.37261928875436e-04);
92 auto alpha_5 = MakeConst(input_type, 1.48572235717979e-05);
93 auto alpha_7 = MakeConst(input_type, 5.12229709037114e-08);
94 auto alpha_9 = MakeConst(input_type, -8.60467152213735e-11);
95 auto alpha_11 = MakeConst(input_type, 2.00018790482477e-13);
96 auto alpha_13 = MakeConst(input_type, -2.76076847742355e-16);
97
98 // The monomial coefficients of the denominator polynomial (even).
99 auto beta_0 = MakeConst(input_type, 4.89352518554385e-03);
100 auto beta_2 = MakeConst(input_type, 2.26843463243900e-03);
101 auto beta_4 = MakeConst(input_type, 1.18534705686654e-04);
102 auto beta_6 = MakeConst(input_type, 1.19825839466702e-06);
103
104 return compute(
105 x->shape,
106 [&](const ffi::Array<PrimVar>& i) {
107 auto x2 = x(i) * x(i);
108 auto p = x2 * alpha_13 + alpha_11;
109 p = x2 * p + alpha_9;
110 p = x2 * p + alpha_7;
111 p = x2 * p + alpha_5;
112 p = x2 * p + alpha_3;
113 p = x2 * p + alpha_1;
114 p = x(i) * p;
115
116 auto q = x2 * beta_6 + beta_4;
117 q = x2 * q + beta_2;
118 q = x2 * q + beta_0;
119 return p / q;
120 },
121 name, tag);
122}
123
133inline Tensor fast_tanh(const Tensor& x, std::string name = "T_fast_tanh",
134 std::string tag = kElementWise) {
135 if (x->GetDataType().MatchesElementType(DLDataTypeCode::kDLFloat, 32)) {
136 // invoke fast_tanh_float implementation
137 return fast_tanh_float(x, name, tag);
138 } else {
139 // fallback to default implementation
140 return compute(
141 x->shape, [&](const ffi::Array<PrimVar>& i) { return ::tvm::prim::tanh(x(i)); }, name, tag);
142 }
143}
144
154inline Tensor identity(const Tensor& x, std::string name = "T_identity",
155 std::string tag = kElementWise) {
156 return compute(x->shape, [&](const ffi::Array<PrimVar>& i) { return x(i); }, name, tag);
157}
158
168inline Tensor negative(const Tensor& x, std::string name = "T_negative",
169 std::string tag = kElementWise) {
170 return compute(x->shape, [&](const ffi::Array<PrimVar>& i) { return -x(i); }, name, tag);
171}
172
182inline Tensor logical_not(const Tensor& x, std::string name = "T_logical_not",
183 std::string tag = kElementWise) {
184 return compute(x->shape, [&](const ffi::Array<PrimVar>& i) { return !x(i); }, name, tag);
185}
186
196inline Tensor bitwise_not(const Tensor& x, std::string name = "T_bitwise_not",
197 std::string tag = kElementWise) {
198 return compute(x->shape, [&](const ffi::Array<PrimVar>& i) { return ~x(i); }, name, tag);
199}
200
210inline Tensor sign(const Tensor& x, std::string name = "T_sign", std::string tag = kElementWise) {
211 using namespace tvm::prim;
212 return compute(
213 x->shape,
214 [&](const ffi::Array<PrimVar>& i) {
215 PrimType x_type(x->GetDataType());
216 PrimExpr zero = MakeConst(x_type, 0);
217 PrimExpr one = MakeConst(x_type, 1);
218 PrimExpr minus_one = MakeConst(x_type, -1);
219 auto s1 = tvm::prim::Select((x(i) < zero), minus_one, zero);
220 auto s2 = tvm::prim::Select((x(i) > zero), one, s1);
221 return s2;
222 },
223 name, tag);
224}
225
235inline Tensor rsqrt(const Tensor& x, std::string name = "tensor", std::string tag = kElementWise) {
236 using namespace tvm::prim;
237 return compute(
238 x->shape,
239 [&](const ffi::Array<PrimVar>& i) {
240 PrimExpr one = MakeConst(x->GetDataType(), 1);
241 return one / tvm::prim::sqrt(x(i));
242 },
243 name, tag);
244}
245
258inline Tensor clip(const Tensor& x, const PrimExpr& a_min, const PrimExpr& a_max,
259 std::string name = "T_clip", std::string tag = kElementWise) {
260 return compute(
261 x->shape,
262 [&](const ffi::Array<PrimVar>& i) {
263 PrimType x_type(x->GetDataType());
264 auto min_val = tvm::prim::cast(x_type, a_min);
265 auto max_val = tvm::prim::cast(x_type, a_max);
266 return tvm::max(tvm::min(x(i), max_val), min_val); // NOLINT(*)
267 },
268 name, tag);
269}
270
283inline Tensor cast(const Tensor& x, PrimType type, std::string name, std::string tag);
284
285inline Tensor cast(const Tensor& x, DLDataType type, std::string name = "T_cast",
286 std::string tag = kElementWise) {
287 using namespace tvm::prim;
288 return cast(x, PrimType(type), std::move(name), std::move(tag));
289}
290
291inline Tensor cast(const Tensor& x, PrimType type, std::string name = "T_cast",
292 std::string tag = kElementWise) {
293 return compute(
294 x->shape,
295 [&](const ffi::Array<PrimVar>& i) -> PrimExpr {
296 auto expr = x(i);
297 PrimType expr_ty = expr.ty();
298 if (expr_ty.MatchesElementType(type.code(), type.bits())) {
299 if (expr_ty.lanes() == type.lanes()) {
300 return expr;
301 } else if (expr_ty.lanes() == 1 && type.IsFixedLengthVector()) {
302 return tvm::prim::Broadcast(expr, type.lanes());
303 }
304 }
305
306 return tvm::prim::cast(type, x(i));
307 },
308 name, tag);
309}
310
321inline Tensor reinterpret(const Tensor& x, PrimType type, std::string name, std::string tag);
322
323inline Tensor reinterpret(const Tensor& x, DLDataType type, std::string name = "tensor",
324 std::string tag = kElementWise) {
325 using namespace tvm::prim;
326 return reinterpret(x, PrimType(type), std::move(name), std::move(tag));
327}
328
329inline Tensor reinterpret(const Tensor& x, PrimType type, std::string name = "tensor",
330 std::string tag = kElementWise) {
331 return compute(
332 x->shape, [&](const ffi::Array<PrimVar>& i) { return tirx::reinterpret(type, x(i)); }, name,
333 tag);
334}
335
345inline Tensor elemwise_sum(const ffi::Array<Tensor>& xs, std::string name = "T_elemwise_sum",
346 std::string tag = kElementWise) {
347 TVM_FFI_ICHECK_GT(xs.size(), 0) << "elemwise sum must have at least one input tensor.";
348 return compute(
349 xs[0]->shape,
350 [&](const ffi::Array<PrimVar>& i) {
351 auto sum_expr = xs[0](i);
352 for (size_t j = 1; j < xs.size(); j++) {
353 sum_expr = sum_expr + xs[j](i);
354 }
355 return sum_expr;
356 },
357 name, tag);
358}
359
371inline Tensor full(const ffi::Array<PrimExpr>& shape, PrimType dtype, const PrimExpr fill_value,
372 std::string name, std::string tag);
373
374inline Tensor full(const ffi::Array<PrimExpr>& shape, DLDataType dtype, const PrimExpr fill_value,
375 std::string name = "T_full", std::string tag = kElementWise) {
376 return full(shape, PrimType(dtype), fill_value, std::move(name), std::move(tag));
377}
378
379inline Tensor full(const ffi::Array<PrimExpr>& shape, PrimType dtype, const PrimExpr fill_value,
380 std::string name = "T_full", std::string tag = kElementWise) {
381 PrimExpr ev = prim::cast(dtype, fill_value);
382 if (!ev.defined()) {
383 LOG(ERROR) << "Can't cast fill_value to " << dtype;
384 }
385 return compute(shape, [&](const ffi::Array<PrimVar>& i) { return ev; }, name, tag);
386}
387
399inline Tensor full_like(const Tensor& x, const PrimExpr fill_value,
400 std::string name = "T_full_like", std::string tag = kElementWise) {
401 PrimExpr ev = prim::cast(x->GetDataType(), fill_value);
402 return compute(x->shape, [&](const ffi::Array<PrimVar>& i) { return ev; }, name, tag);
403}
404
426inline Tensor fast_exp_float32(const Tensor& _x, std::string name, std::string tag) {
427 PrimType f32_ty = PrimType::Float(32);
428 auto x_hi = FloatImm(f32_ty, 88.3762626647950f);
429 auto x_lo = FloatImm(f32_ty, -88.3762626647949f);
430 auto log2e = FloatImm(f32_ty, 1.44269504088896341f);
431 auto ln2 = FloatImm(f32_ty, 0.6931471805599453f);
432 PrimExpr p[6] = {FloatImm(f32_ty, 1.9875691500E-4f), FloatImm(f32_ty, 1.3981999507E-3f),
433 FloatImm(f32_ty, 8.3334519073E-3f), FloatImm(f32_ty, 4.1665795894E-2f),
434 FloatImm(f32_ty, 1.6666665459E-1f), FloatImm(f32_ty, 5.0000001201E-1f)};
435 auto one = FloatImm(f32_ty, 1.0f);
436 auto one_half = FloatImm(f32_ty, 0.5f);
437 auto b = FloatImm(f32_ty, 127.0f);
438
439 return compute(
440 _x->shape,
441 [&](const ffi::Array<PrimVar>& i) {
442 // clamp x
443 auto x = ::tvm::max(::tvm::min(_x(i), x_hi), x_lo);
444 // integer part
445 auto n = ::tvm::prim::floor(x * log2e + one_half);
446 // fractional part
447 auto f = x - n * ln2;
448 auto y =
449 (((((p[0] * f + p[1]) * f + p[2]) * f + p[3]) * f + p[4]) * f + p[5]) * f * f + f + one;
450 // Return 2^m * exp(r).
451 auto ef = tvm::tirx::reinterpret(PrimType::Float(32),
452 ::tvm::prim::cast(PrimType::Int(32), n + b) << 23);
453 return ::tvm::max(ef * y, _x(i)); // NOLINT(*)
454 },
455 name, tag);
456}
457
468inline Tensor fast_exp(const Tensor& x, std::string name = "T_fast_exp",
469 std::string tag = kElementWise) {
470 if (x->GetDataType().MatchesElementType(DLDataTypeCode::kDLFloat, 32)) {
471 auto ret = fast_exp_float32(x, name, tag);
472 return ret;
473 } else {
474 return compute(
475 x->shape, [&](const ffi::Array<PrimVar>& i) { return ::tvm::prim::exp(x(i)); }, name, tag);
476 }
477}
478
482inline Tensor fast_erf_float32(const Tensor& data, std::string name, std::string tag) {
483 using namespace tvm::prim;
484 return compute(
485 data->shape,
486 [&](const ffi::Array<PrimVar>& i) { return tirx::fast_erf_float_expr(data(i), 32); }, name,
487 tag);
488}
489
493inline Tensor fast_erf_float16(const Tensor& data, std::string name, std::string tag) {
494 using namespace tvm::prim;
495 return compute(
496 data->shape,
497 [&](const ffi::Array<PrimVar>& i) { return tirx::fast_erf_float_expr(data(i), 16); }, name,
498 tag);
499}
500
510inline Tensor fast_erf(const Tensor& x, std::string name = "T_fast_erf",
511 std::string tag = kElementWise) {
512 PrimType x_type(x->GetDataType());
513 if (x_type.MatchesElementType(DLDataTypeCode::kDLFloat, 32)) {
514 auto ret = fast_erf_float32(x, name, tag);
515 return ret;
516 } else if (x_type.MatchesElementType(DLDataTypeCode::kDLFloat, 16)) {
517 auto ret = fast_erf_float16(x, name, tag);
518 return ret;
519 } else {
520 return topi::erf(x);
521 }
522}
523
524} // namespace topi
525} // namespace tvm
526#endif // TVM_TOPI_ELEMWISE_H_
Managed reference class to FloatImmNode.
Definition expr.h:232
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Definition base_expr.h:161
TVM_FFI_INLINE bool MatchesElementType(DLDataTypeCode code, int bits) const
Check the scalar element code and bit width.
Definition base_expr.h:222
static TVM_TIRX_DLL PrimType Float(int bits, int lanes=1)
Construct a floating-point type with fixed lanes.
Tensor structure representing a possible input, or intermediate computation result.
Definition tensor.h:111
Detail broadcast.
#define TOPI_DECLARE_UNARY_OP(OpName, ExprFunc)
Definition elemwise.h:43
TIR expressions.
Shared primitive construction and constant helpers.
Specialized mathematical expression builders.
Definition expr.h:47
PrimExpr acos(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1021
PrimExpr sin(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1018
PrimExpr asin(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1020
PrimExpr cos(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1016
PrimExpr atanh(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1025
PrimExpr sinh(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1019
TVM_TIRX_DLL PrimExpr isfinite(PrimExpr x, Location loc=UnknownLoc())
Check if x is finite.
TVM_TIRX_DLL PrimExpr isnan(PrimExpr x, Location loc=UnknownLoc())
Check if x is NaN.
PrimExpr cosh(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1017
TVM_TIRX_DLL PrimExpr trunc(PrimExpr x, Location loc=UnknownLoc())
Calculate trunc(x)
TVM_TIRX_DLL PrimExpr isinf(PrimExpr x, Location loc=UnknownLoc())
Check if x is infinite.
TVM_TIRX_DLL PrimExpr floor(PrimExpr x, Location loc=UnknownLoc())
Calculate floor(x)
PrimExpr tan(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1015
PrimExpr asinh(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1024
PrimExpr erf(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1006
PrimExpr sqrt(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1009
PrimExpr log(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1011
PrimExpr exp(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1003
PrimExpr acosh(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1023
TVM_TIRX_DLL PrimExpr round(PrimExpr x, Location loc=UnknownLoc())
Round x to the nearest integer, ties to even.
TVM_TIRX_DLL PrimExpr abs(PrimExpr x, Location loc=UnknownLoc())
Calculate absolute value of x.
PrimExpr log10(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1012
TVM_TIRX_DLL PrimExpr cast(PrimType t, PrimExpr value, Location loc=UnknownLoc())
cast value to type.
PrimExpr sigmoid(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1008
PrimExpr atan(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1022
PrimExpr tanh(PrimExpr x, Location loc=UnknownLoc())
Definition op.h:1007
Tensor expression language DSL.
Definition extracted_task.h:33
Tensor compute(ffi::Array< PrimExpr > shape, FCompute fcompute, std::string name="tensor", std::string tag="", ffi::Map< ffi::String, ffi::Any > attrs={})
Construct a new tensor by computing over shape, using the computation rule: result_tensor[axis] = fco...
TVM_TIRX_DLL Expr reinterpret(Type target_ty, Expr value, Location loc=UnknownLoc())
perform reinterpret cast value to type.
constexpr auto kElementWise
Definition tags.h:32
Tensor clip(const Tensor &x, const PrimExpr &a_min, const PrimExpr &a_max, std::string name="T_clip", std::string tag=kElementWise)
Creates an operation that clips each element of a tensor to the interval [a_min, a_max].
Definition elemwise.h:258
Tensor ceil(const Tensor &x, std::string name="T_" "ceil", std::string tag=kElementWise)
Definition elemwise.h:58
Tensor isinf(const Tensor &x, std::string name="T_" "isinf", std::string tag=kElementWise)
Definition elemwise.h:76
Tensor shape(const Tensor &src, PrimType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition transform.h:2016
Tensor round(const Tensor &x, std::string name="T_" "round", std::string tag=kElementWise)
Definition elemwise.h:59
Tensor tan(const Tensor &x, std::string name="T_" "tan", std::string tag=kElementWise)
Definition elemwise.h:64
Tensor logical_not(const Tensor &x, std::string name="T_logical_not", std::string tag=kElementWise)
Creates an operation that returns the logical NOT of a given tensor.
Definition elemwise.h:182
Tensor fast_erf_float32(const Tensor &data, std::string name, std::string tag)
Fast_erf_float expression from Eigen.
Definition elemwise.h:482
Tensor floor(const Tensor &x, std::string name="T_" "floor", std::string tag=kElementWise)
Definition elemwise.h:57
Tensor trunc(const Tensor &x, std::string name="T_" "trunc", std::string tag=kElementWise)
Definition elemwise.h:60
Tensor isnan(const Tensor &x, std::string name="T_" "isnan", std::string tag=kElementWise)
Definition elemwise.h:73
Tensor fast_erf_float16(const Tensor &data, std::string name, std::string tag)
Fast_erf_float expression from Eigen for float16.
Definition elemwise.h:493
Tensor exp(const Tensor &x, std::string name="T_" "exp", std::string tag=kElementWise)
Definition elemwise.h:50
Tensor acos(const Tensor &x, std::string name="T_" "acos", std::string tag=kElementWise)
Definition elemwise.h:67
Tensor asinh(const Tensor &x, std::string name="T_" "asinh", std::string tag=kElementWise)
Definition elemwise.h:70
Tensor log(const Tensor &x, std::string name="T_" "log", std::string tag=kElementWise)
Definition elemwise.h:54
Tensor fast_tanh_float(const Tensor &in, std::string name, std::string tag)
Fast_tanh_float implementation from Eigen https://github.com/eigenteam/eigen-git-mirror/blob/master/E...
Definition elemwise.h:82
Tensor fast_tanh(const Tensor &x, std::string name="T_fast_tanh", std::string tag=kElementWise)
Creates an operation that returns hyperbolic tanh of a given tensor.
Definition elemwise.h:133
Tensor fast_erf(const Tensor &x, std::string name="T_fast_erf", std::string tag=kElementWise)
Fast erf implementation.
Definition elemwise.h:510
Tensor cos(const Tensor &x, std::string name="T_" "cos", std::string tag=kElementWise)
Definition elemwise.h:62
tvm::PrimExpr minimum(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition broadcast.h:376
Tensor sqrt(const Tensor &x, std::string name="T_" "sqrt", std::string tag=kElementWise)
Definition elemwise.h:53
Tensor rsqrt(const Tensor &x, std::string name="tensor", std::string tag=kElementWise)
Creates an operation that returns rsqrt of a given tensor.
Definition elemwise.h:235
Tensor abs(const Tensor &x, std::string name="T_" "abs", std::string tag=kElementWise)
Definition elemwise.h:61
Tensor asin(const Tensor &x, std::string name="T_" "asin", std::string tag=kElementWise)
Definition elemwise.h:69
Tensor bitwise_not(const Tensor &x, std::string name="T_bitwise_not", std::string tag=kElementWise)
Creates an operation that returns the bitwise NOT of a given tensor.
Definition elemwise.h:196
Tensor atan(const Tensor &x, std::string name="T_" "atan", std::string tag=kElementWise)
Definition elemwise.h:71
Tensor atanh(const Tensor &x, std::string name="T_" "atanh", std::string tag=kElementWise)
Definition elemwise.h:72
Tensor log10(const Tensor &x, std::string name="T_" "log10", std::string tag=kElementWise)
Definition elemwise.h:56
Tensor sigmoid(const Tensor &x, std::string name="T_" "sigmoid", std::string tag=kElementWise)
Definition elemwise.h:52
Tensor identity(const Tensor &x, std::string name="T_identity", std::string tag=kElementWise)
Creates an operation that returns identity of a given tensor.
Definition elemwise.h:154
Tensor isfinite(const Tensor &x, std::string name="T_" "isfinite", std::string tag=kElementWise)
Definition elemwise.h:75
Tensor log2(const Tensor &x, std::string name="T_" "log2", std::string tag=kElementWise)
Definition elemwise.h:55
Tensor elemwise_sum(const ffi::Array< Tensor > &xs, std::string name="T_elemwise_sum", std::string tag=kElementWise)
Creates an operation that sum each element of a tensor.
Definition elemwise.h:345
Tensor cosh(const Tensor &x, std::string name="T_" "cosh", std::string tag=kElementWise)
Definition elemwise.h:63
Tensor acosh(const Tensor &x, std::string name="T_" "acosh", std::string tag=kElementWise)
Definition elemwise.h:68
Tensor full(const ffi::Array< PrimExpr > &shape, PrimType dtype, const PrimExpr fill_value, std::string name, std::string tag)
Creates an operation that fill a tensor with fill_value.
Definition elemwise.h:379
Tensor sin(const Tensor &x, std::string name="T_" "sin", std::string tag=kElementWise)
Definition elemwise.h:65
Tensor tanh(const Tensor &x, std::string name="T_" "tanh", std::string tag=kElementWise)
Definition elemwise.h:74
Tensor full_like(const Tensor &x, const PrimExpr fill_value, std::string name="T_full_like", std::string tag=kElementWise)
Creates an operation that construct a tensor with same shape as input tensor, then fill a tensor with...
Definition elemwise.h:399
Tensor erf(const Tensor &x, std::string name="T_" "erf", std::string tag=kElementWise)
Definition elemwise.h:51
Tensor fast_exp(const Tensor &x, std::string name="T_fast_exp", std::string tag=kElementWise)
Fast exponential function implementation.
Definition elemwise.h:468
Tensor cast(const Tensor &x, PrimType type, std::string name, std::string tag)
Cast each element of x to the given type. If expr is scalar and type is a corresponding vector type,...
Definition elemwise.h:291
Tensor sign(const Tensor &x, std::string name="T_sign", std::string tag=kElementWise)
Returns the sign of the tensor.
Definition elemwise.h:210
Tensor negative(const Tensor &x, std::string name="T_negative", std::string tag=kElementWise)
Creates an operation that returns the negation of a given tensor.
Definition elemwise.h:168
Tensor sinh(const Tensor &x, std::string name="T_" "sinh", std::string tag=kElementWise)
Definition elemwise.h:66
tvm::PrimExpr maximum(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition broadcast.h:363
Tensor fast_exp_float32(const Tensor &_x, std::string name, std::string tag)
Fast exponential function implementation.
Definition elemwise.h:426
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
TVM_TIRX_DLL PrimExpr log2(PrimExpr x, Location loc=UnknownLoc())
Construct a base-two logarithm with the input's primitive type.
TVM_TIRX_DLL PrimExpr ceil(PrimExpr x, Location loc=UnknownLoc())
Round up to the nearest integral value, preserving the input type.
Tag definitions.
Memory operations for TIRx.