tvm
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
119 TVM_DLL const Op& address_of();
120 
128 TVM_DLL const Op& if_then_else();
129 
137 TVM_DLL const Op& isnullptr();
138 
142 TVM_DLL const Op& isnan();
143 
147 TVM_DLL const Op& popcount();
148 
156 TVM_DLL const Op& fma();
157 
170 TVM_DLL const Op& call_extern();
171 
184 TVM_DLL const Op& call_pure_extern();
185 
196 TVM_DLL const Op& call_llvm_intrin();
197 
208 TVM_DLL const Op& call_llvm_pure_intrin();
209 
219 TVM_DLL const Op& call_spirv_pure_glsl450();
220 
221 // TODO(tvm-team) revisit the builtins below
222 // some of them can simply become ops with special codegen attr.
226 TVM_DLL const Op& prefetch();
227 
243 TVM_DLL const Op& tvm_access_ptr();
244 
249 TVM_DLL const Op& tvm_static_handle();
250 
255 TVM_DLL const Op& tvm_context_id();
256 
264 TVM_DLL const Op& tvm_tuple();
265 
274 TVM_DLL const Op& tvm_struct_get();
275 
284 TVM_DLL const Op& tvm_struct_set();
285 
292 TVM_DLL const Op& lookup_param();
293 
301 TVM_DLL const Op& tvm_throw_last_error();
302 
312 TVM_DLL const Op& tvm_stack_alloca();
313 
324 TVM_DLL const Op& tvm_stack_make_shape();
325 
345 TVM_DLL const Op& tvm_stack_make_array();
346 
360 TVM_DLL const Op& tvm_call_packed();
361 
372 TVM_DLL const Op& tvm_call_cpacked();
373 
385 TVM_DLL const Op& tvm_call_trace_packed();
386 
399 TVM_DLL const Op& tvm_check_return();
400 
412 TVM_DLL const Op& tvm_thread_context();
413 
432 TVM_DLL const Op& tvm_call_packed_lowered();
433 
447 TVM_DLL const Op& tvm_call_cpacked_lowered();
448 
469 
478 TVM_DLL const Op& tvm_storage_sync();
479 
511 TVM_DLL const Op& tvm_warp_shuffle();
512 TVM_DLL const Op& tvm_warp_shuffle_up();
513 TVM_DLL const Op& tvm_warp_shuffle_down();
514 TVM_DLL const Op& tvm_warp_activemask();
515 
520 TVM_DLL const Op& tvm_global_barrier_kinit();
521 
533 TVM_DLL const Op& tvm_thread_allreduce();
534 
535 // TODO(tvm-team) TensorCore specific intrinsics should be directly registered under
536 // cuda. namespace and used through op.
549 TVM_DLL const Op& tvm_load_matrix_sync();
550 
562 TVM_DLL const Op& tvm_mma_sync();
563 
575 TVM_DLL const Op& tvm_bmma_sync();
576 
587 TVM_DLL const Op& tvm_fill_fragment();
588 
600 TVM_DLL const Op& tvm_store_matrix_sync();
601 
611 TVM_DLL const Op& ptx_mma();
612 
617 TVM_DLL const Op& ptx_ldg32();
618 
623 TVM_DLL const Op& ptx_ldg32();
624 
636 TVM_DLL const Op& ptx_mma_sp();
637 
645 TVM_DLL const Op& ptx_ldmatrix();
646 
656 TVM_DLL const Op& ptx_cp_async();
657 
668 TVM_DLL const Op& ptx_cp_async_bulk();
669 
677 TVM_DLL const Op& ptx_commit_group();
678 TVM_DLL const Op& ptx_wait_group();
679 
686 TVM_DLL const Op& ptx_cp_async_barrier();
687 
695 
702 TVM_DLL const Op& ptx_arrive_barrier();
703 
711 
718 TVM_DLL const Op& ptx_wait_barrier();
719 
726 TVM_DLL const Op& create_barriers();
727 
740 TVM_DLL const Op& mma_store();
741 
753 TVM_DLL const Op& mma_fill();
754 
755 // TODO(tvm-team) replace the usage of the vector operations by Shuffle.
759 TVM_DLL const Op& vectorhigh();
760 
764 TVM_DLL const Op& vectorlow();
765 
769 TVM_DLL const Op& vectorcombine();
770 
774 TVM_DLL const Op& atomic_add();
778 TVM_DLL const Op& nd_mem_alloc_with_scope();
779 
783 TVM_DLL const Op& texture2d_store();
784 
788 TVM_DLL const Op& texture2d_load();
789 
801 TVM_DLL const Op& dma_copy();
802 
809 TVM_DLL const Op& dma_wait();
810 
820 TVM_DLL const Op& dma_start_group();
821 
833 TVM_DLL const Op& dma_end_group();
834 
842 TVM_DLL const Op& assume();
843 
850 TVM_DLL const Op& undef();
851 
855 TVM_DLL const Op& start_profile_intrinsic();
856 
860 TVM_DLL const Op& end_profile_intrinsic();
861 
863 enum TVMStructFieldKind : int {
864  // array head address
877  // TVMValue field
880 };
881 } // namespace builtin
882 } // namespace tir
883 } // namespace tvm
884 #endif // TVM_TIR_BUILTIN_H_
Managed reference class to OpNode.
Definition: op.h:165
Primitive operators(builtin intrinsics) and registry for them.
const Op & tvm_call_packed_lowered()
Lowered version of call packed, the space of value and type codes are explicitly allocated.
const Op & bitwise_not()
Bitwise not operator.
const Op & assume()
Provide a true statement that can be used for simplifications.
const Op & q_multiply_shift()
Execute a multiplication between two Q-numbers x and y followed by a right shift s The default roundi...
const Op & tvm_mma_sync()
tvm intrinsic for tensor core mma_sync operators.
const Op & bitwise_xor()
Bitwise xor operator.
const Op & bitwise_and()
Bitwise and operator.
const Op & dma_wait()
Wait until the number of DMA groups in flight is less than or equal to some maximum.
const Op & tvm_stack_alloca()
See pesudo code.
const Op & fma()
Fused multiply add.
const Op & tvm_call_cpacked()
See pesudo code.
const Op & ptx_commit_group()
tvm intrinsics for ptx async copy commit and wait.
const Op & popcount()
Popcount.
const Op & tvm_context_id()
Return a unique context id, used for hint of workspace separation. Different context id ganrantees no...
const Op & likely()
Marks a condition is likely going to happen.
const Op & tvm_struct_get()
See pesudo code.
const Op & tvm_check_return()
Checks the return value of another call is correct or returns a given value.
const Op & shift_left()
Left shift.
const Op & tvm_stack_make_array()
Allocate a NDArray(DLTensor) on stack, return the handle.
const Op & ptx_cp_async_barrier()
tvm intrinsics for ptx async copy barrier using cp.async.mbarrier.arrive
const Op & tvm_call_packed()
See pesudo code.
const Op & create_barriers()
tvm intrinsics to create N barriers
const Op & mma_fill()
tvm intrinsic for zero-initalizing an MMA accumulation registor. For example, if each thread in a war...
const Op & vectorcombine()
Concat two vectors.
const Op & tvm_call_cpacked_lowered()
Lowered version of call c-packed, the space of value and type codes are explicitly allocated.
const Op & large_uint_imm()
See pesudo code.
const Op & ptx_mma_sp()
tvm intrinsic for sparse tensor core ptx instructions.
const Op & dma_end_group()
End a group of DMA copies.
const Op & tvm_access_ptr()
Get head access address with memory access pattern info.
const Op & vectorhigh()
Get the high level half of the vector.
const Op & prefetch()
Prefetch a cacheline.
const Op & ptx_cp_async_bulk()
tvm intrinsics for ptx async copy from global to shared memory using cp.async.bulk
const Op & bitwise_or()
Bitwise or operator.
const Op & tvm_fill_fragment()
tvm intrinsic for tensor core fill_fragment operators.
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 & tvm_static_handle()
Create a function local static handle that iniitalizes to nullptr. can be used to cache function loca...
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 & end_profile_intrinsic()
Profiling intrinsic.
const Op & tvm_struct_set()
See pesudo code.
const Op & texture2d_store()
Store to texture 2d memory.
const Op & isnan()
Check if value is nan.
const Op & address_of()
Returns the address of an element in the buffer (see pseudocode below).
const Op & mma_store()
tvm intrinsic for storing the result of PTX MMA into a destination pointer. For example,...
const Op & undef()
Returns an initialized but arbitrary value.
const Op & ptx_ldg32()
tvm intrinsic for ptx predicate load with 32-bit data type.
const Op & reinterpret()
Reinterpret the value using the target type.
const Op & ptx_cp_async()
tvm intrinsics for ptx async copy from global to shared memory using cp.async
const Op & vectorlow()
Get the low-level half of the vector.
const Op & call_llvm_intrin()
Call an LLVM intrinsic with a given intrinsic id and signature from the types of args in the runtime ...
const Op & ptx_wait_barrier()
tvm intrinsics for ptx barrier wait using mbarrier.try_wait
const Op & tvm_bmma_sync()
tvm intrinsic for tensor core bmma_sync operators.
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 & tvm_storage_sync()
See pseudo code.
const Op & tvm_throw_last_error()
See pesudo code.
const Op & tvm_load_matrix_sync()
tvm intrinsic for tensor core load operators.
const Op & nd_mem_alloc_with_scope()
Create an Nd memory allocation with storage scope.
const Op & tvm_thread_allreduce()
See pesudo code.
const Op & isnullptr()
See pesudo code.
const Op & start_profile_intrinsic()
Profiling intrinsic.
const Op & tvm_call_trace_packed_lowered()
Lowered version of trace intrinsic, the space of value and type codes are explicitly allocated....
const Op & ptx_arrive_barrier_expect_tx()
tvm intrinsic for ptx barrier arrival with expect tx using mbarrier.arrive.expect_tx
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 & atomic_add()
atomic add instruction, corresponding e.g. to atomicAdd in CUDA
const Op & tvm_stack_make_shape()
Allocate a shape tuple on stack, return the handle.
const Op & ptx_arrive_barrier()
tvm intrinsics for ptx barrier arrival using mbarrier.arrive
const Op & call_spirv_pure_glsl450()
Call an SPIRV pure GLSL450 intrinsic.
const Op & tvm_call_trace_packed()
See pesudo code.
const Op & tvm_global_barrier_kinit()
Initialize the global barrier. Call this at beginning of kernel that need global barrier.
const Op & tvm_warp_shuffle()
See pseudo code.
const Op & ptx_init_barrier_thread_count()
tvm intrinsics for ptx barrier initialization of thread count using mbarrier.init
const Op & dma_start_group()
Start a group of DMA copies.
TVMStructFieldKind
The kind of structure field info used in intrinsic.
Definition: builtin.h:863
@ kArrAddr
Definition: builtin.h:865
@ kArrTypeLanes
Definition: builtin.h:872
@ kArrTypeBits
Definition: builtin.h:871
@ kArrKindBound_
Definition: builtin.h:876
@ kArrShape
Definition: builtin.h:867
@ kArrTypeCode
Definition: builtin.h:870
@ kTVMValueContent
Definition: builtin.h:878
@ kArrData
Definition: builtin.h:866
@ kArrDeviceId
Definition: builtin.h:874
@ kArrStrides
Definition: builtin.h:868
@ kTVMValueKindBound_
Definition: builtin.h:879
@ kArrDeviceType
Definition: builtin.h:875
@ kArrNDim
Definition: builtin.h:869
@ kArrByteOffset
Definition: builtin.h:873
const Op & ptx_mma()
tvm intrinsic for ptx tensor core mma instructions.
const Op & tvm_warp_shuffle_up()
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 & if_then_else()
Same as select, used for unsafe memory access.
const Op & ret()
Return value.
const Op & ptx_ldmatrix()
tvm intrinsic for ptx load matrix from shared memory.
const Op & ptx_wait_group()
const Op & shift_right()
Right shift.
const Op & lookup_param()
See pseudo code Type lookup_param(String param_name) { return __tvm_param__param_name; }.
const Op & tvm_warp_shuffle_down()
const Op & tvm_warp_activemask()
const Op & tvm_store_matrix_sync()
tvm intrinsic for tensor core store operators.
const Op & dma_copy()
Initiate a non-blocking DMA copy from source to destination.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
TIR expressions.