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
42class RampNode : public ExprNode {
43 public:
45 : base(std::move(base)), stride(std::move(stride)), lanes(std::move(lanes)) {}
46 explicit RampNode(ffi::UnsafeInit tag) : base(tag), stride(tag), lanes(tag) {}
47
54 static void RegisterReflection() {
55 namespace refl = tvm::ffi::reflection;
56 refl::ObjectDef<RampNode>()
57 .def_ro("base", &RampNode::base)
58 .def_ro("stride", &RampNode::stride)
59 .def_ro("lanes", &RampNode::lanes);
60 }
62};
63
68class Ramp : public PrimExpr {
69 public:
71 explicit Ramp(ffi::ObjectPtr<RampNode> node) : PrimExpr(std::move(node)) {}
72
74 static constexpr bool _type_container_is_exact = true;
76};
77
79class BroadcastNode : public ExprNode {
80 public:
82 : value(std::move(value)), lanes(std::move(lanes)) {}
83 explicit BroadcastNode(ffi::UnsafeInit tag) : value(tag), lanes(tag) {}
84
89 static void RegisterReflection() {
90 namespace refl = tvm::ffi::reflection;
91 refl::ObjectDef<BroadcastNode>()
92 .def_ro("value", &BroadcastNode::value)
93 .def_ro("lanes", &BroadcastNode::lanes);
94 }
96};
97
102class Broadcast : public PrimExpr {
103 public:
105 explicit Broadcast(ffi::ObjectPtr<BroadcastNode> node) : PrimExpr(std::move(node)) {}
106
108 static constexpr bool _type_container_is_exact = true;
110};
111
117class ShuffleNode : public ExprNode {
118 public:
120 ffi::Array<PrimExpr> vectors;
122 ffi::Array<PrimExpr> indices;
123 static void RegisterReflection() {
124 namespace refl = tvm::ffi::reflection;
125 refl::ObjectDef<ShuffleNode>()
126 .def_ro("vectors", &ShuffleNode::vectors)
127 .def_ro("indices", &ShuffleNode::indices);
128 }
130};
131
136class Shuffle : public PrimExpr {
137 public:
138 TVM_TIRX_DLL Shuffle(ffi::Array<PrimExpr> vectors, ffi::Array<PrimExpr> indices,
139 Location loc = UnknownLoc());
140 TVM_TIRX_DLL static PrimExpr Concat(ffi::Array<PrimExpr> vectors, Location loc = UnknownLoc());
142 Location loc = UnknownLoc());
143 explicit Shuffle(ffi::ObjectPtr<ShuffleNode> node) : PrimExpr(std::move(node)) {}
144
146 static constexpr bool _type_container_is_exact = true;
148};
149
150} // namespace prim
151} // namespace tvm
152#endif // TVM_IR_PRIM_VECTOR_EXPR_H_
Base type of all the expressions.
Definition base_expr.h:324
Non-nullable source-location metadata.
Definition location.h:91
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Reference to the shared immutable unknown location.
Definition location.h:105
Create a vector where all the elements are value.
Definition vector_expr.h:79
static void RegisterReflection()
Definition vector_expr.h:89
BroadcastNode(ffi::UnsafeInit tag)
Definition vector_expr.h:83
BroadcastNode(PrimExpr value, PrimExpr lanes)
Definition vector_expr.h:81
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Broadcast", BroadcastNode, ExprNode)
PrimExpr value
The base value.
Definition vector_expr.h:86
PrimExpr lanes
The number of lanes.
Definition vector_expr.h:88
Managed reference to BroadcastNode.
Definition vector_expr.h:102
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Broadcast, PrimExpr, BroadcastNode)
Broadcast(ffi::ObjectPtr< BroadcastNode > node)
Definition vector_expr.h:105
TVM_TIRX_DLL Broadcast(PrimExpr value, PrimExpr lanes, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BroadcastNode)
static constexpr bool _type_container_is_exact
Definition vector_expr.h:108
Construct a vector with lanes elements where its i-th element equals base + i * stride....
Definition vector_expr.h:42
RampNode(PrimExpr base, PrimExpr stride, PrimExpr lanes)
Definition vector_expr.h:44
PrimExpr lanes
Total number of lanes.
Definition vector_expr.h:53
PrimExpr stride
The stride of each step.
Definition vector_expr.h:51
PrimExpr base
The base value.
Definition vector_expr.h:49
static void RegisterReflection()
Definition vector_expr.h:54
RampNode(ffi::UnsafeInit tag)
Definition vector_expr.h:46
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Ramp", RampNode, ExprNode)
Managed reference to RampNode.
Definition vector_expr.h:68
Ramp(ffi::ObjectPtr< RampNode > node)
Definition vector_expr.h:71
TVM_TIRX_DLL Ramp(PrimExpr base, PrimExpr stride, PrimExpr lanes, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Ramp, PrimExpr, RampNode)
static constexpr bool _type_container_is_exact
Definition vector_expr.h:74
TVM_DEFINE_OBJECT_REF_COW_METHOD(RampNode)
Shuffle instruction. vec = concat(vectors) result = (vec[indices[0]], vec[indices[1]] ....
Definition vector_expr.h:117
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Shuffle", ShuffleNode, ExprNode)
ffi::Array< PrimExpr > vectors
the input vectors.
Definition vector_expr.h:120
static void RegisterReflection()
Definition vector_expr.h:123
ffi::Array< PrimExpr > indices
The indices of each element.
Definition vector_expr.h:122
Managed reference to ShuffleNode.
Definition vector_expr.h:136
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())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Shuffle, PrimExpr, ShuffleNode)
static constexpr bool _type_container_is_exact
Definition vector_expr.h:146
static TVM_TIRX_DLL PrimExpr ExtractElement(PrimExpr vector, int index, Location loc=UnknownLoc())
Shuffle(ffi::ObjectPtr< ShuffleNode > node)
Definition vector_expr.h:143
TVM_DEFINE_OBJECT_REF_COW_METHOD(ShuffleNode)
Copy-on-write helper macro for IR ffi::ObjectRef types.
Base expr nodes in TVM.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
#define TVM_TIRX_DLL
Definition base.h:83