# AOT ID: ['8_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/3c/c3cdgwun2icwrf3zhqiyeane4orfyepayezjptkilwxfkyeugulc.py
# Source Nodes: [r, relu], Original ATen: [aten._to_copy, aten.relu]
# r => convert_element_type_2
# relu => relu
triton_poi_fused__to_copy_relu_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=[256, 8192], tile_hint=TileHint.SQUARE,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 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, 2, 3), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_relu_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, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
ynumel = 256
xnumel = 4624
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (x1 + (4624*y0)), xmask & ymask, eviction_policy='evict_last')
tmp1 = tl.full([1, 1], 0, tl.int32)
tmp2 = triton_helpers.maximum(tmp1, tmp0)
tmp3 = tmp2.to(tl.float32)
tl.store(out_ptr0 + (y0 + (256*x1)), tmp3, xmask & ymask)
''', 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/op/cope7fqn5fciejdxhr522xuqugnvl7bczt6xa3h2g5vr6yjs4e66.py
# Source Nodes: [r], Original ATen: [aten._to_copy]
# r => 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=[65536, 16], tile_hint=TileHint.SQUARE,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 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, 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, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
ynumel = 65536
xnumel = 9
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x2 = xindex
y3 = yindex
y0 = yindex % 256
y1 = (yindex // 256)
tmp0 = tl.load(in_ptr0 + (x2 + (9*y3)), xmask, eviction_policy='evict_last')
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (y0 + (256*x2) + (2304*y1)), tmp1, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ax/caxq5wmd2hjaf4yfixabn7fjsgyhxbpoo6253gxz4pszvbxg3ozl.py
# Source Nodes: [r_1], Original ATen: [aten.native_group_norm]
# r_1 => var_mean
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=[16384, 128],
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, 6), 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 = 9272
rnumel = 128
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
r3 = rindex
x0 = xindex % 61
x1 = (xindex // 61) % 19
x2 = (xindex // 1159)
x5 = xindex % 1159
tmp0 = r3 + (128*x0)
tmp1 = tl.full([1, 1], 7788, tl.int32)
tmp2 = tmp0 < tmp1
tmp3 = r3 + (128*x0) + (7788*x1)
tmp4 = tl.full([1, 1], 147968, tl.int32)
tmp5 = tmp3 < tmp4
tmp6 = tmp5 & tmp2
tmp7 = tl.load(in_ptr0 + ((32*x2) + (256*((r3 + (128*x0) + (7788*x1)) % 4624)) + (((r3 + (128*x0) + (7788*x1)) // 4624) % 32)), rmask & tmp6 & xmask, eviction_policy='evict_last', other=0.0).to(tl.float32)
tmp8 = tl.load(in_ptr1 + ((32*x2) + (((r3 + (128*x0) + (7788*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 + (1184*x2)), tmp36, xmask)
tl.store(out_ptr1 + (x5 + (1184*x2)), tmp37, xmask)
tl.store(out_ptr2 + (x5 + (1184*x2)), tmp38, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/j5/cj5zu7medlkfmehtxjpn7ln3i5jreo7ni3vgllpuozwubmxwgmdh.py
# Source Nodes: [r_1], Original ATen: [aten.native_group_norm]
# r_1 => var_mean
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=[256, 64],
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), 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 = 152
rnumel = 61
RBLOCK: tl.constexpr = 64
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
r2 = rindex
x0 = xindex % 19
x1 = (xindex // 19)
x3 = xindex
tmp0 = tl.load(in_ptr0 + (r2 + (61*x0) + (1184*x1)), rmask & xmask, other=0.0)
tmp1 = tl.load(in_ptr1 + (r2 + (61*x0) + (1184*x1)), rmask & xmask, other=0.0)
tmp2 = tl.load(in_ptr2 + (r2 + (61*x0) + (1184*x1)), 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 + (x3), tmp13, xmask)
tl.store(out_ptr1 + (x3), tmp14, xmask)
tl.store(out_ptr2 + (x3), tmp15, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/b3/cb32gwrffrszlnm4jdrficdb5c5ea6mb3byijuotmqygpwdwqash.py
# Source Nodes: [r_1], Original ATen: [aten.native_group_norm]
# r_1 => var_mean
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=[8, 32],
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), 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 = 8
rnumel = 19
RBLOCK: tl.constexpr = 32
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 + (19*x0)), rmask & xmask, other=0.0)
tmp1 = tl.load(in_ptr1 + (r1 + (19*x0)), rmask & xmask, other=0.0)
tmp2 = tl.load(in_ptr2 + (r1 + (19*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/qf/cqfnhqm75c2c5flhhrsofeuatx53fns7ozr5aaekqvtmxrbhnmlt.py
# Source Nodes: [r_1, r_2, relu_1], Original ATen: [aten._to_copy, aten.native_group_norm, aten.relu]
# r_1 => add_1, mul_1
# r_2 => convert_element_type_6
# relu_1 => relu_1
triton_poi_fused__to_copy_native_group_norm_relu_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=[2097152],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp32', 2: '*fp32', 3: '*fp32', 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_native_group_norm_relu_5', 'mutated_arg_names': ['in_out_ptr0'], '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_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, 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_out_ptr0 + (x2), None).to(tl.float32)
tmp1 = tl.load(in_ptr0 + (x0), None, eviction_policy='evict_last')
tmp5 = tl.load(in_ptr1 + ((x0 // 32)), None, eviction_policy='evict_last')
tmp7 = tl.load(in_ptr2 + ((x0 // 32)), None, eviction_policy='evict_last')
tmp14 = tl.load(in_ptr3 + (x0), None, eviction_policy='evict_last')
tmp16 = tl.load(in_ptr4 + (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 = tl.full([1], 0, tl.int32)
tmp19 = triton_helpers.maximum(tmp18, tmp17)
tmp20 = tmp19.to(tl.float32)
tl.store(in_out_ptr0 + (x2), tmp20, None)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/yo/cyoiv6kr4futgl4cs7kwikumvma5fjivss2whp444t2ffykmquv2.py
# Source Nodes: [add, r_3, r_4, relu_2], Original ATen: [aten._to_copy, aten.add, aten.native_group_norm, aten.relu]
# add => add_4
# r_3 => add_3, mul_3
# r_4 => convert_element_type_10
# relu_2 => relu_2
triton_poi_fused__to_copy_add_native_group_norm_relu_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=[256, 8192], tile_hint=TileHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: '*fp16', 9: 'i32', 10: '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, 8, 9, 10), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_add_native_group_norm_relu_6', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 7, '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, in_ptr6, out_ptr0, out_ptr1, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
ynumel = 256
xnumel = 4624
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (x1 + (4624*y0)), xmask & ymask, eviction_policy='evict_last')
tmp1 = tl.load(in_ptr1 + (y0 + (256*x1)), xmask & ymask, eviction_policy='evict_last').to(tl.float32)
tmp2 = tl.load(in_ptr2 + (y0), ymask, eviction_policy='evict_last')
tmp6 = tl.load(in_ptr3 + ((y0 // 32)), ymask, eviction_policy='evict_last')
tmp8 = tl.load(in_ptr4 + ((y0 // 32)), ymask, eviction_policy='evict_last')
tmp15 = tl.load(in_ptr5 + (y0), ymask, eviction_policy='evict_last')
tmp17 = tl.load(in_ptr6 + (y0), ymask, eviction_policy='evict_last')
tmp3 = tmp2.to(tl.float32)
tmp4 = tmp1 + tmp3
tmp5 = tmp4.to(tl.float32)
tmp7 = tmp5 - tmp6
tmp9 = 147968.0
tmp10 = tmp8 / tmp9
tmp11 = 1e-05
tmp12 = tmp10 + tmp11
tmp13 = libdevice.rsqrt(tmp12)
tmp14 = tmp7 * tmp13
tmp16 = tmp14 * tmp15
tmp18 = tmp16 + tmp17
tmp19 = tmp0 + tmp18
tmp20 = tl.full([1, 1], 0, tl.int32)
tmp21 = triton_helpers.maximum(tmp20, tmp19)
tmp22 = tmp21.to(tl.float32)
tl.store(out_ptr0 + (x1 + (4640*y0)), tmp19, xmask & ymask)
tl.store(out_ptr1 + (y0 + (256*x1)), tmp22, xmask & ymask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ty/ctyen3fm7gd5twz5bnd2afil6vamjxgbigdtzm2kcnwzolamltj4.py
# Source Nodes: [add_1, r_7], Original ATen: [aten.add, aten.native_group_norm]
# add_1 => add_9
# r_7 => add_8, mul_7
triton_poi_fused_add_native_group_norm_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=[256, 8192], tile_hint=TileHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: 'i32', 9: '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, 8, 9), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_native_group_norm_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 7, '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, in_ptr6, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
ynumel = 256
xnumel = 4624
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (x1 + (4640*y0)), xmask & ymask, eviction_policy='evict_last')
tmp1 = tl.load(in_ptr1 + (y0 + (256*x1)), xmask & ymask, eviction_policy='evict_last').to(tl.float32)
tmp2 = tl.load(in_ptr2 + (y0), ymask, eviction_policy='evict_last')
tmp6 = tl.load(in_ptr3 + ((y0 // 32)), ymask, eviction_policy='evict_last')
tmp8 = tl.load(in_ptr4 + ((y0 // 32)), ymask, eviction_policy='evict_last')
tmp15 = tl.load(in_ptr5 + (y0), ymask, eviction_policy='evict_last')
tmp17 = tl.load(in_ptr6 + (y0), ymask, eviction_policy='evict_last')
tmp3 = tmp2.to(tl.float32)
tmp4 = tmp1 + tmp3
tmp5 = tmp4.to(tl.float32)
tmp7 = tmp5 - tmp6
tmp9 = 147968.0
tmp10 = tmp8 / tmp9
tmp11 = 1e-05
tmp12 = tmp10 + tmp11
tmp13 = libdevice.rsqrt(tmp12)
tmp14 = tmp7 * tmp13
tmp16 = tmp14 * tmp15
tmp18 = tmp16 + tmp17
tmp19 = tmp0 + tmp18
tl.store(out_ptr0 + (x1 + (4624*y0)), tmp19, xmask & ymask)
''', 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, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1 = args
args.clear()
assert_size_stride(arg0_1, (1, 256, 68, 68), (1183744, 4624, 68, 1))
assert_size_stride(arg1_1, (256, 256, 3, 3), (2304, 9, 3, 1))
assert_size_stride(arg2_1, (256, ), (1, ))
assert_size_stride(arg3_1, (256, ), (1, ))
assert_size_stride(arg4_1, (256, ), (1, ))
assert_size_stride(arg5_1, (256, 256, 3, 3), (2304, 9, 3, 1))
assert_size_stride(arg6_1, (256, ), (1, ))
assert_size_stride(arg7_1, (256, ), (1, ))
assert_size_stride(arg8_1, (256, ), (1, ))
assert_size_stride(arg9_1, (256, 256, 3, 3), (2304, 9, 3, 1))
assert_size_stride(arg10_1, (256, ), (1, ))
assert_size_stride(arg11_1, (256, ), (1, ))
assert_size_stride(arg12_1, (256, ), (1, ))
assert_size_stride(arg13_1, (256, 256, 3, 3), (2304, 9, 3, 1))
assert_size_stride(arg14_1, (256, ), (1, ))
assert_size_stride(arg15_1, (256, ), (1, ))
assert_size_stride(arg16_1, (256, ), (1, ))
with torch.cuda._DeviceGuard(0):
torch.cuda.set_device(0)
buf0 = empty_strided_cuda((1, 256, 68, 68), (1183744, 1, 17408, 256), torch.float16)
# Source Nodes: [r, relu], Original ATen: [aten._to_copy, aten.relu]
stream0 = get_raw_stream(0)
triton_poi_fused__to_copy_relu_0.run(arg0_1, buf0, 256, 4624, grid=grid(256, 4624), stream=stream0)
buf1 = empty_strided_cuda((256, 256, 3, 3), (2304, 1, 768, 256), torch.float16)
# Source Nodes: [r], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_1.run(arg1_1, buf1, 65536, 9, grid=grid(65536, 9), stream=stream0)
del arg1_1
# Source Nodes: [r, relu], Original ATen: [aten._to_copy, aten.convolution, aten.relu]
buf2 = extern_kernels.convolution(buf0, buf1, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
assert_size_stride(buf2, (1, 256, 68, 68), (1183744, 1, 17408, 256))
del buf0
buf3 = empty_strided_cuda((1, 8, 1, 1, 19, 61), (9472, 1184, 9472, 9472, 61, 1), torch.float32)
buf4 = empty_strided_cuda((1, 8, 1, 1, 19, 61), (9472, 1184, 9472, 9472, 61, 1), torch.float32)
buf5 = empty_strided_cuda((1, 8, 1, 1, 19, 61), (9472, 1184, 9472, 9472, 61, 1), torch.float32)
# Source Nodes: [r_1], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_2.run(buf2, arg2_1, buf3, buf4, buf5, 9272, 128, grid=grid(9272), stream=stream0)
buf6 = empty_strided_cuda((1, 8, 1, 1, 19), (152, 19, 152, 152, 1), torch.float32)
buf7 = empty_strided_cuda((1, 8, 1, 1, 19), (152, 19, 152, 152, 1), torch.float32)
buf8 = empty_strided_cuda((1, 8, 1, 1, 19), (152, 19, 152, 152, 1), torch.float32)
# Source Nodes: [r_1], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_3.run(buf3, buf4, buf5, buf6, buf7, buf8, 152, 61, grid=grid(152), stream=stream0)
buf9 = empty_strided_cuda((1, 8, 1, 1), (8, 1, 8, 8), torch.float32)
buf10 = empty_strided_cuda((1, 8, 1, 1), (8, 1, 8, 8), torch.float32)
# Source Nodes: [r_1], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_4.run(buf6, buf7, buf8, buf9, buf10, 8, 19, grid=grid(8), stream=stream0)
buf12 = buf2; del buf2 # reuse
# Source Nodes: [r_1, r_2, relu_1], Original ATen: [aten._to_copy, aten.native_group_norm, aten.relu]
triton_poi_fused__to_copy_native_group_norm_relu_5.run(buf12, arg2_1, buf9, buf10, arg3_1, arg4_1, 1183744, grid=grid(1183744), stream=stream0)
del arg2_1
del arg3_1
del arg4_1
buf13 = buf1; del buf1 # reuse
# Source Nodes: [r_2], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_1.run(arg5_1, buf13, 65536, 9, grid=grid(65536, 9), stream=stream0)
del arg5_1
# Source Nodes: [r_1, r_2, relu_1], Original ATen: [aten._to_copy, aten.convolution, aten.native_group_norm, aten.relu]
buf14 = extern_kernels.convolution(buf12, buf13, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
assert_size_stride(buf14, (1, 256, 68, 68), (1183744, 1, 17408, 256))
buf15 = buf5; del buf5 # reuse
buf16 = buf4; del buf4 # reuse
buf17 = buf3; del buf3 # reuse
# Source Nodes: [r_3], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_2.run(buf14, arg6_1, buf15, buf16, buf17, 9272, 128, grid=grid(9272), stream=stream0)
buf18 = buf8; del buf8 # reuse
buf19 = buf7; del buf7 # reuse
buf20 = buf6; del buf6 # reuse
# Source Nodes: [r_3], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_3.run(buf15, buf16, buf17, buf18, buf19, buf20, 152, 61, grid=grid(152), stream=stream0)
buf21 = buf9; del buf9 # reuse
buf22 = buf10; del buf10 # reuse
# Source Nodes: [r_3], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_4.run(buf18, buf19, buf20, buf21, buf22, 8, 19, grid=grid(8), stream=stream0)
buf24 = empty_strided_cuda((1, 256, 68, 68), (1187840, 4640, 68, 1), torch.float32)
buf25 = buf12; del buf12 # reuse
# Source Nodes: [add, r_3, r_4, relu_2], Original ATen: [aten._to_copy, aten.add, aten.native_group_norm, aten.relu]
triton_poi_fused__to_copy_add_native_group_norm_relu_6.run(arg0_1, buf14, arg6_1, buf21, buf22, arg7_1, arg8_1, buf24, buf25, 256, 4624, grid=grid(256, 4624), stream=stream0)
del arg0_1
del arg6_1
del arg7_1
del arg8_1
del buf14
buf26 = buf13; del buf13 # reuse
# Source Nodes: [r_4], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_1.run(arg9_1, buf26, 65536, 9, grid=grid(65536, 9), stream=stream0)
del arg9_1
# Source Nodes: [r_4, relu_2], Original ATen: [aten._to_copy, aten.convolution, aten.relu]
buf27 = extern_kernels.convolution(buf25, buf26, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
assert_size_stride(buf27, (1, 256, 68, 68), (1183744, 1, 17408, 256))
del buf25
buf28 = buf17; del buf17 # reuse
buf29 = buf16; del buf16 # reuse
buf30 = buf15; del buf15 # reuse
# Source Nodes: [r_5], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_2.run(buf27, arg10_1, buf28, buf29, buf30, 9272, 128, grid=grid(9272), stream=stream0)
buf31 = buf20; del buf20 # reuse
buf32 = buf19; del buf19 # reuse
buf33 = buf18; del buf18 # reuse
# Source Nodes: [r_5], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_3.run(buf28, buf29, buf30, buf31, buf32, buf33, 152, 61, grid=grid(152), stream=stream0)
buf34 = buf22; del buf22 # reuse
buf35 = buf21; del buf21 # reuse
# Source Nodes: [r_5], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_4.run(buf31, buf32, buf33, buf34, buf35, 8, 19, grid=grid(8), stream=stream0)
buf37 = buf27; del buf27 # reuse
# Source Nodes: [r_5, r_6, relu_3], Original ATen: [aten._to_copy, aten.native_group_norm, aten.relu]
triton_poi_fused__to_copy_native_group_norm_relu_5.run(buf37, arg10_1, buf34, buf35, arg11_1, arg12_1, 1183744, grid=grid(1183744), stream=stream0)
del arg10_1
del arg11_1
del arg12_1
buf38 = buf26; del buf26 # reuse
# Source Nodes: [r_6], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_1.run(arg13_1, buf38, 65536, 9, grid=grid(65536, 9), stream=stream0)
del arg13_1
# Source Nodes: [r_5, r_6, relu_3], Original ATen: [aten._to_copy, aten.convolution, aten.native_group_norm, aten.relu]
buf39 = extern_kernels.convolution(buf37, buf38, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
assert_size_stride(buf39, (1, 256, 68, 68), (1183744, 1, 17408, 256))
del buf37
del buf38
buf40 = buf30; del buf30 # reuse
buf41 = buf29; del buf29 # reuse
buf42 = buf28; del buf28 # reuse
# Source Nodes: [r_7], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_2.run(buf39, arg14_1, buf40, buf41, buf42, 9272, 128, grid=grid(9272), stream=stream0)
buf43 = buf33; del buf33 # reuse
buf44 = buf32; del buf32 # reuse
buf45 = buf31; del buf31 # reuse
# Source Nodes: [r_7], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_3.run(buf40, buf41, buf42, buf43, buf44, buf45, 152, 61, grid=grid(152), stream=stream0)
del buf40
del buf41
del buf42
buf46 = buf35; del buf35 # reuse
buf47 = buf34; del buf34 # reuse
# Source Nodes: [r_7], Original ATen: [aten.native_group_norm]
triton_per_fused_native_group_norm_4.run(buf43, buf44, buf45, buf46, buf47, 8, 19, grid=grid(8), stream=stream0)
del buf43
del buf44
del buf45
buf49 = empty_strided_cuda((1, 256, 68, 68), (1183744, 4624, 68, 1), torch.float32)
# Source Nodes: [add_1, r_7], Original ATen: [aten.add, aten.native_group_norm]
triton_poi_fused_add_native_group_norm_7.run(buf24, buf39, arg14_1, buf46, buf47, arg15_1, arg16_1, buf49, 256, 4624, grid=grid(256, 4624), stream=stream0)
del arg14_1
del arg15_1
del arg16_1
del buf24
del buf39
del buf46
del buf47
return (buf49, )
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((1, 256, 68, 68), (1183744, 4624, 68, 1), device='cuda:0', dtype=torch.float32)
arg1_1 = rand_strided((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
arg2_1 = rand_strided((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((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
arg6_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg7_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg8_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg9_1 = rand_strided((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
arg10_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg11_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg12_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg13_1 = rand_strided((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
arg14_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg15_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg16_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, arg12_1, arg13_1, arg14_1, arg15_1, arg16_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)