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 import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.onnx
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_reflection_pad2d_0(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 62208
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 72
    x1 = xindex // 72 % 72
    x2 = xindex // 5184
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-4 +
        x0)) + -64 * tl_math.abs(-63 + tl_math.abs(-4 + x1)) + 4096 * x2),
        xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_red_fused__native_batch_norm_legit_convolution_1(in_out_ptr0,
    in_out_ptr1, in_ptr0, out_ptr0, xnumel, rnumel, XBLOCK: tl.constexpr,
    RBLOCK: tl.constexpr):
    xnumel = 128
    rnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x3 = xindex
    x0 = xindex % 32
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp4_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp4_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp4_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r2 = rindex
        tmp0 = tl.load(in_out_ptr0 + (r2 + 4096 * x3), rmask & xmask,
            eviction_policy='evict_first', other=0.0)
        tmp2 = tmp0 + tmp1
        tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
        tmp4_mean_next, tmp4_m2_next, tmp4_weight_next = (triton_helpers.
            welford_reduce(tmp3, tmp4_mean, tmp4_m2, tmp4_weight, roffset == 0)
            )
        tmp4_mean = tl.where(rmask & xmask, tmp4_mean_next, tmp4_mean)
        tmp4_m2 = tl.where(rmask & xmask, tmp4_m2_next, tmp4_m2)
        tmp4_weight = tl.where(rmask & xmask, tmp4_weight_next, tmp4_weight)
        tl.store(in_out_ptr0 + (r2 + 4096 * x3), tmp2, rmask & xmask)
    tmp4_tmp, tmp5_tmp, tmp6_tmp = triton_helpers.welford(tmp4_mean,
        tmp4_m2, tmp4_weight, 1)
    tmp4 = tmp4_tmp[:, None]
    tmp5 = tmp5_tmp[:, None]
    tmp6_tmp[:, None]
    tl.store(out_ptr0 + x3, tmp4, xmask)
    tmp7 = 4096.0
    tmp8 = tmp5 / tmp7
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = libdevice.rsqrt(tmp10)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp11, xmask)


@triton.jit
def triton_poi_fused_repeat_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0 % 32, xmask)
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_reflection_pad2d_relu_3(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 557568
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 66
    x1 = xindex // 66 % 66
    x2 = xindex // 4356
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-1 +
        x0)) + -64 * tl_math.abs(-63 + tl_math.abs(-1 + x1)) + 4096 * x2),
        xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x2, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + x2, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + x2, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = tmp2 * tmp3
    tmp6 = tmp4 * tmp5
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 0, tl.int32)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tl.store(out_ptr0 + x3, tmp10, xmask)


@triton.jit
def triton_per_fused__native_batch_norm_legit_convolution_relu_repeat_4(
    in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1,
    out_ptr2, out_ptr3, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    x0 = xindex
    r3 = rindex
    x1 = xindex % 64
    tmp0 = tl.load(in_ptr0 + x0 % 64, None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x0 % 64, None, eviction_policy='evict_last')
    tmp2 = tl.load(in_out_ptr0 + (r3 + 1024 * x0), None)
    tmp3 = tl.load(in_ptr2 + x1, None, eviction_policy='evict_last')
    tmp4 = tmp2 + tmp3
    tmp5 = tl.broadcast_to(tmp4, [RBLOCK])
    tmp7 = tl.broadcast_to(tmp5, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.full([1], 1024, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp5 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [RBLOCK])
    tmp17 = triton_helpers.promote_to_tensor(tl.sum(tmp15, 0))
    tmp18 = 1024.0
    tmp19 = tmp17 / tmp18
    tmp20 = 1e-05
    tmp21 = tmp19 + tmp20
    tmp22 = libdevice.rsqrt(tmp21)
    tmp23 = tmp4 - tmp12
    tmp24 = tmp23 * tmp22
    tmp25 = tmp24 * tmp0
    tmp26 = tmp25 + tmp1
    tmp27 = tl.full([1], 0, tl.int32)
    tmp28 = triton_helpers.maximum(tmp27, tmp26)
    tl.store(out_ptr0 + x0, tmp0, None)
    tl.store(out_ptr1 + x0, tmp1, None)
    tl.store(in_out_ptr0 + (r3 + 1024 * x0), tmp4, None)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x0, tmp22, None)
    tl.store(out_ptr3 + (r3 + 1024 * x0), tmp28, None)
    tl.store(out_ptr2 + x0, tmp12, None)


@triton.jit
def triton_poi_fused_reflection_pad2d_5(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 295936
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 34
    x1 = xindex // 34 % 34
    x2 = xindex // 1156
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (1023 + -1 * tl_math.abs(-31 + tl_math.abs(-1 +
        x0)) + -32 * tl_math.abs(-31 + tl_math.abs(-1 + x1)) + 1024 * x2),
        xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_per_fused__native_batch_norm_legit_convolution_6(in_out_ptr0,
    in_out_ptr1, in_ptr0, out_ptr0, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_out_ptr0 + (r2 + 1024 * x3), None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp5 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp7 = triton_helpers.promote_to_tensor(tl.sum(tmp5, 0))
    tmp8 = tl.full([1], 1024, tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 / tmp9
    tmp11 = tmp3 - tmp10
    tmp12 = tmp11 * tmp11
    tmp13 = tl.broadcast_to(tmp12, [RBLOCK])
    tmp15 = triton_helpers.promote_to_tensor(tl.sum(tmp13, 0))
    tmp16 = 1024.0
    tmp17 = tmp15 / tmp16
    tmp18 = 1e-05
    tmp19 = tmp17 + tmp18
    tmp20 = libdevice.rsqrt(tmp19)
    tl.store(in_out_ptr0 + (r2 + 1024 * x3), tmp2, None)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp20, None)
    tl.store(out_ptr0 + x3, tmp10, None)


@triton.jit
def triton_poi_fused_repeat_7(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0 % 64, xmask)
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_reflection_pad2d_relu_8(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 295936
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 34
    x1 = xindex // 34 % 34
    x2 = xindex // 1156
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (1023 + -1 * tl_math.abs(-31 + tl_math.abs(-1 +
        x0)) + -32 * tl_math.abs(-31 + tl_math.abs(-1 + x1)) + 1024 * x2),
        xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x2, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + x2, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + x2, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = tmp2 * tmp3
    tmp6 = tmp4 * tmp5
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 0, tl.int32)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tl.store(out_ptr0 + x3, tmp10, xmask)


@triton.jit
def triton_per_fused__native_batch_norm_legit_add_convolution_repeat_9(
    in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1,
    out_ptr3, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    x0 = xindex
    r3 = rindex
    x1 = xindex % 64
    tmp0 = tl.load(in_ptr0 + x0 % 64, None, eviction_policy='evict_last')
    tmp1 = tl.load(in_out_ptr0 + (r3 + 1024 * x0), None)
    tmp2 = tl.load(in_ptr1 + x1, None, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr2 + x1, None, eviction_policy='evict_last')
    tmp27 = tl.load(in_out_ptr1 + (r3 + 1024 * x0), None)
    tmp3 = tmp1 + tmp2
    tmp4 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp6 = tl.broadcast_to(tmp4, [RBLOCK])
    tmp8 = triton_helpers.promote_to_tensor(tl.sum(tmp6, 0))
    tmp9 = tl.full([1], 1024, tl.int32)
    tmp10 = tmp9.to(tl.float32)
    tmp11 = tmp8 / tmp10
    tmp12 = tmp4 - tmp11
    tmp13 = tmp12 * tmp12
    tmp14 = tl.broadcast_to(tmp13, [RBLOCK])
    tmp16 = triton_helpers.promote_to_tensor(tl.sum(tmp14, 0))
    tmp17 = tmp3 - tmp11
    tmp18 = 1024.0
    tmp19 = tmp16 / tmp18
    tmp20 = 1e-05
    tmp21 = tmp19 + tmp20
    tmp22 = libdevice.rsqrt(tmp21)
    tmp23 = tmp17 * tmp22
    tmp24 = tmp23 * tmp0
    tmp26 = tmp24 + tmp25
    tmp28 = tmp26 + tmp27
    tl.store(out_ptr0 + x0, tmp0, None)
    tl.store(in_out_ptr0 + (r3 + 1024 * x0), tmp3, None)
    tl.store(in_out_ptr1 + (r3 + 1024 * x0), tmp28, None)
    tl.store(out_ptr3 + x0, tmp22, None)
    tl.store(out_ptr1 + x0, tmp11, None)


@triton.jit
def triton_per_fused__native_batch_norm_legit_convolution_10(in_out_ptr0,
    in_ptr0, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_out_ptr0 + (r2 + 1024 * x3), None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp5 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp7 = triton_helpers.promote_to_tensor(tl.sum(tmp5, 0))
    tmp8 = tl.full([1], 1024, tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 / tmp9
    tmp11 = tmp3 - tmp10
    tmp12 = tmp11 * tmp11
    tmp13 = tl.broadcast_to(tmp12, [RBLOCK])
    tmp15 = triton_helpers.promote_to_tensor(tl.sum(tmp13, 0))
    tmp16 = 1024.0
    tmp17 = tmp15 / tmp16
    tmp18 = 1e-05
    tmp19 = tmp17 + tmp18
    tmp20 = libdevice.rsqrt(tmp19)
    tl.store(in_out_ptr0 + (r2 + 1024 * x3), tmp2, None)
    tl.store(out_ptr2 + x3, tmp20, None)
    tl.store(out_ptr0 + x3, tmp10, None)
    tl.store(out_ptr1 + x3, tmp15, None)


@triton.jit
def triton_poi_fused_arange_11(out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused__to_copy_add_arange_mul_12(out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_add_reflection_pad2d_13(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 1115136
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 66 % 66
    x0 = xindex % 66
    x4 = xindex // 4356
    x2 = xindex // 4356 % 64
    x7 = xindex
    tmp0 = tl.load(in_ptr0 + (63 + -1 * tl_math.abs(-63 + tl_math.abs(-1 +
        x1))), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (63 + -1 * tl_math.abs(-63 + tl_math.abs(-1 +
        x0))), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr3 + x4, xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr4 + x4, xmask, eviction_policy='evict_last')
    tmp21 = tl.load(in_ptr5 + x2, xmask, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 32, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tmp8 = tl.where(tmp7, tmp6, tmp5)
    tmp9 = tl.load(in_ptr1 + (tmp8 + 32 * tmp4 + 1024 * x4), xmask,
        eviction_policy='evict_last')
    tmp11 = tmp9 - tmp10
    tmp13 = 1024.0
    tmp14 = tmp12 / tmp13
    tmp15 = 1e-05
    tmp16 = tmp14 + tmp15
    tmp17 = libdevice.rsqrt(tmp16)
    tmp18 = tmp11 * tmp17
    tmp20 = tmp18 * tmp19
    tmp22 = tmp20 + tmp21
    tmp23 = tl.load(in_ptr6 + (tmp8 + 32 * tmp4 + 1024 * x4), xmask,
        eviction_policy='evict_last')
    tmp24 = tmp22 + tmp23
    tl.store(out_ptr0 + x7, tmp24, xmask)


@triton.jit
def triton_poi_fused_reflection_pad2d_relu_14(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, 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 % 72
    x1 = xindex // 72 % 72
    x2 = xindex // 5184
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-4 +
        x0)) + -64 * tl_math.abs(-63 + tl_math.abs(-4 + x1)) + 4096 * x2),
        None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x2, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, None, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + x2, None, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + x2, None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = tmp2 * tmp3
    tmp6 = tmp4 * tmp5
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 0, tl.int32)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tl.store(out_ptr0 + x3, tmp10, None)


@triton.jit
def triton_poi_fused_convolution_15(in_out_ptr0, in_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 3
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21, primals_22,
        primals_23, primals_24, primals_25, primals_26, primals_27,
        primals_28, primals_29, primals_30, primals_31) = args
    args.clear()
    assert_size_stride(primals_1, (4, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_2, (32, 3, 9, 9), (243, 81, 9, 1))
    assert_size_stride(primals_3, (32,), (1,))
    assert_size_stride(primals_4, (32,), (1,))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (64, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_7, (64,), (1,))
    assert_size_stride(primals_8, (64,), (1,))
    assert_size_stride(primals_9, (64,), (1,))
    assert_size_stride(primals_10, (64, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_11, (64,), (1,))
    assert_size_stride(primals_12, (64,), (1,))
    assert_size_stride(primals_13, (64,), (1,))
    assert_size_stride(primals_14, (64, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_15, (64,), (1,))
    assert_size_stride(primals_16, (64,), (1,))
    assert_size_stride(primals_17, (64,), (1,))
    assert_size_stride(primals_18, (64, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_19, (64,), (1,))
    assert_size_stride(primals_20, (64,), (1,))
    assert_size_stride(primals_21, (64,), (1,))
    assert_size_stride(primals_22, (64, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_23, (64,), (1,))
    assert_size_stride(primals_24, (64,), (1,))
    assert_size_stride(primals_25, (64,), (1,))
    assert_size_stride(primals_26, (32, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_27, (32,), (1,))
    assert_size_stride(primals_28, (32,), (1,))
    assert_size_stride(primals_29, (32,), (1,))
    assert_size_stride(primals_30, (3, 32, 9, 9), (2592, 81, 9, 1))
    assert_size_stride(primals_31, (3,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 72, 72), (15552, 5184, 72, 1),
            torch.float32)
        get_raw_stream(0)
        triton_poi_fused_reflection_pad2d_0[grid(62208)](primals_1, buf0, 
            62208, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_1
        buf1 = extern_kernels.convolution(buf0, primals_2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf2 = buf1
        del buf1
        buf5 = empty_strided_cuda((1, 128, 1, 1), (128, 1, 1, 1), torch.float32
            )
        buf6 = empty_strided_cuda((1, 128, 1, 1), (128, 1, 128, 128), torch
            .float32)
        buf8 = reinterpret_tensor(buf6, (1, 128, 1, 1), (128, 1, 1, 1), 0)
        del buf6
        triton_red_fused__native_batch_norm_legit_convolution_1[grid(128)](buf2
            , buf8, primals_3, buf5, 128, 4096, XBLOCK=1, RBLOCK=2048,
            num_warps=16, num_stages=1)
        del primals_3
        buf3 = empty_strided_cuda((128,), (1,), torch.float32)
        triton_poi_fused_repeat_2[grid(128)](primals_4, buf3, 128, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_4
        buf4 = empty_strided_cuda((128,), (1,), torch.float32)
        triton_poi_fused_repeat_2[grid(128)](primals_5, buf4, 128, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_5
        buf9 = empty_strided_cuda((4, 32, 66, 66), (139392, 4356, 66, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_relu_3[grid(557568)](buf2, buf5,
            buf8, buf3, buf4, buf9, 557568, XBLOCK=512, num_warps=8,
            num_stages=1)
        buf10 = extern_kernels.convolution(buf9, primals_6, stride=(2, 2),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf12 = empty_strided_cuda((256,), (1,), torch.float32)
        buf13 = empty_strided_cuda((256,), (1,), torch.float32)
        buf11 = buf10
        del buf10
        buf14 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 1, 1), torch.
            float32)
        buf15 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        buf17 = reinterpret_tensor(buf15, (1, 256, 1, 1), (256, 1, 1, 1), 0)
        del buf15
        buf18 = empty_strided_cuda((4, 64, 32, 32), (65536, 1024, 32, 1),
            torch.float32)
        triton_per_fused__native_batch_norm_legit_convolution_relu_repeat_4[
            grid(256)](buf11, buf17, primals_8, primals_9, primals_7, buf12,
            buf13, buf14, buf18, 256, 1024, num_warps=8, num_stages=1)
        del primals_7
        del primals_8
        del primals_9
        buf19 = empty_strided_cuda((4, 64, 34, 34), (73984, 1156, 34, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_5[grid(295936)](buf18, buf19, 
            295936, XBLOCK=1024, num_warps=4, num_stages=1)
        buf20 = extern_kernels.convolution(buf19, primals_10, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf20, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf21 = buf20
        del buf20
        buf24 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 1, 1), torch.
            float32)
        buf25 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        buf27 = reinterpret_tensor(buf25, (1, 256, 1, 1), (256, 1, 1, 1), 0)
        del buf25
        triton_per_fused__native_batch_norm_legit_convolution_6[grid(256)](
            buf21, buf27, primals_11, buf24, 256, 1024, num_warps=8,
            num_stages=1)
        del primals_11
        buf22 = empty_strided_cuda((256,), (1,), torch.float32)
        triton_poi_fused_repeat_7[grid(256)](primals_12, buf22, 256, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_12
        buf23 = empty_strided_cuda((256,), (1,), torch.float32)
        triton_poi_fused_repeat_7[grid(256)](primals_13, buf23, 256, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_13
        buf28 = empty_strided_cuda((4, 64, 34, 34), (73984, 1156, 34, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_relu_8[grid(295936)](buf21, buf24,
            buf27, buf22, buf23, buf28, 295936, XBLOCK=1024, num_warps=4,
            num_stages=1)
        buf29 = extern_kernels.convolution(buf28, primals_14, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf29, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf31 = empty_strided_cuda((256,), (1,), torch.float32)
        buf30 = buf29
        del buf29
        buf32 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        buf36 = buf18
        del buf18
        buf35 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        triton_per_fused__native_batch_norm_legit_add_convolution_repeat_9[grid
            (256)](buf30, buf36, primals_16, primals_15, primals_17, buf31,
            buf32, buf35, 256, 1024, num_warps=8, num_stages=1)
        del primals_15
        del primals_16
        del primals_17
        buf37 = empty_strided_cuda((4, 64, 34, 34), (73984, 1156, 34, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_5[grid(295936)](buf36, buf37, 
            295936, XBLOCK=1024, num_warps=4, num_stages=1)
        buf38 = extern_kernels.convolution(buf37, primals_18, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf38, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf39 = buf38
        del buf38
        buf42 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 1, 1), torch.
            float32)
        buf43 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        buf45 = reinterpret_tensor(buf43, (1, 256, 1, 1), (256, 1, 1, 1), 0)
        del buf43
        triton_per_fused__native_batch_norm_legit_convolution_6[grid(256)](
            buf39, buf45, primals_19, buf42, 256, 1024, num_warps=8,
            num_stages=1)
        del primals_19
        buf40 = empty_strided_cuda((256,), (1,), torch.float32)
        triton_poi_fused_repeat_7[grid(256)](primals_20, buf40, 256, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_20
        buf41 = empty_strided_cuda((256,), (1,), torch.float32)
        triton_poi_fused_repeat_7[grid(256)](primals_21, buf41, 256, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_21
        buf46 = empty_strided_cuda((4, 64, 34, 34), (73984, 1156, 34, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_relu_8[grid(295936)](buf39, buf42,
            buf45, buf40, buf41, buf46, 295936, XBLOCK=1024, num_warps=4,
            num_stages=1)
        buf47 = extern_kernels.convolution(buf46, primals_22, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf47, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf48 = buf47
        del buf47
        buf50 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        buf51 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        buf53 = empty_strided_cuda((1, 256, 1, 1), (256, 1, 256, 256),
            torch.float32)
        triton_per_fused__native_batch_norm_legit_convolution_10[grid(256)](
            buf48, primals_23, buf50, buf51, buf53, 256, 1024, num_warps=8,
            num_stages=1)
        del primals_23
        buf49 = empty_strided_cuda((256,), (1,), torch.float32)
        triton_poi_fused_repeat_7[grid(256)](primals_24, buf49, 256, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_24
        buf54 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused_arange_11[grid(64)](buf54, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf55 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused__to_copy_add_arange_mul_12[grid(64)](buf55, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf56 = empty_strided_cuda((4, 64, 66, 66), (278784, 4356, 66, 1),
            torch.float32)
        triton_poi_fused__unsafe_index_add_reflection_pad2d_13[grid(1115136)](
            buf55, buf48, buf50, buf51, buf49, primals_25, buf36, buf56, 
            1115136, XBLOCK=512, num_warps=8, num_stages=1)
        del buf36
        del buf51
        del primals_25
        buf57 = extern_kernels.convolution(buf56, primals_26, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf57, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf58 = buf57
        del buf57
        buf61 = empty_strided_cuda((1, 128, 1, 1), (128, 1, 1, 1), torch.
            float32)
        buf62 = empty_strided_cuda((1, 128, 1, 1), (128, 1, 128, 128),
            torch.float32)
        buf64 = reinterpret_tensor(buf62, (1, 128, 1, 1), (128, 1, 1, 1), 0)
        del buf62
        triton_red_fused__native_batch_norm_legit_convolution_1[grid(128)](
            buf58, buf64, primals_27, buf61, 128, 4096, XBLOCK=1, RBLOCK=
            2048, num_warps=16, num_stages=1)
        del primals_27
        buf59 = empty_strided_cuda((128,), (1,), torch.float32)
        triton_poi_fused_repeat_2[grid(128)](primals_28, buf59, 128, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_28
        buf60 = empty_strided_cuda((128,), (1,), torch.float32)
        triton_poi_fused_repeat_2[grid(128)](primals_29, buf60, 128, XBLOCK
            =128, num_warps=4, num_stages=1)
        del primals_29
        buf65 = empty_strided_cuda((4, 32, 72, 72), (165888, 5184, 72, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_relu_14[grid(663552)](buf58,
            buf61, buf64, buf59, buf60, buf65, 663552, XBLOCK=512,
            num_warps=8, num_stages=1)
        buf66 = extern_kernels.convolution(buf65, primals_30, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf66, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf67 = buf66
        del buf66
        triton_poi_fused_convolution_15[grid(49152)](buf67, primals_31, 
            49152, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_31
    return (buf67, primals_2, primals_6, primals_10, primals_14, primals_18,
        primals_22, primals_26, primals_30, buf0, buf2, buf3, buf4, buf5,
        buf8, buf9, buf11, buf12, buf13, buf14, buf17, buf19, buf21, buf22,
        buf23, buf24, buf27, buf28, buf30, buf31, reinterpret_tensor(buf35,
        (256,), (1,), 0), buf37, buf39, buf40, buf41, buf42, buf45, buf46,
        buf48, buf49, reinterpret_tensor(buf53, (256,), (1,), 0), buf54,
        buf55, buf56, buf58, buf59, buf60, buf61, buf64, buf65,
        reinterpret_tensor(buf50, (1, 256, 1, 1), (256, 1, 1, 1), 0),
        reinterpret_tensor(buf32, (1, 256, 1, 1), (256, 1, 1, 1), 0))


class ConvLayer(torch.nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride):
        super(ConvLayer, self).__init__()
        reflection_padding = kernel_size // 2
        self.reflection_pad = torch.nn.ReflectionPad2d(reflection_padding)
        self.conv2d = torch.nn.Conv2d(in_channels, out_channels,
            kernel_size, stride)

    def forward(self, x):
        out = self.reflection_pad(x)
        out = self.conv2d(out)
        return out


class ResidualBlock(torch.nn.Module):
    """ResidualBlock
    introduced in: https://arxiv.org/abs/1512.03385
    recommended architecture: http://torch.ch/blog/2016/02/04/resnets.html
    """

    def __init__(self, channels):
        super(ResidualBlock, self).__init__()
        self.conv1 = ConvLayer(channels, channels, kernel_size=3, stride=1)
        self.in1 = torch.nn.InstanceNorm2d(channels, affine=True)
        self.conv2 = ConvLayer(channels, channels, kernel_size=3, stride=1)
        self.in2 = torch.nn.InstanceNorm2d(channels, affine=True)
        self.relu = torch.nn.ReLU()

    def forward(self, x):
        residual = x
        out = self.relu(self.in1(self.conv1(x)))
        out = self.in2(self.conv2(out))
        out = out + residual
        return out


class UpsampleConvLayer(torch.nn.Module):
    """UpsampleConvLayer
    Upsamples the input and then does a convolution. This method gives better results
    compared to ConvTranspose2d.
    ref: http://distill.pub/2016/deconv-checkerboard/
    """

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        upsample=None):
        super(UpsampleConvLayer, self).__init__()
        self.upsample = upsample
        reflection_padding = kernel_size // 2
        self.reflection_pad = torch.nn.ReflectionPad2d(reflection_padding)
        self.conv2d = torch.nn.Conv2d(in_channels, out_channels,
            kernel_size, stride)

    def forward(self, x):
        x_in = x
        if self.upsample:
            x_in = torch.nn.functional.interpolate(x_in, mode='nearest',
                scale_factor=self.upsample)
        out = self.reflection_pad(x_in)
        out = self.conv2d(out)
        return out


class SmallTransformerNetNew(torch.nn.Module):

    def __init__(self):
        super(SmallTransformerNetNew, self).__init__()
        self.conv1 = ConvLayer(3, 32, kernel_size=9, stride=1)
        self.in1 = torch.nn.InstanceNorm2d(32, affine=True)
        self.conv2 = ConvLayer(32, 64, kernel_size=3, stride=2)
        self.in2 = torch.nn.InstanceNorm2d(64, affine=True)
        self.res6 = ResidualBlock(64)
        self.res7 = ResidualBlock(64)
        self.deconv2 = UpsampleConvLayer(64, 32, kernel_size=3, stride=1,
            upsample=2)
        self.in5 = torch.nn.InstanceNorm2d(32, affine=True)
        self.deconv3 = ConvLayer(32, 3, kernel_size=9, stride=1)
        self.relu = torch.nn.ReLU()

    def forward(self, input_0):
        primals_2 = self.conv1.conv2d.weight
        primals_3 = self.conv1.conv2d.bias
        primals_4 = self.in1.weight
        primals_5 = self.in1.bias
        primals_6 = self.conv2.conv2d.weight
        primals_7 = self.conv2.conv2d.bias
        primals_8 = self.in2.weight
        primals_9 = self.in2.bias
        primals_10 = self.res6.conv1.conv2d.weight
        primals_11 = self.res6.conv1.conv2d.bias
        primals_12 = self.res6.in1.weight
        primals_13 = self.res6.in1.bias
        primals_14 = self.res6.conv2.conv2d.weight
        primals_15 = self.res6.conv2.conv2d.bias
        primals_16 = self.res6.in2.weight
        primals_17 = self.res6.in2.bias
        primals_18 = self.res7.conv1.conv2d.weight
        primals_19 = self.res7.conv1.conv2d.bias
        primals_20 = self.res7.in1.weight
        primals_21 = self.res7.in1.bias
        primals_22 = self.res7.conv2.conv2d.weight
        primals_23 = self.res7.conv2.conv2d.bias
        primals_24 = self.res7.in2.weight
        primals_25 = self.res7.in2.bias
        primals_26 = self.deconv2.conv2d.weight
        primals_27 = self.deconv2.conv2d.bias
        primals_28 = self.in5.weight
        primals_29 = self.in5.bias
        primals_30 = self.deconv3.conv2d.weight
        primals_31 = self.deconv3.conv2d.bias
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21, primals_22, primals_23, primals_24,
            primals_25, primals_26, primals_27, primals_28, primals_29,
            primals_30, primals_31])
        return output[0]


Measured latency_ms: 0.535771