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 typing import Dict
from abc import abstractmethod
from torch import nn
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_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 544
    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 % 17
    y1 = yindex // 17
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 17 * x2 + 153 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 3136
    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 % 49
    y1 = yindex // 49
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 49 * x2 + 441 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 14464
    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 % 113
    y1 = yindex // 113
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 113 * x2 + 1017 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_3(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 61696
    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 % 241
    y1 = yindex // 241
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 241 * x2 + 2169 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_avg_pool2d_4(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x3 = xindex // 16
    x2 = xindex // 256
    x4 = xindex % 256
    tmp0 = tl.load(in_ptr0 + (4 * x0 + 256 * x3), xmask, eviction_policy=
        'evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (64 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (65 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (66 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr0 + (67 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr0 + (128 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr0 + (129 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr0 + (130 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp21 = tl.load(in_ptr0 + (131 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr0 + (192 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr0 + (193 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp27 = tl.load(in_ptr0 + (194 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr0 + (195 + 4 * x0 + 256 * x3), xmask,
        eviction_policy='evict_last')
    tmp2 = tmp1 + tmp0
    tmp4 = tmp3 + tmp2
    tmp6 = tmp5 + tmp4
    tmp8 = tmp7 + tmp6
    tmp10 = tmp9 + tmp8
    tmp12 = tmp11 + tmp10
    tmp14 = tmp13 + tmp12
    tmp16 = tmp15 + tmp14
    tmp18 = tmp17 + tmp16
    tmp20 = tmp19 + tmp18
    tmp22 = tmp21 + tmp20
    tmp24 = tmp23 + tmp22
    tmp26 = tmp25 + tmp24
    tmp28 = tmp27 + tmp26
    tmp30 = tmp29 + tmp28
    tmp31 = 0.0625
    tmp32 = tmp30 * tmp31
    tl.store(out_ptr0 + (x4 + 4352 * x2), tmp32, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_5(in_ptr0, in_ptr1, out_ptr0, ynumel,
    xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 64
    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
    x2 = xindex
    y3 = yindex
    y0 = yindex % 16
    y1 = yindex // 16
    tmp0 = tl.load(in_ptr0 + (x2 + 1024 * y3), xmask & ymask,
        eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + y0, ymask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1, 1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(out_ptr0 + (y0 + 16 * x2 + 16384 * y1), tmp4, xmask & ymask)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_6(in_ptr0, out_ptr0, out_ptr1,
    ynumel, xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    xnumel = 16
    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
    y0 = yindex % 16
    y1 = yindex // 16
    y5 = yindex
    y4 = yindex // 256
    y6 = yindex % 256
    tmp0 = tl.load(in_ptr0 + (x2 + 32 * y0 + 1024 * y1), xmask,
        eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (16 + x2 + 32 * y0 + 1024 * y1), xmask,
        eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (512 + x2 + 32 * y0 + 1024 * y1), xmask,
        eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (528 + x2 + 32 * y0 + 1024 * y1), xmask,
        eviction_policy='evict_last')
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1, 1], 1, tl.int8)
    tmp4 = tl.full([1, 1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1, 1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1, 1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    tmp16 = triton_helpers.maximum(tmp12, tmp11)
    tl.store(out_ptr0 + (x2 + 16 * y5), tmp15, xmask)
    tl.store(out_ptr1 + (y6 + 256 * x2 + 4352 * y4), tmp16, xmask)


@triton.jit
def triton_poi_fused_cat_7(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 68
    xnumel = 256
    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 % 17
    y1 = yindex // 17
    tmp0 = tl.load(in_ptr0 + (x2 + 256 * y3), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 17 * x2 + 4352 * y1), tmp0, xmask & ymask)


@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 % 32
    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, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 32
    x1 = xindex // 32 % 8
    x2 = xindex // 256
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 64 * x1 + 1024 * x2), None)
    tmp1 = tl.load(in_ptr0 + (32 + x0 + 64 * x1 + 1024 * x2), None)
    tmp7 = tl.load(in_ptr0 + (512 + x0 + 64 * x1 + 1024 * x2), None)
    tmp12 = tl.load(in_ptr0 + (544 + x0 + 64 * x1 + 1024 * x2), None)
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1], 1, tl.int8)
    tmp4 = tl.full([1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    triton_helpers.maximum(tmp12, tmp11)
    tl.store(out_ptr0 + x3, tmp15, None)


@triton.jit
def triton_poi_fused_cat_10(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 12544
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 49
    x1 = xindex // 49 % 8
    x2 = xindex // 392
    x3 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 32, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (64 * x1 + 1024 * x2 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tl.load(in_ptr0 + (32 + 64 * x1 + 1024 * x2 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp7 = triton_helpers.maximum(tmp6, tmp5)
    tmp8 = tl.load(in_ptr0 + (512 + 64 * x1 + 1024 * x2 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp9 = triton_helpers.maximum(tmp8, tmp7)
    tmp10 = tl.load(in_ptr0 + (544 + 64 * x1 + 1024 * x2 + x0), tmp4 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp11 = triton_helpers.maximum(tmp10, tmp9)
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp4, tmp11, tmp12)
    tmp14 = tmp0 >= tmp3
    tl.full([1], 49, tl.int64)
    tmp17 = tl.load(in_ptr1 + (34 * x1 + 544 * x2 + (-32 + x0)), tmp14 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp18 = tl.load(in_ptr1 + (17 + 34 * x1 + 544 * x2 + (-32 + x0)), tmp14 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp19 = tmp18 + tmp17
    tmp20 = tl.load(in_ptr1 + (272 + 34 * x1 + 544 * x2 + (-32 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp21 = tmp20 + tmp19
    tmp22 = tl.load(in_ptr1 + (289 + 34 * x1 + 544 * x2 + (-32 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp23 = tmp22 + tmp21
    tmp24 = 0.25
    tmp25 = tmp23 * tmp24
    tmp26 = tl.full(tmp25.shape, 0.0, tmp25.dtype)
    tmp27 = tl.where(tmp14, tmp25, tmp26)
    tmp28 = tl.where(tmp4, tmp13, tmp27)
    tl.store(out_ptr0 + x3, tmp28, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_11(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 % 64
    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_12(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 % 64
    x1 = xindex // 64 % 4
    x2 = xindex // 256
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 128 * x1 + 1024 * x2), None)
    tmp1 = tl.load(in_ptr0 + (64 + x0 + 128 * x1 + 1024 * x2), None)
    tmp7 = tl.load(in_ptr0 + (512 + x0 + 128 * x1 + 1024 * x2), None)
    tmp12 = tl.load(in_ptr0 + (576 + x0 + 128 * x1 + 1024 * x2), None)
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1], 1, tl.int8)
    tmp4 = tl.full([1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    triton_helpers.maximum(tmp12, tmp11)
    tl.store(out_ptr0 + x3, tmp15, None)


@triton.jit
def triton_poi_fused_cat_13(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 7232
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 113
    x1 = xindex // 113 % 4
    x2 = xindex // 452
    x3 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 64, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (128 * x1 + 1024 * x2 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tl.load(in_ptr0 + (64 + 128 * x1 + 1024 * x2 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp7 = triton_helpers.maximum(tmp6, tmp5)
    tmp8 = tl.load(in_ptr0 + (512 + 128 * x1 + 1024 * x2 + x0), tmp4 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp9 = triton_helpers.maximum(tmp8, tmp7)
    tmp10 = tl.load(in_ptr0 + (576 + 128 * x1 + 1024 * x2 + x0), tmp4 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp11 = triton_helpers.maximum(tmp10, tmp9)
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp4, tmp11, tmp12)
    tmp14 = tmp0 >= tmp3
    tl.full([1], 113, tl.int64)
    tmp17 = tl.load(in_ptr1 + (98 * x1 + 784 * x2 + (-64 + x0)), tmp14 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp18 = tl.load(in_ptr1 + (49 + 98 * x1 + 784 * x2 + (-64 + x0)), tmp14 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp19 = tmp18 + tmp17
    tmp20 = tl.load(in_ptr1 + (392 + 98 * x1 + 784 * x2 + (-64 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp21 = tmp20 + tmp19
    tmp22 = tl.load(in_ptr1 + (441 + 98 * x1 + 784 * x2 + (-64 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp23 = tmp22 + tmp21
    tmp24 = 0.25
    tmp25 = tmp23 * tmp24
    tmp26 = tl.full(tmp25.shape, 0.0, tmp25.dtype)
    tmp27 = tl.where(tmp14, tmp25, tmp26)
    tmp28 = tl.where(tmp4, tmp13, tmp27)
    tl.store(out_ptr0 + x3, tmp28, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_14(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_15(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 % 128
    x1 = xindex // 128 % 2
    x2 = xindex // 256
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 256 * x1 + 1024 * x2), None)
    tmp1 = tl.load(in_ptr0 + (128 + x0 + 256 * x1 + 1024 * x2), None)
    tmp7 = tl.load(in_ptr0 + (512 + x0 + 256 * x1 + 1024 * x2), None)
    tmp12 = tl.load(in_ptr0 + (640 + x0 + 256 * x1 + 1024 * x2), None)
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1], 1, tl.int8)
    tmp4 = tl.full([1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    triton_helpers.maximum(tmp12, tmp11)
    tl.store(out_ptr0 + x3, tmp15, None)


@triton.jit
def triton_poi_fused_cat_16(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 3856
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 241
    x1 = xindex // 241 % 2
    x2 = xindex // 482
    x3 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 128, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (256 * x1 + 1024 * x2 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tl.load(in_ptr0 + (128 + 256 * x1 + 1024 * x2 + x0), tmp4 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp7 = triton_helpers.maximum(tmp6, tmp5)
    tmp8 = tl.load(in_ptr0 + (512 + 256 * x1 + 1024 * x2 + x0), tmp4 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp9 = triton_helpers.maximum(tmp8, tmp7)
    tmp10 = tl.load(in_ptr0 + (640 + 256 * x1 + 1024 * x2 + x0), tmp4 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp11 = triton_helpers.maximum(tmp10, tmp9)
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp4, tmp11, tmp12)
    tmp14 = tmp0 >= tmp3
    tl.full([1], 241, tl.int64)
    tmp17 = tl.load(in_ptr1 + (226 * x1 + 904 * x2 + (-128 + x0)), tmp14 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp18 = tl.load(in_ptr1 + (113 + 226 * x1 + 904 * x2 + (-128 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp19 = tmp18 + tmp17
    tmp20 = tl.load(in_ptr1 + (452 + 226 * x1 + 904 * x2 + (-128 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp21 = tmp20 + tmp19
    tmp22 = tl.load(in_ptr1 + (565 + 226 * x1 + 904 * x2 + (-128 + x0)), 
        tmp14 & xmask, eviction_policy='evict_last', other=0.0)
    tmp23 = tmp22 + tmp21
    tmp24 = 0.25
    tmp25 = tmp23 * tmp24
    tmp26 = tl.full(tmp25.shape, 0.0, tmp25.dtype)
    tmp27 = tl.where(tmp14, tmp25, tmp26)
    tmp28 = tl.where(tmp4, tmp13, tmp27)
    tl.store(out_ptr0 + x3, tmp28, xmask)


@triton.jit
def triton_poi_fused_convolution_mean_relu_17(in_ptr0, in_ptr1, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 256
    x1 = xindex // 256
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 1024 * x1), xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (256 + x0 + 1024 * x1), xmask)
    tmp9 = tl.load(in_ptr0 + (512 + x0 + 1024 * x1), xmask)
    tmp13 = tl.load(in_ptr0 + (768 + x0 + 1024 * x1), xmask)
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp6 = tmp5 + tmp1
    tmp7 = triton_helpers.maximum(tmp3, tmp6)
    tmp8 = tmp4 + tmp7
    tmp10 = tmp9 + tmp1
    tmp11 = triton_helpers.maximum(tmp3, tmp10)
    tmp12 = tmp8 + tmp11
    tmp14 = tmp13 + tmp1
    tmp15 = triton_helpers.maximum(tmp3, tmp14)
    tmp16 = tmp12 + tmp15
    tmp17 = 4.0
    tmp18 = tmp16 / tmp17
    tl.store(out_ptr0 + x2, tmp18, xmask)


@triton.jit
def triton_poi_fused_relu_18(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 % 1024
    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_relu_threshold_backward_19(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)
    x2 = xindex
    x0 = xindex % 256
    tmp0 = tl.load(in_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(out_ptr0 + x2, tmp6, 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) = args
    args.clear()
    assert_size_stride(primals_1, (4, 1, 64, 64), (4096, 4096, 64, 1))
    assert_size_stride(primals_2, (16, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_3, (16,), (1,))
    assert_size_stride(primals_4, (32, 17, 3, 3), (153, 9, 3, 1))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (64, 49, 3, 3), (441, 9, 3, 1))
    assert_size_stride(primals_7, (64,), (1,))
    assert_size_stride(primals_8, (128, 113, 3, 3), (1017, 9, 3, 1))
    assert_size_stride(primals_9, (128,), (1,))
    assert_size_stride(primals_10, (256, 241, 3, 3), (2169, 9, 3, 1))
    assert_size_stride(primals_11, (256,), (1,))
    assert_size_stride(primals_12, (1024, 256), (256, 1))
    assert_size_stride(primals_13, (1024,), (1,))
    assert_size_stride(primals_14, (2, 1024), (1024, 1))
    assert_size_stride(primals_15, (2,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((32, 17, 3, 3), (153, 1, 51, 17), torch.
            float32)
        get_raw_stream(0)
        triton_poi_fused_0[grid(544, 9)](primals_4, buf0, 544, 9, XBLOCK=16,
            YBLOCK=64, num_warps=4, num_stages=1)
        del primals_4
        buf1 = empty_strided_cuda((64, 49, 3, 3), (441, 1, 147, 49), torch.
            float32)
        triton_poi_fused_1[grid(3136, 9)](primals_6, buf1, 3136, 9, XBLOCK=
            16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_6
        buf2 = empty_strided_cuda((128, 113, 3, 3), (1017, 1, 339, 113),
            torch.float32)
        triton_poi_fused_2[grid(14464, 9)](primals_8, buf2, 14464, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_8
        buf3 = empty_strided_cuda((256, 241, 3, 3), (2169, 1, 723, 241),
            torch.float32)
        triton_poi_fused_3[grid(61696, 9)](primals_10, buf3, 61696, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_10
        buf9 = empty_strided_cuda((4, 17, 16, 16), (4352, 256, 16, 1),
            torch.float32)
        buf4 = reinterpret_tensor(buf9, (4, 1, 16, 16), (4352, 256, 16, 1),
            4096)
        triton_poi_fused_avg_pool2d_4[grid(1024)](primals_1, buf4, 1024,
            XBLOCK=128, num_warps=4, num_stages=1)
        buf5 = extern_kernels.convolution(primals_1, primals_2, stride=(2, 
            2), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (4, 16, 32, 32), (16384, 1024, 32, 1))
        buf6 = empty_strided_cuda((4, 16, 32, 32), (16384, 1, 512, 16),
            torch.float32)
        triton_poi_fused_convolution_relu_5[grid(64, 1024)](buf5, primals_3,
            buf6, 64, 1024, XBLOCK=32, YBLOCK=32, num_warps=4, num_stages=1)
        del buf5
        del primals_3
        buf7 = empty_strided_cuda((4, 16, 16, 16), (4096, 1, 256, 16),
            torch.int8)
        buf8 = reinterpret_tensor(buf9, (4, 16, 16, 16), (4352, 256, 16, 1), 0)
        triton_poi_fused_max_pool2d_with_indices_6[grid(1024, 16)](buf6,
            buf7, buf8, 1024, 16, XBLOCK=16, YBLOCK=16, num_warps=4,
            num_stages=1)
        buf10 = empty_strided_cuda((4, 17, 16, 16), (4352, 1, 272, 17),
            torch.float32)
        triton_poi_fused_cat_7[grid(68, 256)](buf9, buf10, 68, 256, XBLOCK=
            32, YBLOCK=32, num_warps=4, num_stages=1)
        del buf4
        del buf8
        del buf9
        buf11 = extern_kernels.convolution(buf10, buf0, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 32, 16, 16), (8192, 1, 512, 32))
        buf12 = buf11
        del buf11
        triton_poi_fused_convolution_relu_8[grid(32768)](buf12, primals_5, 
            32768, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_5
        buf13 = empty_strided_cuda((4, 32, 8, 8), (2048, 1, 256, 32), torch
            .int8)
        triton_poi_fused_max_pool2d_with_indices_9[grid(8192)](buf12, buf13,
            8192, XBLOCK=256, num_warps=4, num_stages=1)
        buf14 = empty_strided_cuda((4, 49, 8, 8), (3136, 1, 392, 49), torch
            .float32)
        triton_poi_fused_cat_10[grid(12544)](buf12, buf10, buf14, 12544,
            XBLOCK=128, num_warps=4, num_stages=1)
        buf15 = extern_kernels.convolution(buf14, buf1, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 64, 8, 8), (4096, 1, 512, 64))
        buf16 = buf15
        del buf15
        triton_poi_fused_convolution_relu_11[grid(16384)](buf16, primals_7,
            16384, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_7
        buf17 = empty_strided_cuda((4, 64, 4, 4), (1024, 1, 256, 64), torch
            .int8)
        triton_poi_fused_max_pool2d_with_indices_12[grid(4096)](buf16,
            buf17, 4096, XBLOCK=256, num_warps=4, num_stages=1)
        buf18 = empty_strided_cuda((4, 113, 4, 4), (1808, 1, 452, 113),
            torch.float32)
        triton_poi_fused_cat_13[grid(7232)](buf16, buf14, buf18, 7232,
            XBLOCK=128, num_warps=4, num_stages=1)
        buf19 = extern_kernels.convolution(buf18, buf2, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 128, 4, 4), (2048, 1, 512, 128))
        buf20 = buf19
        del buf19
        triton_poi_fused_convolution_relu_14[grid(8192)](buf20, primals_9, 
            8192, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_9
        buf21 = empty_strided_cuda((4, 128, 2, 2), (512, 1, 256, 128),
            torch.int8)
        triton_poi_fused_max_pool2d_with_indices_15[grid(2048)](buf20,
            buf21, 2048, XBLOCK=256, num_warps=4, num_stages=1)
        buf22 = empty_strided_cuda((4, 241, 2, 2), (964, 1, 482, 241),
            torch.float32)
        triton_poi_fused_cat_16[grid(3856)](buf20, buf18, buf22, 3856,
            XBLOCK=128, num_warps=4, num_stages=1)
        buf23 = extern_kernels.convolution(buf22, buf3, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf23, (4, 256, 2, 2), (1024, 1, 512, 256))
        buf24 = empty_strided_cuda((4, 256, 1, 1), (256, 1, 1024, 1024),
            torch.float32)
        triton_poi_fused_convolution_mean_relu_17[grid(1024)](buf23,
            primals_11, buf24, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        buf25 = empty_strided_cuda((4, 1024), (1024, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf24, (4, 256), (256, 1), 0),
            reinterpret_tensor(primals_12, (256, 1024), (1, 256), 0), out=buf25
            )
        buf26 = buf25
        del buf25
        triton_poi_fused_relu_18[grid(4096)](buf26, primals_13, 4096,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_13
        buf27 = empty_strided_cuda((4, 2), (2, 1), torch.float32)
        extern_kernels.addmm(primals_15, buf26, reinterpret_tensor(
            primals_14, (1024, 2), (1, 1024), 0), alpha=1, beta=1, out=buf27)
        del primals_15
        buf28 = empty_strided_cuda((4, 256, 2, 2), (1024, 1, 512, 256),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_19[grid(4096)](
            buf23, primals_11, buf28, 4096, XBLOCK=256, num_warps=4,
            num_stages=1)
        del buf23
        del primals_11
    return (buf27, primals_1, primals_2, buf0, buf1, buf2, buf3, buf6, buf7,
        buf10, buf12, buf13, buf14, buf16, buf17, buf18, buf20, buf21,
        buf22, reinterpret_tensor(buf24, (4, 256), (256, 1), 0), buf26,
        primals_14, primals_12, buf28)


class DetectionModel(nn.Module):
    """
    Base class describing any single object detection model
    """

    def __init__(self, params: '{}'):
        self._params = params
        assert params is not None
        super(DetectionModel, self).__init__()

    def save(self, folder: 'Path', name):
        with open(folder / (name + '.json'), 'w') as f:
            json.dump(self._params, f, indent=2)
        torch.save(self.state_dict(), folder / (name + '.pt'))

    def load(self, folder: 'Path', name):
        with open(folder / (name + '.json'), 'r') as f:
            params = json.load(f)
        model = self.load_structure(params)
        model.load_state_dict(torch.load(folder / (name + '.pt')))
        return model

    @abstractmethod
    def load_structure(self, config_dictionary: 'Dict'):
        """
        Loads model structure from a json description.
        The structure json file describes non-trainable hyperparameters such as number of layers, filters etc.
        :param config_dictionary: dictionary with all the parameters necessary to load the model
        :return: None
        """
        return NotImplemented


class ResNetModelNew(DetectionModel):
    default_params = {'model_type': 'resnet', 'model_version': 1.0,
        'input_shape': (1, 240, 320), 'initial_filters': 16, 'num_outputs': 2}

    def __init__(self, params=None):
        self._model_version = 1.0
        if params is None:
            params = ResNetModelNew.default_params
        if 'version' not in params:
            params['version'] = self._model_version
        if 'model_type' not in params:
            params['model_type'] = 'resnet'
        super(ResNetModelNew, self).__init__(params)
        self.load_structure(params)

    def load_structure(self, hyperparameters):
        C_in, _H_in, _W_in = hyperparameters['input_shape']
        init_f = hyperparameters['initial_filters']
        num_outputs = hyperparameters['num_outputs']
        self.conv1 = nn.Conv2d(C_in, init_f, kernel_size=3, stride=2, padding=1
            )
        self.conv2 = nn.Conv2d(init_f + C_in, 2 * init_f, kernel_size=3,
            stride=1, padding=1)
        self.conv3 = nn.Conv2d(3 * init_f + C_in, 4 * init_f, kernel_size=3,
            padding=1)
        self.conv4 = nn.Conv2d(7 * init_f + C_in, 8 * init_f, kernel_size=3,
            padding=1)
        self.conv5 = nn.Conv2d(15 * init_f + C_in, 16 * init_f, kernel_size
            =3, padding=1)
        self.fc1 = nn.Linear(16 * init_f, 64 * init_f)
        self.fc_out = nn.Linear(64 * init_f, num_outputs)
        return self

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


Measured latency_ms: 0.413466