# AOT ID: ['14_inference'] from ctypes import c_void_p, c_long import torch import math import random import os import tempfile from math import inf, nan from torch._inductor.hooks import run_intermediate_hooks from torch._inductor.utils import maybe_profile from torch._inductor.codegen.memory_planning import _align as align from torch import device, empty_strided from torch._inductor.async_compile import AsyncCompile from torch._inductor.select_algorithm import extern_kernels from torch._inductor.codegen.multi_kernel import MultiKernelCall aten = torch.ops.aten inductor_ops = torch.ops.inductor _quantized = torch.ops._quantized assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda alloc_from_pool = torch.ops.inductor._alloc_from_pool reinterpret_tensor = torch.ops.inductor._reinterpret_tensor async_compile = AsyncCompile() # kernel path: /tmp/torchinductor_root/jd/cjdpzu3av6gm2wmibwuibcbne3ru3vklay6af3rnj5vetzak545s.py # Source Nodes: [q, q_1], Original ATen: [aten.div, aten.view] # q => div # q_1 => view_2 triton_poi_fused_div_view_0 = async_compile.triton('triton_', ''' import triton import triton.language as tl from triton.compiler.compiler import AttrsDescriptor from torch._inductor.runtime import triton_helpers, triton_heuristics from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties @triton_heuristics.pointwise( size_hints=[8388608], filename=__file__, triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]}, inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_div_view_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}, min_elem_per_thread=0 ) @triton.jit def triton_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr): xoffset = tl.program_id(0) * XBLOCK xindex = xoffset + tl.arange(0, XBLOCK)[:] xmask = xindex < xnumel x0 = xindex tmp0 = tl.load(in_ptr0 + (x0), xmask).to(tl.float32) tmp1 = 0.0625 tmp2 = tmp0 * tmp1 tl.store(out_ptr0 + (x0), tmp2, xmask) ''', device_str='cuda') import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, start_graph, end_graph from torch._C import _cuda_getCurrentRawStream as get_raw_stream # kernel path: /tmp/torchinductor_root/5z/c5z4ovq3lzu2bjvvs35eu6dbqxhcab3wcyijtl5qf3s6z3pf2ubg.py # Source Nodes: [qk_mask], Original ATen: [aten.rsub] # qk_mask => sub_6 triton_poi_fused_rsub_1 = async_compile.triton('triton_', ''' import triton import triton.language as tl from triton.compiler.compiler import AttrsDescriptor from torch._inductor.runtime import triton_helpers, triton_heuristics from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties @triton_heuristics.pointwise( size_hints=[4194304], filename=__file__, triton_meta={'signature': {0: '*fp32', 1: 'i32', 2: 'i32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0,), equal_to_1=())]}, inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_rsub_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 0, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}, min_elem_per_thread=0 ) @triton.jit def triton_(out_ptr0, ks0, ks1, ks2, xnumel, XBLOCK : tl.constexpr): xoffset = tl.program_id(0) * XBLOCK xindex = xoffset + tl.arange(0, XBLOCK)[:] xmask = xindex < xnumel x0 = xindex % ks0 x1 = (xindex // ks0) x2 = xindex tl.device_assert(((x0 // ks1) + (x1 // 15) < 14 + ks2) | ~(xmask), "index out of bounds: (x0 // ks1) + (x1 // 15) < 14 + ks2") tl.device_assert(((x0 % ks1) + (x1 % 15) < 14 + ks1) | ~(xmask), "index out of bounds: (x0 % ks1) + (x1 % 15) < 14 + ks1") tmp2 = (-7) + (x0 // ks1) + (x1 // 15) tmp3 = tl.full([1], 0, tl.int64) tmp4 = tmp2 >= tmp3 tmp5 = ks2 tmp6 = tmp2 < tmp5 tmp7 = (-7) + (x0 % ks1) + (x1 % 15) tmp8 = tmp7 >= tmp3 tmp9 = ks1 tmp10 = tmp7 < tmp9 tmp11 = tmp4 & tmp6 tmp12 = tmp11 & tmp8 tmp13 = tmp12 & tmp10 tmp14 = 1.0 tmp15 = tl.full(tmp14.shape, 0.0, tmp14.dtype) tmp16 = tl.where(tmp13, tmp14, tmp15) tmp17 = tmp14 - tmp16 tl.store(out_ptr0 + (x2), tmp17, xmask) ''', device_str='cuda') # kernel path: /tmp/torchinductor_root/jf/cjfq526klpxeiwil3fk3g3s3pl2h4zjmt47ivqhra4l7j3bfbgaw.py # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] # relative_emb => convert_element_type, convert_element_type_1, convolution triton_poi_fused__to_copy_convolution_2 = async_compile.triton('triton_', ''' import triton import triton.language as tl from triton.compiler.compiler import AttrsDescriptor from torch._inductor.runtime import triton_helpers, triton_heuristics from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties @triton_heuristics.pointwise( size_hints=[65536], filename=__file__, triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]}, inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_convolution_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}, min_elem_per_thread=0 ) @triton.jit def triton_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr): xnumel = 57600 xoffset = tl.program_id(0) * XBLOCK xindex = xoffset + tl.arange(0, XBLOCK)[:] xmask = xindex < xnumel x0 = xindex tmp0 = tl.load(in_ptr0 + (x0), xmask) tmp1 = tmp0.to(tl.float32) tl.store(out_ptr0 + (x0), tmp1, xmask) ''', device_str='cuda') # kernel path: /tmp/torchinductor_root/lw/clwcyft7h5r6iq7cev722pbhjaxs4cixdl2kqco4dl2rlvp4pz3t.py # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] # relative_emb => convert_element_type, convert_element_type_1, convolution triton_poi_fused__to_copy_convolution_3 = async_compile.triton('triton_', ''' import triton import triton.language as tl from triton.compiler.compiler import AttrsDescriptor from torch._inductor.runtime import triton_helpers, triton_heuristics from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties @triton_heuristics.pointwise( size_hints=[256], filename=__file__, triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]}, inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_convolution_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}, min_elem_per_thread=0 ) @triton.jit def triton_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr): xnumel = 225 xoffset = tl.program_id(0) * XBLOCK xindex = xoffset + tl.arange(0, XBLOCK)[:] xmask = xindex < xnumel x0 = xindex tmp0 = tl.load(in_ptr0 + (x0), xmask) tmp1 = tmp0.to(tl.float32) tl.store(out_ptr0 + (x0), tmp1, xmask) ''', device_str='cuda') # kernel path: /tmp/torchinductor_root/gm/cgmex3zhfvem2tizepj5mw66xbu5pgm5vxs3rczrvaqysbzyjz6n.py # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] # relative_emb => convert_element_type, convert_element_type_1, convolution triton_poi_fused__to_copy_convolution_4 = async_compile.triton('triton_', ''' import triton import triton.language as tl from triton.compiler.compiler import AttrsDescriptor from torch._inductor.runtime import triton_helpers, triton_heuristics from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties @triton_heuristics.pointwise( size_hints=[4194304], filename=__file__, triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]}, inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_convolution_4', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}, min_elem_per_thread=0 ) @triton.jit def triton_(in_out_ptr0, in_ptr0, ks0, xnumel, XBLOCK : tl.constexpr): xoffset = tl.program_id(0) * XBLOCK xindex = xoffset + tl.arange(0, XBLOCK)[:] xmask = xindex < xnumel x2 = xindex x1 = (xindex // ks0) tmp0 = tl.load(in_out_ptr0 + (x2), xmask, eviction_policy='evict_last').to(tl.float32) tmp1 = tl.load(in_ptr0 + (x1), xmask, eviction_policy='evict_last').to(tl.float32) tmp2 = tmp0 + tmp1 tl.store(in_out_ptr0 + (x2), tmp2, xmask) ''', device_str='cuda') async_compile.wait(globals()) del async_compile def call(args): arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1 = args args.clear() s0 = arg0_1 s1 = arg1_1 assert_size_stride(arg2_1, (1, 256, s0, s1), (256*s0*s1, s0*s1, s1, 1)) assert_size_stride(arg3_1, (225, 256, 1, 1), (256, 1, 1, 1)) assert_size_stride(arg4_1, (225, ), (1, )) assert_size_stride(arg5_1, (1, 256, s0, s1), (256*s0*s1, s0*s1, s1, 1)) assert_size_stride(arg6_1, (1, 256, s0, s1), (256*s0*s1, s0*s1, s1, 1)) with torch.cuda._DeviceGuard(0): torch.cuda.set_device(0) buf0 = empty_strided_cuda((1, 256, s0, s1), (256*s0*s1, s0*s1, s1, 1), torch.float16) # Source Nodes: [q, q_1], Original ATen: [aten.div, aten.view] triton_poi_fused_div_view_0_xnumel = 256*s0*s1 stream0 = get_raw_stream(0) triton_poi_fused_div_view_0.run(arg5_1, buf0, triton_poi_fused_div_view_0_xnumel, grid=grid(triton_poi_fused_div_view_0_xnumel), stream=stream0) ps0 = s0*s1 buf1 = empty_strided_cuda((1, 1, 225, s0*s1), (225*s0*s1, 225*s0*s1, s0*s1, 1), torch.float32) # Source Nodes: [qk_mask], Original ATen: [aten.rsub] triton_poi_fused_rsub_1_xnumel = 225*s0*s1 triton_poi_fused_rsub_1.run(buf1, ps0, s1, s0, triton_poi_fused_rsub_1_xnumel, grid=grid(triton_poi_fused_rsub_1_xnumel), stream=stream0) buf2 = empty_strided_cuda((225, 256, 1, 1), (256, 1, 1, 1), torch.float16) # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] triton_poi_fused__to_copy_convolution_2.run(arg3_1, buf2, 57600, grid=grid(57600), stream=stream0) del arg3_1 buf3 = empty_strided_cuda((225, ), (1, ), torch.float16) # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] triton_poi_fused__to_copy_convolution_3.run(arg4_1, buf3, 225, grid=grid(225), stream=stream0) del arg4_1 # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] buf4 = extern_kernels.convolution(arg5_1, buf2, stride=(1, 1), padding=(0, 0), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None) assert_size_stride(buf4, (1, 225, s0, s1), (225*s0*s1, s0*s1, s1, 1)) del arg5_1 del buf2 buf5 = buf4; del buf4 # reuse # Source Nodes: [relative_emb], Original ATen: [aten._to_copy, aten.convolution] triton_poi_fused__to_copy_convolution_4_xnumel = 225*s0*s1 triton_poi_fused__to_copy_convolution_4.run(buf5, buf3, ps0, triton_poi_fused__to_copy_convolution_4_xnumel, grid=grid(triton_poi_fused__to_copy_convolution_4_xnumel), stream=stream0) del buf3 return (buf0, arg6_1, reinterpret_tensor(arg2_1, (1, 1, 256, s0*s1), (256*s0*s1, 256*s0*s1, s0*s1, 1), 0), s0, s1, buf1, reinterpret_tensor(buf5, (1, 1, 225, s0*s1), (225*s0*s1, 225*s0*s1, s0*s1, 1), 0), ) def benchmark_compiled_module(times=10, repeat=10): from torch._dynamo.testing import rand_strided from torch._inductor.utils import print_performance arg0_1 = 136 arg1_1 = 136 arg2_1 = rand_strided((1, 256, 136, 136), (4734976, 18496, 136, 1), device='cuda:0', dtype=torch.float16) arg3_1 = rand_strided((225, 256, 1, 1), (256, 1, 1, 1), device='cuda:0', dtype=torch.float32) arg4_1 = rand_strided((225, ), (1, ), device='cuda:0', dtype=torch.float32) arg5_1 = rand_strided((1, 256, 136, 136), (4734976, 18496, 136, 1), device='cuda:0', dtype=torch.float16) arg6_1 = rand_strided((1, 256, 136, 136), (4734976, 18496, 136, 1), device='cuda:0', dtype=torch.float16) fn = lambda: call([arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1]) return print_performance(fn, times=times, repeat=repeat) if __name__ == "__main__": from torch._inductor.wrapper_benchmark import compiled_module_main compiled_module_main('None', benchmark_compiled_module)