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
import torch.nn as nn
from collections import OrderedDict
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 192
    xnumel = 225
    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 + 225 * y3), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 675 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 12
    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]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    x2 = xindex
    y3 = yindex
    y0 = yindex % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 65536 * y3), ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 196608 * y1), tmp0, ymask)


@triton.jit
def triton_poi_fused_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 25
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 64
    y1 = yindex // 64
    tmp0 = tl.load(in_ptr0 + (x2 + 25 * y3), xmask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 64 * x2 + 1600 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_3(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 128
    y1 = yindex // 128
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 128 * x2 + 1152 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_4(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)
        ) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    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'
        )
    tl.store(out_ptr0 + (y0 + 256 * x2 + 2304 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_5(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 49
    yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)
        ) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    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 + 49 * y3), xmask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 256 * x2 + 12544 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_6(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 1679616
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_7(in_ptr0, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 64
    x1 = xindex // 64 % 40
    x2 = xindex // 2560 % 40
    x3 = xindex // 102400
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 128 * x1 + 10368 * x2 + 419904 * x3), None)
    tmp1 = tl.load(in_ptr0 + (64 + x0 + 128 * x1 + 10368 * x2 + 419904 * x3
        ), None)
    tmp3 = tl.load(in_ptr0 + (128 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp5 = tl.load(in_ptr0 + (5184 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp7 = tl.load(in_ptr0 + (5248 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp9 = tl.load(in_ptr0 + (5312 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp11 = tl.load(in_ptr0 + (10368 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp13 = tl.load(in_ptr0 + (10432 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp15 = tl.load(in_ptr0 + (10496 + x0 + 128 * x1 + 10368 * x2 + 419904 *
        x3), None)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tmp8 = triton_helpers.maximum(tmp7, tmp6)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tmp12 = triton_helpers.maximum(tmp11, tmp10)
    tmp14 = triton_helpers.maximum(tmp13, tmp12)
    tmp16 = triton_helpers.maximum(tmp15, tmp14)
    tmp17 = tmp1 > tmp0
    tmp18 = tl.full([1], 1, tl.int8)
    tmp19 = tl.full([1], 0, tl.int8)
    tmp20 = tl.where(tmp17, tmp18, tmp19)
    tmp21 = tmp3 > tmp2
    tmp22 = tl.full([1], 2, tl.int8)
    tmp23 = tl.where(tmp21, tmp22, tmp20)
    tmp24 = tmp5 > tmp4
    tmp25 = tl.full([1], 3, tl.int8)
    tmp26 = tl.where(tmp24, tmp25, tmp23)
    tmp27 = tmp7 > tmp6
    tmp28 = tl.full([1], 4, tl.int8)
    tmp29 = tl.where(tmp27, tmp28, tmp26)
    tmp30 = tmp9 > tmp8
    tmp31 = tl.full([1], 5, tl.int8)
    tmp32 = tl.where(tmp30, tmp31, tmp29)
    tmp33 = tmp11 > tmp10
    tmp34 = tl.full([1], 6, tl.int8)
    tmp35 = tl.where(tmp33, tmp34, tmp32)
    tmp36 = tmp13 > tmp12
    tmp37 = tl.full([1], 7, tl.int8)
    tmp38 = tl.where(tmp36, tmp37, tmp35)
    tmp39 = tmp15 > tmp14
    tmp40 = tl.full([1], 8, tl.int8)
    tmp41 = tl.where(tmp39, tmp40, tmp38)
    tl.store(out_ptr0 + x4, tmp16, None)
    tl.store(out_ptr1 + x4, tmp41, None)


@triton.jit
def triton_poi_fused_convolution_relu_8(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)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_9(in_ptr0, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 147968
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 128
    x1 = xindex // 128 % 17
    x2 = xindex // 2176 % 17
    x3 = xindex // 36992
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 256 * x1 + 9216 * x2 + 165888 * x3), xmask)
    tmp1 = tl.load(in_ptr0 + (128 + x0 + 256 * x1 + 9216 * x2 + 165888 * x3
        ), xmask)
    tmp3 = tl.load(in_ptr0 + (256 + x0 + 256 * x1 + 9216 * x2 + 165888 * x3
        ), xmask)
    tmp5 = tl.load(in_ptr0 + (4608 + x0 + 256 * x1 + 9216 * x2 + 165888 *
        x3), xmask)
    tmp7 = tl.load(in_ptr0 + (4736 + x0 + 256 * x1 + 9216 * x2 + 165888 *
        x3), xmask)
    tmp9 = tl.load(in_ptr0 + (4864 + x0 + 256 * x1 + 9216 * x2 + 165888 *
        x3), xmask)
    tmp11 = tl.load(in_ptr0 + (9216 + x0 + 256 * x1 + 9216 * x2 + 165888 *
        x3), xmask)
    tmp13 = tl.load(in_ptr0 + (9344 + x0 + 256 * x1 + 9216 * x2 + 165888 *
        x3), xmask)
    tmp15 = tl.load(in_ptr0 + (9472 + x0 + 256 * x1 + 9216 * x2 + 165888 *
        x3), xmask)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tmp8 = triton_helpers.maximum(tmp7, tmp6)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tmp12 = triton_helpers.maximum(tmp11, tmp10)
    tmp14 = triton_helpers.maximum(tmp13, tmp12)
    tmp16 = triton_helpers.maximum(tmp15, tmp14)
    tmp17 = tmp1 > tmp0
    tmp18 = tl.full([1], 1, tl.int8)
    tmp19 = tl.full([1], 0, tl.int8)
    tmp20 = tl.where(tmp17, tmp18, tmp19)
    tmp21 = tmp3 > tmp2
    tmp22 = tl.full([1], 2, tl.int8)
    tmp23 = tl.where(tmp21, tmp22, tmp20)
    tmp24 = tmp5 > tmp4
    tmp25 = tl.full([1], 3, tl.int8)
    tmp26 = tl.where(tmp24, tmp25, tmp23)
    tmp27 = tmp7 > tmp6
    tmp28 = tl.full([1], 4, tl.int8)
    tmp29 = tl.where(tmp27, tmp28, tmp26)
    tmp30 = tmp9 > tmp8
    tmp31 = tl.full([1], 5, tl.int8)
    tmp32 = tl.where(tmp30, tmp31, tmp29)
    tmp33 = tmp11 > tmp10
    tmp34 = tl.full([1], 6, tl.int8)
    tmp35 = tl.where(tmp33, tmp34, tmp32)
    tmp36 = tmp13 > tmp12
    tmp37 = tl.full([1], 7, tl.int8)
    tmp38 = tl.where(tmp36, tmp37, tmp35)
    tmp39 = tmp15 > tmp14
    tmp40 = tl.full([1], 8, tl.int8)
    tmp41 = tl.where(tmp39, tmp40, tmp38)
    tl.store(out_ptr0 + x4, tmp16, xmask)
    tl.store(out_ptr1 + x4, tmp41, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_10(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 295936
    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, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_11(in_ptr0, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 256
    x1 = xindex // 256 % 8
    x2 = xindex // 2048 % 8
    x3 = xindex // 16384
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 512 * x1 + 8704 * x2 + 73984 * x3), None)
    tmp1 = tl.load(in_ptr0 + (256 + x0 + 512 * x1 + 8704 * x2 + 73984 * x3),
        None)
    tmp3 = tl.load(in_ptr0 + (512 + x0 + 512 * x1 + 8704 * x2 + 73984 * x3),
        None)
    tmp5 = tl.load(in_ptr0 + (4352 + x0 + 512 * x1 + 8704 * x2 + 73984 * x3
        ), None)
    tmp7 = tl.load(in_ptr0 + (4608 + x0 + 512 * x1 + 8704 * x2 + 73984 * x3
        ), None)
    tmp9 = tl.load(in_ptr0 + (4864 + x0 + 512 * x1 + 8704 * x2 + 73984 * x3
        ), None)
    tmp11 = tl.load(in_ptr0 + (8704 + x0 + 512 * x1 + 8704 * x2 + 73984 *
        x3), None)
    tmp13 = tl.load(in_ptr0 + (8960 + x0 + 512 * x1 + 8704 * x2 + 73984 *
        x3), None)
    tmp15 = tl.load(in_ptr0 + (9216 + x0 + 512 * x1 + 8704 * x2 + 73984 *
        x3), None)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tmp8 = triton_helpers.maximum(tmp7, tmp6)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tmp12 = triton_helpers.maximum(tmp11, tmp10)
    tmp14 = triton_helpers.maximum(tmp13, tmp12)
    tmp16 = triton_helpers.maximum(tmp15, tmp14)
    tmp17 = tmp1 > tmp0
    tmp18 = tl.full([1], 1, tl.int8)
    tmp19 = tl.full([1], 0, tl.int8)
    tmp20 = tl.where(tmp17, tmp18, tmp19)
    tmp21 = tmp3 > tmp2
    tmp22 = tl.full([1], 2, tl.int8)
    tmp23 = tl.where(tmp21, tmp22, tmp20)
    tmp24 = tmp5 > tmp4
    tmp25 = tl.full([1], 3, tl.int8)
    tmp26 = tl.where(tmp24, tmp25, tmp23)
    tmp27 = tmp7 > tmp6
    tmp28 = tl.full([1], 4, tl.int8)
    tmp29 = tl.where(tmp27, tmp28, tmp26)
    tmp30 = tmp9 > tmp8
    tmp31 = tl.full([1], 5, tl.int8)
    tmp32 = tl.where(tmp30, tmp31, tmp29)
    tmp33 = tmp11 > tmp10
    tmp34 = tl.full([1], 6, tl.int8)
    tmp35 = tl.where(tmp33, tmp34, tmp32)
    tmp36 = tmp13 > tmp12
    tmp37 = tl.full([1], 7, tl.int8)
    tmp38 = tl.where(tmp36, tmp37, tmp35)
    tmp39 = tmp15 > tmp14
    tmp40 = tl.full([1], 8, tl.int8)
    tmp41 = tl.where(tmp39, tmp40, tmp38)
    tl.store(out_ptr0 + x4, tmp16, None)
    tl.store(out_ptr1 + x4, tmp41, None)


@triton.jit
def triton_poi_fused_convolution_relu_12(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)
    x2 = xindex
    x0 = xindex % 512
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_convolution_13(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)
    x2 = xindex
    x0 = xindex % 256
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x2, tmp2, None)


@triton.jit
def triton_red_fused_mul_sum_14(in_ptr0, out_ptr0, xnumel, rnumel, XBLOCK:
    tl.constexpr, RBLOCK: tl.constexpr):
    xnumel = 32
    rnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x0 = xindex % 8
    x1 = xindex // 8
    _tmp3 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
    x3 = xindex
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r2 = rindex
        tmp0 = tl.load(in_ptr0 + (32 * x0 + 256 * (r2 % 4) + 1024 * x1 + r2 //
            4), rmask & xmask, eviction_policy='evict_last', other=0.0)
        tmp1 = tmp0 * tmp0
        tmp2 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
        tmp4 = _tmp3 + tmp2
        _tmp3 = tl.where(rmask & xmask, tmp4, _tmp3)
    tmp3 = tl.sum(_tmp3, 1)[:, None]
    tl.store(out_ptr0 + x3, tmp3, xmask)


@triton.jit
def triton_per_fused_mul_sqrt_sum_15(in_out_ptr0, in_ptr0, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    RBLOCK: tl.constexpr = 8
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 8 * x0), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp5 = libdevice.sqrt(tmp4)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp5, xmask)


@triton.jit
def triton_poi_fused_add_div_16(in_ptr0, in_ptr1, 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 % 4
    x1 = xindex // 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (256 * (x1 % 4) + 1024 * x0 + x1 // 4), None,
        eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp2 = 1e-10
    tmp3 = tmp1 + tmp2
    tmp4 = tmp0 / tmp3
    tl.store(out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_add_div_permute_17(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 1024
    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
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4 * x1), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (x1 + 1024 * y0), tmp0, xmask & ymask)


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) = args
    args.clear()
    assert_size_stride(primals_1, (64, 3, 15, 15), (675, 225, 15, 1))
    assert_size_stride(primals_2, (64,), (1,))
    assert_size_stride(primals_3, (4, 3, 256, 256), (196608, 65536, 256, 1))
    assert_size_stride(primals_4, (128, 64, 5, 5), (1600, 25, 5, 1))
    assert_size_stride(primals_5, (128,), (1,))
    assert_size_stride(primals_6, (256, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_7, (256,), (1,))
    assert_size_stride(primals_8, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_9, (256,), (1,))
    assert_size_stride(primals_10, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_11, (256,), (1,))
    assert_size_stride(primals_12, (512, 256, 7, 7), (12544, 49, 7, 1))
    assert_size_stride(primals_13, (512,), (1,))
    assert_size_stride(primals_14, (256, 512, 1, 1), (512, 1, 1, 1))
    assert_size_stride(primals_15, (256,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 3, 15, 15), (675, 1, 45, 3), torch.
            float32)
        get_raw_stream(0)
        triton_poi_fused_0[grid(192, 225)](primals_1, buf0, 192, 225,
            XBLOCK=32, YBLOCK=32, num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((4, 3, 256, 256), (196608, 1, 768, 3),
            torch.float32)
        triton_poi_fused_1[grid(12, 65536)](primals_3, buf1, 12, 65536,
            XBLOCK=64, YBLOCK=16, num_warps=4, num_stages=1)
        del primals_3
        buf2 = empty_strided_cuda((128, 64, 5, 5), (1600, 1, 320, 64),
            torch.float32)
        triton_poi_fused_2[grid(8192, 25)](primals_4, buf2, 8192, 25,
            XBLOCK=32, YBLOCK=32, num_warps=4, num_stages=1)
        del primals_4
        buf3 = empty_strided_cuda((256, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_3[grid(32768, 9)](primals_6, buf3, 32768, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_6
        buf4 = empty_strided_cuda((256, 256, 3, 3), (2304, 1, 768, 256),
            torch.float32)
        triton_poi_fused_4[grid(65536, 9)](primals_8, buf4, 65536, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_8
        buf5 = empty_strided_cuda((256, 256, 3, 3), (2304, 1, 768, 256),
            torch.float32)
        triton_poi_fused_4[grid(65536, 9)](primals_10, buf5, 65536, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_10
        buf6 = empty_strided_cuda((512, 256, 7, 7), (12544, 1, 1792, 256),
            torch.float32)
        triton_poi_fused_5[grid(131072, 49)](primals_12, buf6, 131072, 49,
            XBLOCK=32, YBLOCK=32, num_warps=4, num_stages=1)
        del primals_12
        buf7 = extern_kernels.convolution(buf1, buf0, stride=(3, 3),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 64, 81, 81), (419904, 1, 5184, 64))
        buf8 = buf7
        del buf7
        triton_poi_fused_convolution_relu_6[grid(1679616)](buf8, primals_2,
            1679616, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_2
        buf9 = empty_strided_cuda((4, 64, 40, 40), (102400, 1, 2560, 64),
            torch.float32)
        buf10 = empty_strided_cuda((4, 64, 40, 40), (102400, 1, 2560, 64),
            torch.int8)
        triton_poi_fused_max_pool2d_with_indices_7[grid(409600)](buf8, buf9,
            buf10, 409600, XBLOCK=512, num_warps=8, num_stages=1)
        buf11 = extern_kernels.convolution(buf9, buf2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 128, 36, 36), (165888, 1, 4608, 128))
        buf12 = buf11
        del buf11
        triton_poi_fused_convolution_relu_8[grid(663552)](buf12, primals_5,
            663552, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_5
        buf13 = empty_strided_cuda((4, 128, 17, 17), (36992, 1, 2176, 128),
            torch.float32)
        buf14 = empty_strided_cuda((4, 128, 17, 17), (36992, 1, 2176, 128),
            torch.int8)
        triton_poi_fused_max_pool2d_with_indices_9[grid(147968)](buf12,
            buf13, buf14, 147968, XBLOCK=512, num_warps=8, num_stages=1)
        buf15 = extern_kernels.convolution(buf13, buf3, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 256, 17, 17), (73984, 1, 4352, 256))
        buf16 = buf15
        del buf15
        triton_poi_fused_convolution_relu_10[grid(295936)](buf16, primals_7,
            295936, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_7
        buf17 = extern_kernels.convolution(buf16, buf4, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf17, (4, 256, 17, 17), (73984, 1, 4352, 256))
        buf18 = buf17
        del buf17
        triton_poi_fused_convolution_relu_10[grid(295936)](buf18, primals_9,
            295936, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_9
        buf19 = extern_kernels.convolution(buf18, buf5, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 256, 17, 17), (73984, 1, 4352, 256))
        buf20 = buf19
        del buf19
        triton_poi_fused_convolution_relu_10[grid(295936)](buf20,
            primals_11, 295936, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_11
        buf21 = empty_strided_cuda((4, 256, 8, 8), (16384, 1, 2048, 256),
            torch.float32)
        buf22 = empty_strided_cuda((4, 256, 8, 8), (16384, 1, 2048, 256),
            torch.int8)
        triton_poi_fused_max_pool2d_with_indices_11[grid(65536)](buf20,
            buf21, buf22, 65536, XBLOCK=256, num_warps=4, num_stages=1)
        buf23 = extern_kernels.convolution(buf21, buf6, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf23, (4, 512, 2, 2), (2048, 1, 1024, 512))
        buf24 = buf23
        del buf23
        triton_poi_fused_convolution_relu_12[grid(8192)](buf24, primals_13,
            8192, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_13
        buf25 = extern_kernels.convolution(buf24, primals_14, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf25, (4, 256, 2, 2), (1024, 1, 512, 256))
        buf26 = buf25
        del buf25
        triton_poi_fused_convolution_13[grid(4096)](buf26, primals_15, 4096,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_15
        buf27 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        triton_red_fused_mul_sum_14[grid(32)](buf26, buf27, 32, 128, XBLOCK
            =32, RBLOCK=16, num_warps=4, num_stages=1)
        buf28 = empty_strided_cuda((4,), (1,), torch.float32)
        buf29 = buf28
        del buf28
        triton_per_fused_mul_sqrt_sum_15[grid(4)](buf29, buf27, 4, 8,
            XBLOCK=1, num_warps=2, num_stages=1)
        del buf27
        buf30 = empty_strided_cuda((1024, 4), (4, 1), torch.float32)
        triton_poi_fused_add_div_16[grid(4096)](buf26, buf29, buf30, 4096,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf31 = empty_strided_cuda((4, 1024), (1024, 1), torch.float32)
        triton_poi_fused_add_div_permute_17[grid(4, 1024)](buf30, buf31, 4,
            1024, XBLOCK=256, YBLOCK=4, num_warps=4, num_stages=1)
        del buf30
    return (buf31, buf0, buf1, buf2, buf3, buf4, buf5, buf6, primals_14,
        buf8, buf9, buf10, buf12, buf13, buf14, buf16, buf18, buf20, buf21,
        buf22, buf24, buf26, buf29)


class Flatten(nn.Module):

    def __init__(self):
        super(Flatten, self).__init__()

    def forward(self, x):
        x = x.view(x.size(0), -1)
        return x


class L2Normalization(nn.Module):

    def __init__(self):
        super(L2Normalization, self).__init__()

    def forward(self, x):
        div = torch.sqrt(torch.sum(x * x, 1))
        x = (x.T / (div + 1e-10)).T
        return x


class SaNNew(nn.Module):

    def __init__(self):
        super(SaNNew, self).__init__()
        self.features = self._make_layers()

    def _make_layers(self):
        """
        Refer to https://github.com/yuchuochuo1023/Deep_SBIR_tf/blob/master/triplet_sbir_train.py
        torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')
        torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)
        """
        return nn.Sequential(OrderedDict([('conv1', nn.Conv2d(3, 64, 15, 3,
            0)), ('relu1', nn.ReLU()), ('maxpool1', nn.MaxPool2d(3, 2, 0)),
            ('conv2', nn.Conv2d(64, 128, 5, 1, 0)), ('relu2', nn.ReLU()), (
            'maxpool2', nn.MaxPool2d(3, 2, 0)), ('conv3', nn.Conv2d(128, 
            256, 3, 1, 1)), ('relu3', nn.ReLU()), ('conv4', nn.Conv2d(256, 
            256, 3, 1, 1)), ('relu4', nn.ReLU()), ('conv5', nn.Conv2d(256, 
            256, 3, 1, 1)), ('relu5', nn.ReLU()), ('maxpool5', nn.MaxPool2d
            (3, 2, 0)), ('conv6', nn.Conv2d(256, 512, 7, 1, 0)), ('relu6',
            nn.ReLU()), ('conv7', nn.Conv2d(512, 256, 1, 1, 0)), ('flatten',
            Flatten()), ('l2norm', L2Normalization())]))

    def forward(self, input_0):
        primals_1 = self.features.conv1.weight
        primals_2 = self.features.conv1.bias
        primals_4 = self.features.conv2.weight
        primals_5 = self.features.conv2.bias
        primals_6 = self.features.conv3.weight
        primals_7 = self.features.conv3.bias
        primals_8 = self.features.conv4.weight
        primals_9 = self.features.conv4.bias
        primals_10 = self.features.conv5.weight
        primals_11 = self.features.conv5.bias
        primals_12 = self.features.conv6.weight
        primals_13 = self.features.conv6.bias
        primals_14 = self.features.conv7.weight
        primals_15 = self.features.conv7.bias
        primals_3 = 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])
        return output[0]


Measured latency_ms: 0.027377