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:
50 static void RegisterReflection() {
51 namespace refl = tvm::ffi::reflection;
52 refl::ObjectDef<RampNode>()
53 .def_ro("base", &RampNode::base)
54 .def_ro("stride", &RampNode::stride)
55 .def_ro("lanes", &RampNode::lanes);
56 }
58};
59
71
73class BroadcastNode : public ExprNode {
74 public:
79 static void RegisterReflection() {
80 namespace refl = tvm::ffi::reflection;
81 refl::ObjectDef<BroadcastNode>()
82 .def_ro("value", &BroadcastNode::value)
83 .def_ro("lanes", &BroadcastNode::lanes);
84 }
86};
87
99
105class ShuffleNode : public ExprNode {
106 public:
108 ffi::Array<PrimExpr> vectors;
110 ffi::Array<PrimExpr> indices;
111 static void RegisterReflection() {
112 namespace refl = tvm::ffi::reflection;
113 refl::ObjectDef<ShuffleNode>()
114 .def_ro("vectors", &ShuffleNode::vectors)
115 .def_ro("indices", &ShuffleNode::indices);
116 }
118};
119
124class Shuffle : public PrimExpr {
125 public:
126 TVM_DLL Shuffle(ffi::Array<PrimExpr> vectors, ffi::Array<PrimExpr> indices, Span span = Span());
127 TVM_DLL static PrimExpr Concat(ffi::Array<PrimExpr> vectors, Span span = Span());
128 TVM_DLL static PrimExpr ExtractElement(PrimExpr vector, int index, Span span = Span());
130 static constexpr bool _type_container_is_exact = true;
132};
133
134} // namespace prim
135} // namespace tvm
136#endif // TVM_IR_PRIM_VECTOR_EXPR_H_
Base type of all the expressions.
Definition base_expr.h:300
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Definition source_map.h:111
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Create a vector where all the elements are value.
Definition vector_expr.h:73
static void RegisterReflection()
Definition vector_expr.h:79
PrimExpr value
The base value.
Definition vector_expr.h:76
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.prim.Broadcast", BroadcastNode, ExprNode)
PrimExpr lanes
The number of lanes.
Definition vector_expr.h:78
Managed reference to BroadcastNode.
Definition vector_expr.h:92
Broadcast(PrimExpr value, PrimExpr lanes, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BroadcastNode)
static constexpr bool _type_container_is_exact
Definition vector_expr.h:96
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Broadcast, PrimExpr, BroadcastNode)
Construct a vector with lanes elements where its i-th element equals base + i * stride....
Definition vector_expr.h:42
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.prim.Ramp", RampNode, ExprNode)
PrimExpr lanes
Total number of lanes.
Definition vector_expr.h:49
PrimExpr stride
The stride of each step.
Definition vector_expr.h:47
PrimExpr base
The base value.
Definition vector_expr.h:45
static void RegisterReflection()
Definition vector_expr.h:50
Managed reference to RampNode.
Definition vector_expr.h:64
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Ramp, PrimExpr, RampNode)
Ramp(PrimExpr base, PrimExpr stride, PrimExpr lanes, Span span=Span())
static constexpr bool _type_container_is_exact
Definition vector_expr.h:68
TVM_DEFINE_OBJECT_REF_COW_METHOD(RampNode)
Shuffle instruction. vec = concat(vectors) result = (vec[indices[0]], vec[indices[1]] ....
Definition vector_expr.h:105
ffi::Array< PrimExpr > vectors
the input vectors.
Definition vector_expr.h:108
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.prim.Shuffle", ShuffleNode, ExprNode)
static void RegisterReflection()
Definition vector_expr.h:111
ffi::Array< PrimExpr > indices
The indices of each element.
Definition vector_expr.h:110
Managed reference to ShuffleNode.
Definition vector_expr.h:124
static PrimExpr ExtractElement(PrimExpr vector, int index, Span span=Span())
static constexpr bool _type_container_is_exact
Definition vector_expr.h:130
Shuffle(ffi::Array< PrimExpr > vectors, ffi::Array< PrimExpr > indices, Span span=Span())
static PrimExpr Concat(ffi::Array< PrimExpr > vectors, Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Shuffle, PrimExpr, ShuffleNode)
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 analyzer.h:40