tvm
Loading...
Searching...
No Matches
vector_expr.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 */
23#ifndef TVM_IR_PRIM_VECTOR_EXPR_H_
24#define TVM_IR_PRIM_VECTOR_EXPR_H_
25
26#include <tvm/ffi/container/array.h>
27#include <tvm/ir/cow.h>
28#include <tvm/ir/expr.h>
29
30namespace tvm {
31namespace prim {
32
45class RampObj : public ExprObj {
46 public:
48 : base(std::move(base)), stride(std::move(stride)), lanes(std::move(lanes)) {}
49 explicit RampObj(ffi::UnsafeInit tag) : base(tag), stride(tag), lanes(tag) {}
50
57 static void RegisterReflection() {
58 namespace refl = tvm::ffi::reflection;
59 refl::ObjectDef<RampObj>()
60 .def_ro("base", &RampObj::base)
61 .def_ro("stride", &RampObj::stride)
62 .def_ro("lanes", &RampObj::lanes);
63 }
65};
66
71class Ramp : public PrimExpr {
72 public:
74 explicit Ramp(ffi::ObjectPtr<RampObj> node) : PrimExpr(std::move(node)) {}
75
77 static constexpr bool _type_container_is_exact = true;
79};
80
82class BroadcastObj : public ExprObj {
83 public:
84 BroadcastObj(PrimExpr value, PrimExpr lanes) : value(std::move(value)), lanes(std::move(lanes)) {}
85 explicit BroadcastObj(ffi::UnsafeInit tag) : value(tag), lanes(tag) {}
86
91 static void RegisterReflection() {
92 namespace refl = tvm::ffi::reflection;
93 refl::ObjectDef<BroadcastObj>()
94 .def_ro("value", &BroadcastObj::value)
95 .def_ro("lanes", &BroadcastObj::lanes);
96 }
98};
99
104class Broadcast : public PrimExpr {
105 public:
107 explicit Broadcast(ffi::ObjectPtr<BroadcastObj> node) : PrimExpr(std::move(node)) {}
108
110 static constexpr bool _type_container_is_exact = true;
112};
113
119class ShuffleObj : public ExprObj {
120 public:
122 ffi::Array<PrimExpr> vectors;
124 ffi::Array<PrimExpr> indices;
125 static void RegisterReflection() {
126 namespace refl = tvm::ffi::reflection;
127 refl::ObjectDef<ShuffleObj>()
128 .def_ro("vectors", &ShuffleObj::vectors)
129 .def_ro("indices", &ShuffleObj::indices);
130 }
132};
133
138class Shuffle : public PrimExpr {
139 public:
140 TVM_TIRX_DLL Shuffle(ffi::Array<PrimExpr> vectors, ffi::Array<PrimExpr> indices,
141 Location loc = UnknownLoc());
142 TVM_TIRX_DLL static PrimExpr Concat(ffi::Array<PrimExpr> vectors, Location loc = UnknownLoc());
144 Location loc = UnknownLoc());
145 explicit Shuffle(ffi::ObjectPtr<ShuffleObj> node) : PrimExpr(std::move(node)) {}
146
148 static constexpr bool _type_container_is_exact = true;
150};
151
152} // namespace prim
153} // namespace tvm
154#endif // TVM_IR_PRIM_VECTOR_EXPR_H_
Base expr nodes in TVM.
#define TVM_TIRX_DLL
Definition base.h:55
Base type of all the expressions.
Definition expr.h:66
Non-nullable source-location metadata.
Definition location.h:91
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Reference to the shared immutable unknown location.
Definition location.h:105
Create a vector where all the elements are value.
Definition vector_expr.h:82
PrimExpr lanes
The number of lanes.
Definition vector_expr.h:90
static void RegisterReflection()
Definition vector_expr.h:91
BroadcastObj(PrimExpr value, PrimExpr lanes)
Definition vector_expr.h:84
BroadcastObj(ffi::UnsafeInit tag)
Definition vector_expr.h:85
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Broadcast", BroadcastObj, ExprObj)
PrimExpr value
The base value.
Definition vector_expr.h:88
Managed reference to BroadcastObj.
Definition vector_expr.h:104
TVM_DEFINE_OBJECT_REF_COW_METHOD(BroadcastObj)
Broadcast(ffi::ObjectPtr< BroadcastObj > node)
Definition vector_expr.h:107
TVM_TIRX_DLL Broadcast(PrimExpr value, PrimExpr lanes, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition vector_expr.h:110
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Broadcast, PrimExpr, BroadcastObj)
Construct a vector with lanes elements where its i-th element equals base + i * stride....
Definition vector_expr.h:45
static void RegisterReflection()
Definition vector_expr.h:57
RampObj(ffi::UnsafeInit tag)
Definition vector_expr.h:49
RampObj(PrimExpr base, PrimExpr stride, PrimExpr lanes)
Definition vector_expr.h:47
PrimExpr base
The base value.
Definition vector_expr.h:52
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Ramp", RampObj, ExprObj)
PrimExpr lanes
Total number of lanes.
Definition vector_expr.h:56
PrimExpr stride
The stride of each step.
Definition vector_expr.h:54
Managed reference to RampObj.
Definition vector_expr.h:71
Ramp(ffi::ObjectPtr< RampObj > node)
Definition vector_expr.h:74
TVM_TIRX_DLL Ramp(PrimExpr base, PrimExpr stride, PrimExpr lanes, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(RampObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Ramp, PrimExpr, RampObj)
static constexpr bool _type_container_is_exact
Definition vector_expr.h:77
Shuffle instruction. vec = concat(vectors) result = (vec[indices[0]], vec[indices[1]] ....
Definition vector_expr.h:119
static void RegisterReflection()
Definition vector_expr.h:125
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Shuffle", ShuffleObj, ExprObj)
ffi::Array< PrimExpr > vectors
the input vectors.
Definition vector_expr.h:122
ffi::Array< PrimExpr > indices
The indices of each element.
Definition vector_expr.h:124
Managed reference to ShuffleObj.
Definition vector_expr.h:138
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Shuffle, PrimExpr, ShuffleObj)
Shuffle(ffi::ObjectPtr< ShuffleObj > node)
Definition vector_expr.h:145
TVM_TIRX_DLL Shuffle(ffi::Array< PrimExpr > vectors, ffi::Array< PrimExpr > indices, Location loc=UnknownLoc())
static TVM_TIRX_DLL PrimExpr Concat(ffi::Array< PrimExpr > vectors, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition vector_expr.h:148
static TVM_TIRX_DLL PrimExpr ExtractElement(PrimExpr vector, int index, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(ShuffleObj)
Copy-on-write helper macro for IR ffi::ObjectRef types.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41