# AOT ID: ['6_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/bt/cbtdyiskfo744rhyoni6ayxznda6mafxzeqo6gl3ozs33bgcqx7w.py
# Source Nodes: [_tgt, add, linear, tgt], Original ATen: [aten._to_copy, aten.add, aten.native_layer_norm]
# _tgt => add_2, add_3, mul, mul_1, rsqrt, sub, var_mean
# add => add
# linear => convert_element_type_2
# tgt => add_1
triton_per_fused__to_copy_add_native_layer_norm_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.persistent_reduction(
size_hints=[8192, 256],
reduction_hint=ReductionHint.INNER,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: '*fp16', 3: '*fp32', 4: '*fp32', 5: '*fp16', 6: 'i32', 7: '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, 3, 4, 5, 6, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__to_copy_add_native_layer_norm_0', 'mutated_arg_names': [], 'no_x_dim': True, 'num_load': 5, 'num_reduction': 4, '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}
)
@triton.jit
def triton_(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr2, xnumel, rnumel):
xnumel = 4624
XBLOCK: tl.constexpr = 1
rnumel = 256
RBLOCK: tl.constexpr = 256
xoffset = tl.program_id(0) * XBLOCK
xindex = tl.full([1], xoffset, tl.int32)
xmask = xindex < xnumel
rindex = tl.arange(0, RBLOCK)[:]
roffset = 0
rmask = rindex < rnumel
r1 = rindex
x0 = xindex
tmp0 = tl.load(in_ptr0 + (r1 + (256*x0)), rmask & xmask, other=0.0)
tmp1 = tl.load(in_ptr1 + (r1 + (256*x0)), rmask & xmask, other=0.0).to(tl.float32)
tmp2 = tl.load(in_ptr2 + (r1 + (256*x0)), rmask & xmask, other=0.0).to(tl.float32)
tmp29 = tl.load(in_ptr3 + (r1), rmask, eviction_policy='evict_last', other=0.0)
tmp31 = tl.load(in_ptr4 + (r1), rmask, eviction_policy='evict_last', other=0.0)
tmp3 = tmp1 + tmp2
tmp4 = tmp3.to(tl.float32)
tmp5 = tmp0 + tmp4
tmp6 = tl.broadcast_to(tmp5, [RBLOCK])
tmp8 = tl.where(rmask & xmask, tmp6, 0)
tmp9 = tl.broadcast_to(tmp6, [RBLOCK])
tmp11 = tl.where(rmask & xmask, tmp9, 0)
tmp12 = triton_helpers.promote_to_tensor(tl.sum(tmp11, 0))
tmp13 = tl.full([1], 256, tl.int32)
tmp14 = tmp13.to(tl.float32)
tmp15 = tmp12 / tmp14
tmp16 = tmp6 - tmp15
tmp17 = tmp16 * tmp16
tmp18 = tl.broadcast_to(tmp17, [RBLOCK])
tmp20 = tl.where(rmask & xmask, tmp18, 0)
tmp21 = triton_helpers.promote_to_tensor(tl.sum(tmp20, 0))
tmp22 = tmp5 - tmp15
tmp23 = 256.0
tmp24 = tmp21 / tmp23
tmp25 = 1e-05
tmp26 = tmp24 + tmp25
tmp27 = libdevice.rsqrt(tmp26)
tmp28 = tmp22 * tmp27
tmp30 = tmp28 * tmp29
tmp32 = tmp30 + tmp31
tmp33 = tmp32.to(tl.float32)
tl.store(out_ptr2 + (r1 + (256*x0)), tmp33, rmask & 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/as/caslnaz5ovc2w4ytfnlr2jibrkfgmcp4e7e42dxcuygano3oelsl.py
# Source Nodes: [linear], Original ATen: [aten._to_copy]
# linear => convert_element_type_1
triton_poi_fused__to_copy_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=[262144],
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_1', '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 = 262144
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex
tmp0 = tl.load(in_ptr0 + (x0), None)
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x0), tmp1, None)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/vb/cvbmvuwb6uxqkrrldzge7qnzlzdqk2l4gdp337mybwl44sp4h43k.py
# Source Nodes: [x_1], Original ATen: [aten.native_group_norm]
# x_1 => var_mean_1
triton_per_fused_native_group_norm_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.persistent_reduction(
size_hints=[32768, 256],
reduction_hint=ReductionHint.INNER,
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32', 6: '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, 3, 4, 5), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_native_group_norm_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 3, '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}
)
@triton.jit
def triton_(in_ptr0, in_ptr1, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr):
xnumel = 29088
rnumel = 163
RBLOCK: tl.constexpr = 256
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rindex = tl.arange(0, RBLOCK)[None, :]
roffset = 0
rmask = rindex < rnumel
r3 = rindex
x0 = xindex % 101
x1 = (xindex // 101) % 9
x2 = (xindex // 909)
x5 = xindex
tmp0 = r3 + (163*x0)
tmp1 = tl.full([1, 1], 16441, tl.int32)
tmp2 = tmp0 < tmp1
tmp3 = r3 + (163*x0) + (16441*x1)
tmp4 = tl.full([1, 1], 147968, tl.int32)
tmp5 = tmp3 < tmp4
tmp6 = tmp5 & tmp2
tmp7 = tl.load(in_ptr0 + ((32*x2) + (1024*((r3 + (163*x0) + (16441*x1)) % 4624)) + (((r3 + (163*x0) + (16441*x1)) // 4624) % 32)), rmask & tmp6 & xmask, eviction_policy='evict_last', other=0.0).to(tl.float32)
tmp8 = tl.load(in_ptr1 + ((32*x2) + (((r3 + (163*x0) + (16441*x1)) // 4624) % 32)), rmask & tmp6 & xmask, eviction_policy='evict_last', other=0.0)
tmp9 = tmp8.to(tl.float32)
tmp10 = tmp7 + tmp9
tmp11 = tmp10.to(tl.float32)
tmp12 = tl.full(tmp11.shape, 0, tmp11.dtype)
tmp13 = tl.where(tmp6, tmp11, tmp12)
tmp14 = tl.full(tmp13.shape, 0, tmp13.dtype)
tmp15 = tl.where(tmp2, tmp13, tmp14)
tmp16 = 0.0
tmp17 = tl.full(tmp16.shape, 0, tmp16.dtype)
tmp18 = tl.where(tmp6, tmp16, tmp17)
tmp19 = tl.full(tmp18.shape, 0, tmp18.dtype)
tmp20 = tl.where(tmp2, tmp18, tmp19)
tmp21 = 1.0
tmp22 = tl.full(tmp21.shape, 0, tmp21.dtype)
tmp23 = tl.where(tmp6, tmp21, tmp22)
tmp24 = tl.full(tmp23.shape, 0, tmp23.dtype)
tmp25 = tl.where(tmp2, tmp23, tmp24)
tmp26 = tl.broadcast_to(tmp15, [XBLOCK, RBLOCK])
tmp27 = tl.broadcast_to(tmp20, [XBLOCK, RBLOCK])
tmp28 = tl.broadcast_to(tmp25, [XBLOCK, RBLOCK])
tmp30 = tl.where(rmask & xmask, tmp26, 0)
tmp31 = tl.where(rmask & xmask, tmp27, 0)
tmp32 = tl.where(rmask & xmask, tmp28, 0)
tmp33, tmp34, tmp35 = triton_helpers.welford(tmp30, tmp31, tmp32, 1)
tmp36 = tmp33[:, None]
tmp37 = tmp34[:, None]
tmp38 = tmp35[:, None]
tl.store(out_ptr0 + (x5), tmp36, xmask)
tl.store(out_ptr1 + (x5), tmp37, xmask)
tl.store(out_ptr2 + (x5), tmp38, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ry/cryr4surecktcuhmwmjogkgofvheizc7oycy6s35eitytxi4j6ua.py
# Source Nodes: [x_1], Original ATen: [aten.native_group_norm]
# x_1 => var_mean_1
triton_per_fused_native_group_norm_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.persistent_reduction(
size_hints=[512, 128],
reduction_hint=ReductionHint.INNER,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32', 7: '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, 3, 4, 5, 6), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_native_group_norm_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 3, '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}
)
@triton.jit
def triton_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr):
xnumel = 288
rnumel = 101
RBLOCK: tl.constexpr = 128
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rindex = tl.arange(0, RBLOCK)[None, :]
roffset = 0
rmask = rindex < rnumel
r1 = rindex
x0 = xindex
tmp0 = tl.load(in_ptr0 + (r1 + (101*x0)), rmask & xmask, other=0.0)
tmp1 = tl.load(in_ptr1 + (r1 + (101*x0)), rmask & xmask, other=0.0)
tmp2 = tl.load(in_ptr2 + (r1 + (101*x0)), rmask & xmask, other=0.0)
tmp3 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
tmp5 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
tmp7 = tl.where(rmask & xmask, tmp3, 0)
tmp8 = tl.where(rmask & xmask, tmp4, 0)
tmp9 = tl.where(rmask & xmask, tmp5, 0)
tmp10, tmp11, tmp12 = triton_helpers.welford(tmp7, tmp8, tmp9, 1)
tmp13 = tmp10[:, None]
tmp14 = tmp11[:, None]
tmp15 = tmp12[:, None]
tl.store(out_ptr0 + (x0), tmp13, xmask)
tl.store(out_ptr1 + (x0), tmp14, xmask)
tl.store(out_ptr2 + (x0), tmp15, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ti/ctiiksb3r3xvomwwtvvhkcylacpicxwzqr465usrd6g2ujlxocbb.py
# Source Nodes: [x_1], Original ATen: [aten.native_group_norm]
# x_1 => var_mean_1
triton_per_fused_native_group_norm_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.persistent_reduction(
size_hints=[32, 16],
reduction_hint=ReductionHint.INNER,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32', 6: '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, 3, 4, 5), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_native_group_norm_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 2, '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}
)
@triton.jit
def triton_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
xnumel = 32
rnumel = 9
RBLOCK: tl.constexpr = 16
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rindex = tl.arange(0, RBLOCK)[None, :]
roffset = 0
rmask = rindex < rnumel
r1 = rindex
x0 = xindex
tmp0 = tl.load(in_ptr0 + (r1 + (9*x0)), rmask & xmask, other=0.0)
tmp1 = tl.load(in_ptr1 + (r1 + (9*x0)), rmask & xmask, other=0.0)
tmp2 = tl.load(in_ptr2 + (r1 + (9*x0)), rmask & xmask, other=0.0)
tmp3 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
tmp5 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
tmp7 = tl.where(rmask & xmask, tmp3, 0)
tmp8 = tl.where(rmask & xmask, tmp4, 0)
tmp9 = tl.where(rmask & xmask, tmp5, 0)
tmp10, tmp11, tmp12 = triton_helpers.welford(tmp7, tmp8, tmp9, 1)
tmp13 = tmp10[:, None]
tmp14 = tmp11[:, None]
tmp15 = tmp12[:, None]
tl.store(out_ptr0 + (x0), tmp13, xmask)
tl.store(out_ptr1 + (x0), tmp14, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/wi/cwint6fgs7zu33a3pnijw6lclxbp7vkpkqy6yhslrgwbtyayqvnc.py
# Source Nodes: [x_1, x_2, x_3], Original ATen: [aten._to_copy, aten.gelu, aten.native_group_norm]
# x_1 => add_5, mul_3
# x_2 => add_6, erf, mul_4, mul_5, mul_6
# x_3 => convert_element_type_8
triton_poi_fused__to_copy_gelu_native_group_norm_5 = 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: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp16', 7: '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, 3, 4, 5, 6, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_gelu_native_group_norm_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 6, '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, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, out_ptr1, xnumel, XBLOCK : tl.constexpr):
xnumel = 4734976
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x2 = xindex
x0 = xindex % 1024
tmp0 = tl.load(in_ptr0 + (x2), None).to(tl.float32)
tmp1 = tl.load(in_ptr1 + (x0), None, eviction_policy='evict_last')
tmp5 = tl.load(in_ptr2 + ((x0 // 32)), None, eviction_policy='evict_last')
tmp7 = tl.load(in_ptr3 + ((x0 // 32)), None, eviction_policy='evict_last')
tmp14 = tl.load(in_ptr4 + (x0), None, eviction_policy='evict_last')
tmp16 = tl.load(in_ptr5 + (x0), None, eviction_policy='evict_last')
tmp2 = tmp1.to(tl.float32)
tmp3 = tmp0 + tmp2
tmp4 = tmp3.to(tl.float32)
tmp6 = tmp4 - tmp5
tmp8 = 147968.0
tmp9 = tmp7 / tmp8
tmp10 = 1e-05
tmp11 = tmp9 + tmp10
tmp12 = libdevice.rsqrt(tmp11)
tmp13 = tmp6 * tmp12
tmp15 = tmp13 * tmp14
tmp17 = tmp15 + tmp16
tmp18 = 0.5
tmp19 = tmp17 * tmp18
tmp20 = 0.7071067811865476
tmp21 = tmp17 * tmp20
tmp22 = libdevice.erf(tmp21)
tmp23 = 1.0
tmp24 = tmp22 + tmp23
tmp25 = tmp19 * tmp24
tmp26 = tmp25.to(tl.float32)
tl.store(out_ptr1 + (x2), tmp26, None)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/yp/cypln35vatxtjpb4pa4zsjqgqtmbm56jb4xbgkykms7hlfanclpj.py
# Source Nodes: [x_3], Original ATen: [aten._to_copy]
# x_3 => convert_element_type_7
triton_poi_fused__to_copy_6 = 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=[32768],
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_6', '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 = 25600
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/uw/cuw4pqmp72ftjc3o5cbzv4m4bdd477er3aa27hhgm4dqtryxfp7p.py
# Source Nodes: [add, tgt, tgt2, tgt_1], Original ATen: [aten._to_copy, aten.add]
# add => add
# tgt => add_1
# tgt2 => add_7, convert_element_type_9
# tgt_1 => add_8
triton_poi_fused__to_copy_add_7 = 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=[2097152],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: '*fp16', 3: '*fp16', 4: '*fp32', 5: '*fp32', 6: '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, 3, 4, 5, 6), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_add_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, '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, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xnumel = 1183744
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x2 = xindex
x0 = xindex % 256
tmp0 = tl.load(in_ptr0 + (x2), None)
tmp1 = tl.load(in_ptr1 + (x2), None).to(tl.float32)
tmp2 = tl.load(in_ptr2 + (x2), None).to(tl.float32)
tmp6 = tl.load(in_ptr3 + (x2), None).to(tl.float32)
tmp7 = tl.load(in_ptr4 + (x0), None, eviction_policy='evict_last')
tmp3 = tmp1 + tmp2
tmp4 = tmp3.to(tl.float32)
tmp5 = tmp0 + tmp4
tmp8 = tmp7.to(tl.float32)
tmp9 = tmp6 + tmp8
tmp10 = tmp9.to(tl.float32)
tmp11 = tmp5 + tmp10
tl.store(out_ptr0 + (x2), tmp11, None)
''', 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, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1 = args
args.clear()
assert_size_stride(arg0_1, (4624, 1, 256), (256, 256, 1))
assert_size_stride(arg1_1, (4624, 1, 256), (256, 256, 1))
assert_size_stride(arg2_1, (4624, 1, 256), (256, 256, 1))
assert_size_stride(arg3_1, (256, ), (1, ))
assert_size_stride(arg4_1, (256, ), (1, ))
assert_size_stride(arg5_1, (1024, 256), (256, 1))
assert_size_stride(arg6_1, (1024, ), (1, ))
assert_size_stride(arg7_1, (1024, ), (1, ))
assert_size_stride(arg8_1, (1024, ), (1, ))
assert_size_stride(arg9_1, (1024, 1, 5, 5), (25, 25, 5, 1))
assert_size_stride(arg10_1, (256, 1024), (1024, 1))
assert_size_stride(arg11_1, (256, ), (1, ))
with torch.cuda._DeviceGuard(0):
torch.cuda.set_device(0)
buf3 = empty_strided_cuda((4624, 1, 256), (256, 256, 1), torch.float16)
# Source Nodes: [_tgt, add, linear, tgt], Original ATen: [aten._to_copy, aten.add, aten.native_layer_norm]
stream0 = get_raw_stream(0)
triton_per_fused__to_copy_add_native_layer_norm_0.run(arg2_1, arg1_1, arg0_1, arg3_1, arg4_1, buf3, 4624, 256, grid=grid(4624), stream=stream0)
del arg3_1
del arg4_1
buf4 = empty_strided_cuda((1024, 256), (256, 1), torch.float16)
# Source Nodes: [linear], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_1.run(arg5_1, buf4, 262144, grid=grid(262144), stream=stream0)
del arg5_1
buf5 = empty_strided_cuda((4624, 1024), (1024, 1), torch.float16)
# Source Nodes: [], Original ATen: []
extern_kernels.mm(reinterpret_tensor(buf3, (4624, 256), (256, 1), 0), reinterpret_tensor(buf4, (256, 1024), (1, 256), 0), out=buf5)
buf6 = empty_strided_cuda((1, 32, 1, 1, 9, 101), (29088, 909, 29088, 29088, 101, 1), torch.float32)
buf7 = empty_strided_cuda((1, 32, 1, 1, 9, 101), (29088, 909, 29088, 29088, 101, 1), torch.float32)
buf8 = empty_strided_cuda((1, 32, 1, 1, 9, 101), (29088, 909, 29088, 29088, 101, 1), torch.float32)
# Source Nodes: [x_1], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_2.run(buf5, arg6_1, buf6, buf7, buf8, 29088, 163, grid=grid(29088), stream=stream0)
buf9 = empty_strided_cuda((1, 32, 1, 1, 9), (288, 9, 288, 288, 1), torch.float32)
buf10 = empty_strided_cuda((1, 32, 1, 1, 9), (288, 9, 288, 288, 1), torch.float32)
buf11 = empty_strided_cuda((1, 32, 1, 1, 9), (288, 9, 288, 288, 1), torch.float32)
# Source Nodes: [x_1], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_3.run(buf6, buf7, buf8, buf9, buf10, buf11, 288, 101, grid=grid(288), stream=stream0)
del buf6
del buf7
del buf8
buf12 = empty_strided_cuda((1, 32, 1, 1), (32, 1, 32, 32), torch.float32)
buf13 = empty_strided_cuda((1, 32, 1, 1), (32, 1, 32, 32), torch.float32)
# Source Nodes: [x_1], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_4.run(buf9, buf10, buf11, buf12, buf13, 32, 9, grid=grid(32), stream=stream0)
del buf10
del buf11
del buf9
buf16 = empty_strided_cuda((1, 1024, 68, 68), (4734976, 1, 69632, 1024), torch.float16)
# Source Nodes: [x_1, x_2, x_3], Original ATen: [aten._to_copy, aten.gelu, aten.native_group_norm]
triton_poi_fused__to_copy_gelu_native_group_norm_5.run(buf5, arg6_1, buf12, buf13, arg7_1, arg8_1, buf16, 4734976, grid=grid(4734976), stream=stream0)
del arg6_1
del arg7_1
del arg8_1
del buf12
del buf13
del buf5
buf17 = empty_strided_cuda((1024, 1, 5, 5), (25, 25, 5, 1), torch.float16)
# Source Nodes: [x_3], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_6.run(arg9_1, buf17, 25600, grid=grid(25600), stream=stream0)
del arg9_1
# Source Nodes: [x_2, x_3], Original ATen: [aten._to_copy, aten.convolution, aten.gelu]
buf18 = extern_kernels.convolution(buf16, buf17, stride=(1, 1), padding=(2, 2), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1024, bias=None)
assert_size_stride(buf18, (1, 1024, 68, 68), (4734976, 1, 69632, 1024))
del buf16
del buf17
buf19 = reinterpret_tensor(buf4, (256, 1024), (1024, 1), 0); del buf4 # reuse
# Source Nodes: [tgt2], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_1.run(arg10_1, buf19, 262144, grid=grid(262144), stream=stream0)
del arg10_1
buf20 = buf3; del buf3 # reuse
# Source Nodes: [tgt2], Original ATen: [aten.bmm]
extern_kernels.bmm(reinterpret_tensor(buf18, (4624, 1, 1024), (1024, 0, 1), 0), reinterpret_tensor(buf19, (4624, 1024, 256), (0, 1, 1024), 0), out=buf20)
del buf18
del buf19
buf21 = empty_strided_cuda((4624, 1, 256), (256, 256, 1), torch.float32)
# Source Nodes: [add, tgt, tgt2, tgt_1], Original ATen: [aten._to_copy, aten.add]
triton_poi_fused__to_copy_add_7.run(arg2_1, arg1_1, arg0_1, buf20, arg11_1, buf21, 1183744, grid=grid(1183744), stream=stream0)
del arg0_1
del arg11_1
del arg1_1
del arg2_1
del buf20
return (buf21, )
def benchmark_compiled_module(times=10, repeat=10):
from torch._dynamo.testing import rand_strided
from torch._inductor.utils import print_performance
arg0_1 = rand_strided((4624, 1, 256), (256, 256, 1), device='cuda:0', dtype=torch.float16)
arg1_1 = rand_strided((4624, 1, 256), (256, 256, 1), device='cuda:0', dtype=torch.float16)
arg2_1 = rand_strided((4624, 1, 256), (256, 256, 1), device='cuda:0', dtype=torch.float32)
arg3_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg4_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg5_1 = rand_strided((1024, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg6_1 = rand_strided((1024, ), (1, ), device='cuda:0', dtype=torch.float32)
arg7_1 = rand_strided((1024, ), (1, ), device='cuda:0', dtype=torch.float32)
arg8_1 = rand_strided((1024, ), (1, ), device='cuda:0', dtype=torch.float32)
arg9_1 = rand_strided((1024, 1, 5, 5), (25, 25, 5, 1), device='cuda:0', dtype=torch.float32)
arg10_1 = rand_strided((256, 1024), (1024, 1), device='cuda:0', dtype=torch.float32)
arg11_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
fn = lambda: call([arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_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)