tvm
builtin.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 
33 #ifndef TVM_TIR_BUILTIN_H_
34 #define TVM_TIR_BUILTIN_H_
35 
36 #include <tvm/ir/op.h>
37 #include <tvm/tir/expr.h>
38 
39 namespace tvm {
40 namespace tir {
41 
43 namespace builtin {
47 TVM_DLL const Op& ret();
51 TVM_DLL const Op& reinterpret();
52 
56 TVM_DLL const Op& likely();
57 
61 TVM_DLL const Op& bitwise_and();
62 
66 TVM_DLL const Op& bitwise_or();
67 
71 TVM_DLL const Op& bitwise_xor();
72 
76 TVM_DLL const Op& bitwise_not();
77 
81 TVM_DLL const Op& shift_left();
82 
86 TVM_DLL const Op& shift_right();
87 
97 TVM_DLL const Op& large_uint_imm();
98 
105 TVM_DLL const Op& q_multiply_shift();
106 
114 TVM_DLL const Op& address_of();
115 
123 TVM_DLL const Op& if_then_else();
124 
132 TVM_DLL const Op& isnullptr();
133 
137 TVM_DLL const Op& isnan();
138 
142 TVM_DLL const Op& popcount();
143 
151 TVM_DLL const Op& fma();
152 
165 TVM_DLL const Op& call_extern();
166 
179 TVM_DLL const Op& call_pure_extern();
180 
191 TVM_DLL const Op& call_llvm_intrin();
192 
203 TVM_DLL const Op& call_llvm_pure_intrin();
204 
214 TVM_DLL const Op& call_spirv_pure_glsl450();
215 
216 // TODO(tvm-team) revisit the builtins below
217 // some of them can simply become ops with special codegen attr.
221 TVM_DLL const Op& prefetch();
222 
238 TVM_DLL const Op& tvm_access_ptr();
239 
244 TVM_DLL const Op& tvm_static_handle();
245 
250 TVM_DLL const Op& tvm_context_id();
251 
259 TVM_DLL const Op& tvm_tuple();
260 
269 TVM_DLL const Op& tvm_struct_get();
270 
279 TVM_DLL const Op& tvm_struct_set();
280 
287 TVM_DLL const Op& lookup_param();
288 
296 TVM_DLL const Op& tvm_throw_last_error();
297 
307 TVM_DLL const Op& tvm_stack_alloca();
308 
319 TVM_DLL const Op& tvm_stack_make_shape();
320 
340 TVM_DLL const Op& tvm_stack_make_array();
341 
355 TVM_DLL const Op& tvm_call_packed();
356 
367 TVM_DLL const Op& tvm_call_cpacked();
368 
380 TVM_DLL const Op& tvm_call_trace_packed();
381 
393 TVM_DLL const Op& tvm_thread_context();
394 
413 TVM_DLL const Op& tvm_call_packed_lowered();
414 
428 TVM_DLL const Op& tvm_call_cpacked_lowered();
429 
449 TVM_DLL const Op& tvm_call_trace_packed_lowered();
450 
459 TVM_DLL const Op& tvm_storage_sync();
460 
492 TVM_DLL const Op& tvm_warp_shuffle();
493 TVM_DLL const Op& tvm_warp_shuffle_up();
494 TVM_DLL const Op& tvm_warp_shuffle_down();
495 TVM_DLL const Op& tvm_warp_activemask();
496 
501 TVM_DLL const Op& tvm_global_barrier_kinit();
502 
514 TVM_DLL const Op& tvm_thread_allreduce();
515 
516 // TODO(tvm-team) TensorCore specific intrinsics should be directly registered under
517 // cuda. namespace and used through op.
530 TVM_DLL const Op& tvm_load_matrix_sync();
531 
543 TVM_DLL const Op& tvm_mma_sync();
544 
556 TVM_DLL const Op& tvm_bmma_sync();
557 
568 TVM_DLL const Op& tvm_fill_fragment();
569 
581 TVM_DLL const Op& tvm_store_matrix_sync();
582 
583 // TODO(tvm-team) replace the usage of the vector operations by Shuffle.
587 TVM_DLL const Op& vectorhigh();
588 
592 TVM_DLL const Op& vectorlow();
593 
597 TVM_DLL const Op& vectorcombine();
598 
602 TVM_DLL const Op& atomic_add();
606 TVM_DLL const Op& texture2d_alloca();
607 
611 TVM_DLL const Op& texture2d_store();
612 
616 TVM_DLL const Op& texture2d_load();
617 
619 enum TVMStructFieldKind : int {
620  // array head address
633  // TVMValue field
636 };
637 } // namespace builtin
638 } // namespace tir
639 } // namespace tvm
640 #endif // TVM_TIR_BUILTIN_H_
Definition: builtin.h:630
Definition: builtin.h:625
Definition: builtin.h:621
const Op & tvm_storage_sync()
See pseudo code.
const Op & tvm_stack_alloca()
See pesudo code.
const Op & tvm_thread_allreduce()
See pesudo code.
const Op & tvm_call_cpacked()
See pesudo code.
const Op & tvm_warp_shuffle()
See pseudo code.
const Op & texture2d_store()
Store to texture 2d memory.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
const Op & call_llvm_intrin()
Call an LLVM intrinsic with a given intrinsic id and signature from the types of args in the runtime ...
Definition: builtin.h:631
const Op & fma()
Fused multiply add.
const Op & call_llvm_pure_intrin()
Call an LLVM pure intrinsic with a given intrinsic id and signature from the types of args in the run...
const Op & atomic_add()
atomic add instruction, corresponding e.g. to atomicAdd in CUDA
const Op & tvm_global_barrier_kinit()
Initialize the global barrier. Call this at beginning of kernel that need global barrier.
const Op & tvm_call_cpacked_lowered()
Lowered version of call c-packed, the space of value and type codes are explicitly allocated...
const Op & vectorcombine()
Concat two vectors.
const Op & tvm_warp_shuffle_up()
const Op & tvm_call_trace_packed()
See pesudo code.
const Op & tvm_store_matrix_sync()
tvm intrinsic for tensor core store operators.
Definition: builtin.h:624
const Op & call_spirv_pure_glsl450()
Call an SPIRV pure GLSL450 intrinsic.
const Op & tvm_thread_context()
See pesudo code Mark the content as thread local context, can get optimized by only call the call onc...
const Op & address_of()
See pesudo code.
const Op & bitwise_not()
Bitwise not operator.
Definition: builtin.h:629
const Op & q_multiply_shift()
Execute a multiplication between two Q-numbers x and y followed by a right shift s The default roundi...
Primitive operators(builtin intrinsics) and registry for them.
const Op & vectorlow()
Get the low-level half of the vector.
const Op & tvm_mma_sync()
tvm intrinsic for tensor core mma_sync operators.
Definition: builtin.h:627
const Op & reinterpret()
Reinterpret the value using the target type.
const Op & call_pure_extern()
Call an pure extern C function with given name and signature from the types of args in the runtime en...
const Op & texture2d_load()
Load from texture 2d memory.
const Op & popcount()
Popcount.
Definition: builtin.h:628
const Op & tvm_call_packed()
See pesudo code.
TIR expressions.
Definition: builtin.h:632
const Op & likely()
Marks a condition is likely going to happen.
const Op & tvm_struct_get()
See pesudo code.
Definition: builtin.h:634
const Op & tvm_stack_make_array()
Allocate a NDArray(DLTensor) on stack, return the handle.
const Op & prefetch()
Prefetch a cacheline.
const Op & tvm_throw_last_error()
See pesudo code.
const Op & tvm_load_matrix_sync()
tvm intrinsic for tensor core load operators.
const Op & tvm_access_ptr()
Get head access address with memory access pattern info.
const Op & texture2d_alloca()
Create a texture 2d memory allocation.
const Op & tvm_stack_make_shape()
Allocate a shape tuple on stack, return the handle.
const Op & if_then_else()
Same as select, used for unsafe memory access.
Managed reference class to OpNode.
Definition: op.h:165
Definition: builtin.h:623
const Op & tvm_warp_activemask()
const Op & call_extern()
Call an extern C function with given name and signature from the types of args in the runtime environ...
const Op & shift_right()
Right shift.
const Op & tvm_struct_set()
See pesudo code.
const Op & tvm_tuple()
tvm_tuple is not an actual function and cannot codegen. It is used to represent tuple structure in va...
const Op & tvm_bmma_sync()
tvm intrinsic for tensor core bmma_sync operators.
const Op & lookup_param()
See pseudo code Type lookup_param(String param_name) { return __tvm_param__param_name; }...
const Op & bitwise_xor()
Bitwise xor operator.
const Op & tvm_static_handle()
Create a function local static handle that iniitalizes to nullptr. can be used to cache function loca...
TVMStructFieldKind
The kind of structure field info used in intrinsic.
Definition: builtin.h:619
const Op & bitwise_and()
Bitwise and operator.
const Op & isnan()
Check if value is nan.
const Op & tvm_warp_shuffle_down()
const Op & bitwise_or()
Bitwise or operator.
const Op & tvm_fill_fragment()
tvm intrinsic for tensor core fill_fragment operators.
const Op & ret()
Return value.
const Op & vectorhigh()
Get the high level half of the vector.
const Op & tvm_call_packed_lowered()
Lowered version of call packed, the space of value and type codes are explicitly allocated.
const Op & large_uint_imm()
See pesudo code.
const Op & tvm_context_id()
Return a unique context id, used for hint of workspace separation. Different context id ganrantees no...
Definition: builtin.h:622
const Op & shift_left()
Left shift.
Definition: builtin.h:626
const Op & tvm_call_trace_packed_lowered()
Lowered version of trace intrinsic, the space of value and type codes are explicitly allocated...
const Op & isnullptr()
See pesudo code.