# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
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
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

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
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_7/inductor_cache/wf/cwfmdhu3ccgn42tlvywxwfl2rjkbyxes3rkmno2onyq4lvajjauc.py
# Topologically Sorted Source Nodes: [ll], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   ll => cat
# Graph fragment:
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%add_1, %add_2, %sub_2], 1), kwargs = {})
triton_poi_fused_cat_0 = async_compile.triton('triton_poi_fused_cat_0', '''
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: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_cat_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 9, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, '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_poi_fused_cat_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 49152
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x1 = (xindex // 4096) % 3
    x0 = xindex % 4096
    x2 = (xindex // 12288)
    x3 = xindex
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + (16384*x2)), tmp4, eviction_policy='evict_last', other=0.0)
    tmp6 = 0.299
    tmp7 = tmp5 * tmp6
    tmp8 = tl.load(in_ptr0 + (4096 + x0 + (16384*x2)), tmp4, eviction_policy='evict_last', other=0.0)
    tmp9 = 0.587
    tmp10 = tmp8 * tmp9
    tmp11 = tmp7 + tmp10
    tmp12 = tl.load(in_ptr0 + (8192 + x0 + (16384*x2)), tmp4, eviction_policy='evict_last', other=0.0)
    tmp13 = 0.114
    tmp14 = tmp12 * tmp13
    tmp15 = tmp11 + tmp14
    tmp16 = tl.full(tmp15.shape, 0.0, tmp15.dtype)
    tmp17 = tl.where(tmp4, tmp15, tmp16)
    tmp18 = tmp0 >= tmp3
    tmp19 = tl.full([1], 2, tl.int64)
    tmp20 = tmp0 < tmp19
    tmp21 = tmp18 & tmp20
    tmp22 = tl.load(in_ptr0 + (x0 + (16384*x2)), tmp21, eviction_policy='evict_last', other=0.0)
    tmp23 = -0.16875
    tmp24 = tmp22 * tmp23
    tmp25 = tl.load(in_ptr0 + (4096 + x0 + (16384*x2)), tmp21, eviction_policy='evict_last', other=0.0)
    tmp26 = 0.33126
    tmp27 = tmp25 * tmp26
    tmp28 = tmp24 - tmp27
    tmp29 = tl.load(in_ptr0 + (8192 + x0 + (16384*x2)), tmp21, eviction_policy='evict_last', other=0.0)
    tmp30 = 0.5
    tmp31 = tmp29 * tmp30
    tmp32 = tmp28 + tmp31
    tmp33 = tl.full(tmp32.shape, 0.0, tmp32.dtype)
    tmp34 = tl.where(tmp21, tmp32, tmp33)
    tmp35 = tmp0 >= tmp19
    tmp36 = tl.full([1], 3, tl.int64)
    tmp37 = tmp0 < tmp36
    tmp38 = tl.load(in_ptr0 + (x0 + (16384*x2)), tmp35, eviction_policy='evict_last', other=0.0)
    tmp39 = tmp38 * tmp30
    tmp40 = tl.load(in_ptr0 + (4096 + x0 + (16384*x2)), tmp35, eviction_policy='evict_last', other=0.0)
    tmp41 = 0.41869
    tmp42 = tmp40 * tmp41
    tmp43 = tmp39 - tmp42
    tmp44 = tl.load(in_ptr0 + (8192 + x0 + (16384*x2)), tmp35, eviction_policy='evict_last', other=0.0)
    tmp45 = 0.08131
    tmp46 = tmp44 * tmp45
    tmp47 = tmp43 - tmp46
    tmp48 = tl.full(tmp47.shape, 0.0, tmp47.dtype)
    tmp49 = tl.where(tmp35, tmp47, tmp48)
    tmp50 = tl.where(tmp21, tmp34, tmp49)
    tmp51 = tl.where(tmp4, tmp17, tmp50)
    tl.store(out_ptr0 + (x3), tmp51, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/ku/ckumpwajqevulil7b6yp53yneqbbpl5depnwkbz3cxzybx4tzuoh.py
# Topologically Sorted Source Nodes: [pad], Original ATen: [aten.reflection_pad2d]
# Source node to ATen node mapping:
#   pad => _unsafe_index, _unsafe_index_1
# Graph fragment:
#   %_unsafe_index : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat, [None, None, %sub_4, None]), kwargs = {})
#   %_unsafe_index_1 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%_unsafe_index, [None, None, None, %sub_6]), kwargs = {})
triton_poi_fused_reflection_pad2d_1 = async_compile.triton('triton_poi_fused_reflection_pad2d_1', '''
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=[16, 8192], tile_hint=TileHint.SQUARE,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_reflection_pad2d_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, '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_poi_fused_reflection_pad2d_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
    ynumel = 12
    xnumel = 4608
    yoffset = tl.program_id(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 % 72
    x3 = (xindex // 72)
    y4 = yindex
    x5 = xindex
    y0 = yindex % 3
    y1 = (yindex // 3)
    tmp0 = tl.load(in_ptr0 + (4095 + ((-1)*(tl_math.abs((-63) + (tl_math.abs((-4) + x2))))) + ((-64)*(tl_math.abs((-63) + x3))) + (4096*y4)), xmask & ymask, eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + (3*x5) + (13824*y1)), tmp0, xmask & ymask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/di/cdicidl3cxykw4clroikgcj2de4ch2aa5hngcyrkzbsbm5kphotm.py
# Topologically Sorted Source Nodes: [pad, conv2d], Original ATen: [aten.reflection_pad2d, aten.convolution]
# Source node to ATen node mapping:
#   conv2d => convolution
#   pad => _unsafe_index, _unsafe_index_1
# Graph fragment:
#   %_unsafe_index : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat, [None, None, %sub_4, None]), kwargs = {})
#   %_unsafe_index_1 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%_unsafe_index, [None, None, None, %sub_6]), kwargs = {})
#   %convolution : [num_users=1] = call_function[target=torch.ops.aten.convolution.default](args = (%_unsafe_index_1, %arg1_1, None, [1, 1], [0, 0], [1, 1], False, [0, 0], 1), kwargs = {})
triton_poi_fused_convolution_reflection_pad2d_2 = async_compile.triton('triton_poi_fused_convolution_reflection_pad2d_2', '''
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=[16, 16], tile_hint=TileHint.SQUARE,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_convolution_reflection_pad2d_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, '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_poi_fused_convolution_reflection_pad2d_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
    ynumel = 9
    xnumel = 9
    yoffset = tl.program_id(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 % 3
    y1 = (yindex // 3)
    tmp0 = tl.load(in_ptr0 + (x2 + (9*y3)), xmask & ymask)
    tl.store(out_ptr0 + (y0 + (3*x2) + (27*y1)), tmp0, xmask & ymask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/pd/cpdp5pujjstn3pe3jage67qkvumeqzq3z6tzpqnmtvernsddwxtv.py
# Topologically Sorted Source Nodes: [pad_1], Original ATen: [aten.reflection_pad2d]
# Source node to ATen node mapping:
#   pad_1 => _unsafe_index_2, _unsafe_index_3
# Graph fragment:
#   %_unsafe_index_2 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%convolution, [None, None, %sub_8, None]), kwargs = {})
#   %_unsafe_index_3 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%_unsafe_index_2, [None, None, None, %sub_10]), kwargs = {})
triton_poi_fused_reflection_pad2d_3 = async_compile.triton('triton_poi_fused_reflection_pad2d_3', '''
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: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_reflection_pad2d_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, '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_poi_fused_reflection_pad2d_3(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 55296
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 3
    x1 = (xindex // 3) % 64
    x2 = (xindex // 192) % 72
    x3 = (xindex // 13824)
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (12285 + x0 + ((-192)*(tl_math.abs((-63) + (tl_math.abs((-4) + x2))))) + ((-3)*(tl_math.abs((-63) + x1))) + (12288*x3)), None)
    tl.store(out_ptr0 + (x4), tmp0, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/oe/coe4k6o3ewqe4vvn6k5ijj3w6bypqkamoo2k5drbk442lkzbz2q3.py
# Topologically Sorted Source Nodes: [rgb_shifted], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   rgb_shifted => cat_1
# Graph fragment:
#   %cat_1 : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%add_3, %sub_12, %add_4], 1), kwargs = {})
triton_poi_fused_cat_4 = async_compile.triton('triton_poi_fused_cat_4', '''
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: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_cat_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 7, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, '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_poi_fused_cat_4(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 49152
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x1 = (xindex // 4096) % 3
    x0 = xindex % 4096
    x2 = (xindex // 12288)
    x3 = xindex
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + ((3*x0) + (12288*x2)), tmp4, eviction_policy='evict_last', other=0.0)
    tmp6 = tl.load(in_ptr0 + (2 + (3*x0) + (12288*x2)), tmp4, eviction_policy='evict_last', other=0.0)
    tmp7 = 1.402
    tmp8 = tmp6 * tmp7
    tmp9 = tmp5 + tmp8
    tmp10 = tl.full(tmp9.shape, 0.0, tmp9.dtype)
    tmp11 = tl.where(tmp4, tmp9, tmp10)
    tmp12 = tmp0 >= tmp3
    tmp13 = tl.full([1], 2, tl.int64)
    tmp14 = tmp0 < tmp13
    tmp15 = tmp12 & tmp14
    tmp16 = tl.load(in_ptr0 + ((3*x0) + (12288*x2)), tmp15, eviction_policy='evict_last', other=0.0)
    tmp17 = tl.load(in_ptr0 + (1 + (3*x0) + (12288*x2)), tmp15, eviction_policy='evict_last', other=0.0)
    tmp18 = 0.34413
    tmp19 = tmp17 * tmp18
    tmp20 = tmp16 - tmp19
    tmp21 = tl.load(in_ptr0 + (2 + (3*x0) + (12288*x2)), tmp15, eviction_policy='evict_last', other=0.0)
    tmp22 = 0.71414
    tmp23 = tmp21 * tmp22
    tmp24 = tmp20 - tmp23
    tmp25 = tl.full(tmp24.shape, 0.0, tmp24.dtype)
    tmp26 = tl.where(tmp15, tmp24, tmp25)
    tmp27 = tmp0 >= tmp13
    tmp28 = tl.full([1], 3, tl.int64)
    tmp29 = tmp0 < tmp28
    tmp30 = tl.load(in_ptr0 + ((3*x0) + (12288*x2)), tmp27, eviction_policy='evict_last', other=0.0)
    tmp31 = tl.load(in_ptr0 + (1 + (3*x0) + (12288*x2)), tmp27, eviction_policy='evict_last', other=0.0)
    tmp32 = 1.772
    tmp33 = tmp31 * tmp32
    tmp34 = tmp30 + tmp33
    tmp35 = tl.full(tmp34.shape, 0.0, tmp34.dtype)
    tmp36 = tl.where(tmp27, tmp34, tmp35)
    tmp37 = tl.where(tmp15, tmp26, tmp36)
    tmp38 = tl.where(tmp4, tmp11, tmp37)
    tl.store(out_ptr0 + (x3), tmp38, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1, arg2_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 64, 64), (16384, 4096, 64, 1))
    assert_size_stride(arg1_1, (3, 3, 1, 9), (27, 9, 9, 1))
    assert_size_stride(arg2_1, (3, 3, 9, 1), (27, 9, 1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 64, 64), (12288, 4096, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [ll], Original ATen: [aten.cat]
        stream0 = get_raw_stream(0)
        triton_poi_fused_cat_0.run(arg0_1, buf0, 49152, grid=grid(49152), stream=stream0)
        del arg0_1
        buf1 = empty_strided_cuda((4, 3, 64, 72), (13824, 1, 216, 3), torch.float32)
        # Topologically Sorted Source Nodes: [pad], Original ATen: [aten.reflection_pad2d]
        triton_poi_fused_reflection_pad2d_1.run(buf0, buf1, 12, 4608, grid=grid(12, 4608), stream=stream0)
        del buf0
        buf2 = empty_strided_cuda((3, 3, 1, 9), (27, 1, 27, 3), torch.float32)
        # Topologically Sorted Source Nodes: [pad, conv2d], Original ATen: [aten.reflection_pad2d, aten.convolution]
        triton_poi_fused_convolution_reflection_pad2d_2.run(arg1_1, buf2, 9, 9, grid=grid(9, 9), stream=stream0)
        del arg1_1
        # Topologically Sorted Source Nodes: [pad, conv2d], Original ATen: [aten.reflection_pad2d, aten.convolution]
        buf3 = extern_kernels.convolution(buf1, buf2, stride=(1, 1), padding=(0, 0), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 3, 64, 64), (12288, 1, 192, 3))
        buf4 = reinterpret_tensor(buf1, (4, 3, 72, 64), (13824, 1, 192, 3), 0); del buf1  # reuse
        # Topologically Sorted Source Nodes: [pad_1], Original ATen: [aten.reflection_pad2d]
        triton_poi_fused_reflection_pad2d_3.run(buf3, buf4, 55296, grid=grid(55296), stream=stream0)
        buf5 = reinterpret_tensor(buf2, (3, 3, 9, 1), (27, 1, 3, 3), 0); del buf2  # reuse
        # Topologically Sorted Source Nodes: [pad_1, ll_1], Original ATen: [aten.reflection_pad2d, aten.convolution]
        triton_poi_fused_convolution_reflection_pad2d_2.run(arg2_1, buf5, 9, 9, grid=grid(9, 9), stream=stream0)
        del arg2_1
        # Topologically Sorted Source Nodes: [pad_1, ll_1], Original ATen: [aten.reflection_pad2d, aten.convolution]
        buf6 = extern_kernels.convolution(buf4, buf5, stride=(1, 1), padding=(0, 0), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 3, 64, 64), (12288, 1, 192, 3))
        del buf4
        del buf5
        buf7 = reinterpret_tensor(buf3, (4, 3, 64, 64), (12288, 4096, 64, 1), 0); del buf3  # reuse
        # Topologically Sorted Source Nodes: [rgb_shifted], Original ATen: [aten.cat]
        triton_poi_fused_cat_4.run(buf6, buf7, 49152, grid=grid(49152), stream=stream0)
        del buf6
    return (buf7, )


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((4, 4, 64, 64), (16384, 4096, 64, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((3, 3, 1, 9), (27, 9, 9, 1), device='cuda:0', dtype=torch.float32)
    arg2_1 = rand_strided((3, 3, 9, 1), (27, 9, 1, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1, arg2_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)

import torch
import torch.nn.parallel
import torch.utils.data
from torch import nn
import torch.fft


class LossyYCbCr(nn.Module):

    def forward(self, rgb: 'torch.Tensor'):
        return torch.cat([0.299 * rgb[:, 0:1] + 0.587 * rgb[:, 1:2] + 0.114 *
            rgb[:, 2:3], -0.16875 * rgb[:, 0:1] - 0.33126 * rgb[:, 1:2] + 
            0.5 * rgb[:, 2:3], 0.5 * rgb[:, 0:1] - 0.41869 * rgb[:, 1:2] - 
            0.08131 * rgb[:, 2:3]], dim=1)


class LossyRGB(nn.Module):

    def forward(self, ycbcr: 'torch.Tensor'):
        return torch.cat([ycbcr[:, 0:1] + 1.402 * ycbcr[:, 2:3], ycbcr[:, 0
            :1] - 0.34413 * ycbcr[:, 1:2] - 0.71414 * ycbcr[:, 2:3], ycbcr[
            :, 0:1] + 1.772 * ycbcr[:, 1:2]], dim=1)


class LosslessYCbCr(nn.Module):

    def forward(self, rgb: 'torch.Tensor'):
        return torch.cat([(rgb[:, 0:1] + 2 * rgb[:, 1:2] + rgb[:, 2:3]) / 4,
            rgb[:, 2:3] - rgb[:, 1:2], rgb[:, 0:1] - rgb[:, 1:2]], dim=1)


class LosslessRGB(nn.Module):

    def forward(self, ycbcr: 'torch.Tensor'):
        return torch.cat([ycbcr[:, 2:3] + ycbcr[:, 0:1] - 0.25 * ycbcr[:, 1
            :2] - 0.25 * ycbcr[:, 2:3], ycbcr[:, 0:1] - 0.25 * ycbcr[:, 1:2
            ] - 0.25 * ycbcr[:, 2:3], ycbcr[:, 1:2] + ycbcr[:, 0:1] - 0.25 *
            ycbcr[:, 1:2] - 0.25 * ycbcr[:, 2:3]], dim=1)


class DWT(nn.Module):

    def __init__(self, lossy: 'bool'=True):
        super().__init__()
        if lossy:
            dec_lo = [0.02674875741080976, -0.01686411844287495, -
                0.07822326652898785, 0.2668641184428723, 0.6029490182363579,
                0.2668641184428723, -0.07822326652898785, -
                0.01686411844287495, 0.02674875741080976]
            self.to_ycbcr = LossyYCbCr()
            self.to_rgb = LossyRGB()
            None
        else:
            dec_lo = [-0.125, 0.25, 0.75, 0.25, -0.125]
            self.to_ycbcr = LosslessYCbCr()
            self.to_rgb = LosslessRGB()
            None
        self.dwt_vertical = nn.Conv2d(3, 3, (len(dec_lo), 1), padding=(len(
            dec_lo) // 2, 0), bias=False, padding_mode='reflect')
        self.dwt_horizontal = nn.Conv2d(3, 3, (1, len(dec_lo)), padding=(0,
            len(dec_lo) // 2), bias=False, padding_mode='reflect')
        self.dwt_vertical.weight.requires_grad = False
        self.dwt_horizontal.weight.requires_grad = False
        self.dwt_vertical.weight.fill_(0)
        self.dwt_horizontal.weight.fill_(0)
        for c in range(3):
            for i in range(len(dec_lo)):
                self.dwt_vertical.weight[c, c, i, 0] = dec_lo[i]
                self.dwt_horizontal.weight[c, c, 0, i] = dec_lo[i]

    def forward(self, image: 'torch.Tensor', k: 'int'=1) ->torch.Tensor:
        """
        Args:
            image: 画素値0.0-1.0の画像バッチ
        """
        ll = self.to_ycbcr(image)
        for i in range(k):
            ll = self.dwt_vertical(self.dwt_horizontal(ll))
        rgb_shifted = self.to_rgb(ll)
        return rgb_shifted


def get_inputs():
    return [torch.rand([4, 4, 64, 64])]


def get_init_inputs():
    return [[], {}]

import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn.parallel
import torch.utils.data
from torch import nn
import torch.fft
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_cat_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 4096 % 3
    x0 = xindex % 4096
    x2 = xindex // 12288
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 16384 * x2), tmp4, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = 0.299
    tmp7 = tmp5 * tmp6
    tmp8 = tl.load(in_ptr0 + (4096 + x0 + 16384 * x2), tmp4,
        eviction_policy='evict_last', other=0.0)
    tmp9 = 0.587
    tmp10 = tmp8 * tmp9
    tmp11 = tmp7 + tmp10
    tmp12 = tl.load(in_ptr0 + (8192 + x0 + 16384 * x2), tmp4,
        eviction_policy='evict_last', other=0.0)
    tmp13 = 0.114
    tmp14 = tmp12 * tmp13
    tmp15 = tmp11 + tmp14
    tmp16 = tl.full(tmp15.shape, 0.0, tmp15.dtype)
    tmp17 = tl.where(tmp4, tmp15, tmp16)
    tmp18 = tmp0 >= tmp3
    tmp19 = tl.full([1], 2, tl.int64)
    tmp20 = tmp0 < tmp19
    tmp21 = tmp18 & tmp20
    tmp22 = tl.load(in_ptr0 + (x0 + 16384 * x2), tmp21, eviction_policy=
        'evict_last', other=0.0)
    tmp23 = -0.16875
    tmp24 = tmp22 * tmp23
    tmp25 = tl.load(in_ptr0 + (4096 + x0 + 16384 * x2), tmp21,
        eviction_policy='evict_last', other=0.0)
    tmp26 = 0.33126
    tmp27 = tmp25 * tmp26
    tmp28 = tmp24 - tmp27
    tmp29 = tl.load(in_ptr0 + (8192 + x0 + 16384 * x2), tmp21,
        eviction_policy='evict_last', other=0.0)
    tmp30 = 0.5
    tmp31 = tmp29 * tmp30
    tmp32 = tmp28 + tmp31
    tmp33 = tl.full(tmp32.shape, 0.0, tmp32.dtype)
    tmp34 = tl.where(tmp21, tmp32, tmp33)
    tmp35 = tmp0 >= tmp19
    tl.full([1], 3, tl.int64)
    tmp38 = tl.load(in_ptr0 + (x0 + 16384 * x2), tmp35, eviction_policy=
        'evict_last', other=0.0)
    tmp39 = tmp38 * tmp30
    tmp40 = tl.load(in_ptr0 + (4096 + x0 + 16384 * x2), tmp35,
        eviction_policy='evict_last', other=0.0)
    tmp41 = 0.41869
    tmp42 = tmp40 * tmp41
    tmp43 = tmp39 - tmp42
    tmp44 = tl.load(in_ptr0 + (8192 + x0 + 16384 * x2), tmp35,
        eviction_policy='evict_last', other=0.0)
    tmp45 = 0.08131
    tmp46 = tmp44 * tmp45
    tmp47 = tmp43 - tmp46
    tmp48 = tl.full(tmp47.shape, 0.0, tmp47.dtype)
    tmp49 = tl.where(tmp35, tmp47, tmp48)
    tmp50 = tl.where(tmp21, tmp34, tmp49)
    tmp51 = tl.where(tmp4, tmp17, tmp50)
    tl.store(out_ptr0 + x3, tmp51, None)


@triton.jit
def triton_poi_fused_reflection_pad2d_1(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 12
    xnumel = 4608
    yoffset = tl.program_id(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 % 72
    x3 = xindex // 72
    y4 = yindex
    x5 = xindex
    y0 = yindex % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-4 +
        x2)) + -64 * tl_math.abs(-63 + x3) + 4096 * y4), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x5 + 13824 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_reflection_pad2d_2(in_ptr0, out_ptr0,
    ynumel, xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 9
    xnumel = 9
    yoffset = tl.program_id(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 % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask)
    tl.store(out_ptr0 + (y0 + 3 * x2 + 27 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_reflection_pad2d_3(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 3
    x1 = xindex // 3 % 64
    x2 = xindex // 192 % 72
    x3 = xindex // 13824
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (12285 + x0 + -192 * tl_math.abs(-63 + tl_math
        .abs(-4 + x2)) + -3 * tl_math.abs(-63 + x1) + 12288 * x3), None)
    tl.store(out_ptr0 + x4, tmp0, None)


@triton.jit
def triton_poi_fused_cat_4(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 4096 % 3
    x0 = xindex % 4096
    x2 = xindex // 12288
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (3 * x0 + 12288 * x2), tmp4, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tl.load(in_ptr0 + (2 + 3 * x0 + 12288 * x2), tmp4,
        eviction_policy='evict_last', other=0.0)
    tmp7 = 1.402
    tmp8 = tmp6 * tmp7
    tmp9 = tmp5 + tmp8
    tmp10 = tl.full(tmp9.shape, 0.0, tmp9.dtype)
    tmp11 = tl.where(tmp4, tmp9, tmp10)
    tmp12 = tmp0 >= tmp3
    tmp13 = tl.full([1], 2, tl.int64)
    tmp14 = tmp0 < tmp13
    tmp15 = tmp12 & tmp14
    tmp16 = tl.load(in_ptr0 + (3 * x0 + 12288 * x2), tmp15, eviction_policy
        ='evict_last', other=0.0)
    tmp17 = tl.load(in_ptr0 + (1 + 3 * x0 + 12288 * x2), tmp15,
        eviction_policy='evict_last', other=0.0)
    tmp18 = 0.34413
    tmp19 = tmp17 * tmp18
    tmp20 = tmp16 - tmp19
    tmp21 = tl.load(in_ptr0 + (2 + 3 * x0 + 12288 * x2), tmp15,
        eviction_policy='evict_last', other=0.0)
    tmp22 = 0.71414
    tmp23 = tmp21 * tmp22
    tmp24 = tmp20 - tmp23
    tmp25 = tl.full(tmp24.shape, 0.0, tmp24.dtype)
    tmp26 = tl.where(tmp15, tmp24, tmp25)
    tmp27 = tmp0 >= tmp13
    tl.full([1], 3, tl.int64)
    tmp30 = tl.load(in_ptr0 + (3 * x0 + 12288 * x2), tmp27, eviction_policy
        ='evict_last', other=0.0)
    tmp31 = tl.load(in_ptr0 + (1 + 3 * x0 + 12288 * x2), tmp27,
        eviction_policy='evict_last', other=0.0)
    tmp32 = 1.772
    tmp33 = tmp31 * tmp32
    tmp34 = tmp30 + tmp33
    tmp35 = tl.full(tmp34.shape, 0.0, tmp34.dtype)
    tmp36 = tl.where(tmp27, tmp34, tmp35)
    tmp37 = tl.where(tmp15, tmp26, tmp36)
    tmp38 = tl.where(tmp4, tmp11, tmp37)
    tl.store(out_ptr0 + x3, tmp38, None)


def call(args):
    arg0_1, arg1_1, arg2_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 64, 64), (16384, 4096, 64, 1))
    assert_size_stride(arg1_1, (3, 3, 1, 9), (27, 9, 9, 1))
    assert_size_stride(arg2_1, (3, 3, 9, 1), (27, 9, 1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 64, 64), (12288, 4096, 64, 1),
            torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(49152)](arg0_1, buf0, 49152, XBLOCK=256,
            num_warps=4, num_stages=1)
        del arg0_1
        buf1 = empty_strided_cuda((4, 3, 64, 72), (13824, 1, 216, 3), torch
            .float32)
        triton_poi_fused_reflection_pad2d_1[grid(12, 4608)](buf0, buf1, 12,
            4608, XBLOCK=64, YBLOCK=16, num_warps=4, num_stages=1)
        del buf0
        buf2 = empty_strided_cuda((3, 3, 1, 9), (27, 1, 27, 3), torch.float32)
        triton_poi_fused_convolution_reflection_pad2d_2[grid(9, 9)](arg1_1,
            buf2, 9, 9, XBLOCK=16, YBLOCK=16, num_warps=4, num_stages=1)
        del arg1_1
        buf3 = extern_kernels.convolution(buf1, buf2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 3, 64, 64), (12288, 1, 192, 3))
        buf4 = reinterpret_tensor(buf1, (4, 3, 72, 64), (13824, 1, 192, 3), 0)
        del buf1
        triton_poi_fused_reflection_pad2d_3[grid(55296)](buf3, buf4, 55296,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf5 = reinterpret_tensor(buf2, (3, 3, 9, 1), (27, 1, 3, 3), 0)
        del buf2
        triton_poi_fused_convolution_reflection_pad2d_2[grid(9, 9)](arg2_1,
            buf5, 9, 9, XBLOCK=16, YBLOCK=16, num_warps=4, num_stages=1)
        del arg2_1
        buf6 = extern_kernels.convolution(buf4, buf5, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 3, 64, 64), (12288, 1, 192, 3))
        del buf4
        del buf5
        buf7 = reinterpret_tensor(buf3, (4, 3, 64, 64), (12288, 4096, 64, 1), 0
            )
        del buf3
        triton_poi_fused_cat_4[grid(49152)](buf6, buf7, 49152, XBLOCK=256,
            num_warps=4, num_stages=1)
        del buf6
    return buf7,


class LossyYCbCr(nn.Module):

    def forward(self, rgb: 'torch.Tensor'):
        return torch.cat([0.299 * rgb[:, 0:1] + 0.587 * rgb[:, 1:2] + 0.114 *
            rgb[:, 2:3], -0.16875 * rgb[:, 0:1] - 0.33126 * rgb[:, 1:2] + 
            0.5 * rgb[:, 2:3], 0.5 * rgb[:, 0:1] - 0.41869 * rgb[:, 1:2] - 
            0.08131 * rgb[:, 2:3]], dim=1)


class LossyRGB(nn.Module):

    def forward(self, ycbcr: 'torch.Tensor'):
        return torch.cat([ycbcr[:, 0:1] + 1.402 * ycbcr[:, 2:3], ycbcr[:, 0
            :1] - 0.34413 * ycbcr[:, 1:2] - 0.71414 * ycbcr[:, 2:3], ycbcr[
            :, 0:1] + 1.772 * ycbcr[:, 1:2]], dim=1)


class LosslessYCbCr(nn.Module):

    def forward(self, rgb: 'torch.Tensor'):
        return torch.cat([(rgb[:, 0:1] + 2 * rgb[:, 1:2] + rgb[:, 2:3]) / 4,
            rgb[:, 2:3] - rgb[:, 1:2], rgb[:, 0:1] - rgb[:, 1:2]], dim=1)


class LosslessRGB(nn.Module):

    def forward(self, ycbcr: 'torch.Tensor'):
        return torch.cat([ycbcr[:, 2:3] + ycbcr[:, 0:1] - 0.25 * ycbcr[:, 1
            :2] - 0.25 * ycbcr[:, 2:3], ycbcr[:, 0:1] - 0.25 * ycbcr[:, 1:2
            ] - 0.25 * ycbcr[:, 2:3], ycbcr[:, 1:2] + ycbcr[:, 0:1] - 0.25 *
            ycbcr[:, 1:2] - 0.25 * ycbcr[:, 2:3]], dim=1)


class DWTNew(nn.Module):

    def __init__(self, lossy: 'bool'=True):
        super().__init__()
        if lossy:
            dec_lo = [0.02674875741080976, -0.01686411844287495, -
                0.07822326652898785, 0.2668641184428723, 0.6029490182363579,
                0.2668641184428723, -0.07822326652898785, -
                0.01686411844287495, 0.02674875741080976]
            self.to_ycbcr = LossyYCbCr()
            self.to_rgb = LossyRGB()
            None
        else:
            dec_lo = [-0.125, 0.25, 0.75, 0.25, -0.125]
            self.to_ycbcr = LosslessYCbCr()
            self.to_rgb = LosslessRGB()
            None
        self.dwt_vertical = nn.Conv2d(3, 3, (len(dec_lo), 1), padding=(len(
            dec_lo) // 2, 0), bias=False, padding_mode='reflect')
        self.dwt_horizontal = nn.Conv2d(3, 3, (1, len(dec_lo)), padding=(0,
            len(dec_lo) // 2), bias=False, padding_mode='reflect')
        self.dwt_vertical.weight.requires_grad = False
        self.dwt_horizontal.weight.requires_grad = False
        self.dwt_vertical.weight.fill_(0)
        self.dwt_horizontal.weight.fill_(0)
        for c in range(3):
            for i in range(len(dec_lo)):
                self.dwt_vertical.weight[c, c, i, 0] = dec_lo[i]
                self.dwt_horizontal.weight[c, c, 0, i] = dec_lo[i]

    def forward(self, input_0):
        arg2_1 = self.dwt_vertical.weight
        arg1_1 = self.dwt_horizontal.weight
        arg0_1 = input_0
        output = call([arg0_1, arg1_1, arg2_1])
        return output[0]
