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 Tuple
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_convolution_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 16
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_relu_1(in_ptr0, out_ptr0,
    out_ptr1, out_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 2 % 2
    x0 = xindex % 2
    x4 = xindex // 2
    x3 = xindex
    tmp0 = -1 + 2 * x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tmp2 & tmp4
    tmp6 = -1 + 2 * x0
    tmp7 = tmp6 >= tmp1
    tmp8 = tmp6 < tmp3
    tmp9 = tmp7 & tmp8
    tmp10 = tmp5 & tmp9
    tmp11 = tl.load(in_ptr0 + (-5 + 2 * x0 + 8 * x4), tmp10 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp12 = 2 * x0
    tmp13 = tmp12 >= tmp1
    tmp14 = tmp12 < tmp3
    tmp15 = tmp13 & tmp14
    tmp16 = tmp5 & tmp15
    tmp17 = tl.load(in_ptr0 + (-4 + 2 * x0 + 8 * x4), tmp16 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp18 = triton_helpers.maximum(tmp17, tmp11)
    tmp19 = 1 + 2 * x0
    tmp20 = tmp19 >= tmp1
    tmp21 = tmp19 < tmp3
    tmp22 = tmp20 & tmp21
    tmp23 = tmp5 & tmp22
    tmp24 = tl.load(in_ptr0 + (-3 + 2 * x0 + 8 * x4), tmp23 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp25 = triton_helpers.maximum(tmp24, tmp18)
    tmp26 = 2 * x1
    tmp27 = tmp26 >= tmp1
    tmp28 = tmp26 < tmp3
    tmp29 = tmp27 & tmp28
    tmp30 = tmp29 & tmp9
    tmp31 = tl.load(in_ptr0 + (-1 + 2 * x0 + 8 * x4), tmp30 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp32 = triton_helpers.maximum(tmp31, tmp25)
    tmp33 = tmp29 & tmp15
    tmp34 = tl.load(in_ptr0 + (2 * x0 + 8 * x4), tmp33 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp35 = triton_helpers.maximum(tmp34, tmp32)
    tmp36 = tmp29 & tmp22
    tmp37 = tl.load(in_ptr0 + (1 + 2 * x0 + 8 * x4), tmp36 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp38 = triton_helpers.maximum(tmp37, tmp35)
    tmp39 = 1 + 2 * x1
    tmp40 = tmp39 >= tmp1
    tmp41 = tmp39 < tmp3
    tmp42 = tmp40 & tmp41
    tmp43 = tmp42 & tmp9
    tmp44 = tl.load(in_ptr0 + (3 + 2 * x0 + 8 * x4), tmp43 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp45 = triton_helpers.maximum(tmp44, tmp38)
    tmp46 = tmp42 & tmp15
    tmp47 = tl.load(in_ptr0 + (4 + 2 * x0 + 8 * x4), tmp46 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp48 = triton_helpers.maximum(tmp47, tmp45)
    tmp49 = tmp42 & tmp22
    tmp50 = tl.load(in_ptr0 + (5 + 2 * x0 + 8 * x4), tmp49 & xmask,
        eviction_policy='evict_last', other=float('-inf'))
    tmp51 = triton_helpers.maximum(tmp50, tmp48)
    tmp52 = tmp17 > tmp11
    tmp53 = tl.full([1], 1, tl.int8)
    tmp54 = tl.full([1], 0, tl.int8)
    tmp55 = tl.where(tmp52, tmp53, tmp54)
    tmp56 = tmp24 > tmp18
    tmp57 = tl.full([1], 2, tl.int8)
    tmp58 = tl.where(tmp56, tmp57, tmp55)
    tmp59 = tmp31 > tmp25
    tmp60 = tl.full([1], 3, tl.int8)
    tmp61 = tl.where(tmp59, tmp60, tmp58)
    tmp62 = tmp34 > tmp32
    tmp63 = tl.full([1], 4, tl.int8)
    tmp64 = tl.where(tmp62, tmp63, tmp61)
    tmp65 = tmp37 > tmp35
    tmp66 = tl.full([1], 5, tl.int8)
    tmp67 = tl.where(tmp65, tmp66, tmp64)
    tmp68 = tmp44 > tmp38
    tmp69 = tl.full([1], 6, tl.int8)
    tmp70 = tl.where(tmp68, tmp69, tmp67)
    tmp71 = tmp47 > tmp45
    tmp72 = tl.full([1], 7, tl.int8)
    tmp73 = tl.where(tmp71, tmp72, tmp70)
    tmp74 = tmp50 > tmp48
    tmp75 = tl.full([1], 8, tl.int8)
    tmp76 = tl.where(tmp74, tmp75, tmp73)
    tmp77 = tl.full([1], 0, tl.int32)
    tmp78 = triton_helpers.maximum(tmp77, tmp51)
    tl.store(out_ptr0 + x3, tmp51, xmask)
    tl.store(out_ptr1 + x3, tmp76, xmask)
    tl.store(out_ptr2 + x3, tmp78, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_2(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 16
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, 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 + x3, tmp4, xmask)


@triton.jit
def triton_poi_fused_add_convolution_relu_3(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x3, xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tl.store(out_ptr0 + x3, tmp6, xmask)


@triton.jit
def triton_poi_fused_add_convolution_4(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 16
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr1 + x3, xmask)
    tmp4 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr3 + x3, xmask)
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp2 + tmp7
    tl.store(in_out_ptr0 + x3, tmp8, xmask)


@triton.jit
def triton_poi_fused_convolution_5(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 32
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_relu_6(in_ptr0, out_ptr0,
    out_ptr1, out_ptr2, 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.full([1], -1, tl.int64)
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 2, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tmp2 & tmp4
    tmp6 = tmp5 & tmp5
    tmp7 = tl.load(in_ptr0 + (-3 + 4 * x0), tmp6 & xmask, eviction_policy=
        'evict_last', other=float('-inf'))
    tmp8 = tmp1 >= tmp1
    tmp9 = tmp1 < tmp3
    tmp10 = tmp8 & tmp9
    tmp11 = tmp5 & tmp10
    tmp12 = tl.load(in_ptr0 + (-2 + 4 * x0), tmp11 & xmask, eviction_policy
        ='evict_last', other=float('-inf'))
    tmp13 = triton_helpers.maximum(tmp12, tmp7)
    tmp14 = tl.full([1], 1, tl.int64)
    tmp15 = tmp14 >= tmp1
    tmp16 = tmp14 < tmp3
    tmp17 = tmp15 & tmp16
    tmp18 = tmp5 & tmp17
    tmp19 = tl.load(in_ptr0 + (-1 + 4 * x0), tmp18 & xmask, eviction_policy
        ='evict_last', other=float('-inf'))
    tmp20 = triton_helpers.maximum(tmp19, tmp13)
    tmp21 = tmp10 & tmp5
    tmp22 = tl.load(in_ptr0 + (-1 + 4 * x0), tmp21 & xmask, eviction_policy
        ='evict_last', other=float('-inf'))
    tmp23 = triton_helpers.maximum(tmp22, tmp20)
    tmp24 = tmp10 & tmp10
    tmp25 = tl.load(in_ptr0 + 4 * x0, tmp24 & xmask, eviction_policy=
        'evict_last', other=float('-inf'))
    tmp26 = triton_helpers.maximum(tmp25, tmp23)
    tmp27 = tmp10 & tmp17
    tmp28 = tl.load(in_ptr0 + (1 + 4 * x0), tmp27 & xmask, eviction_policy=
        'evict_last', other=float('-inf'))
    tmp29 = triton_helpers.maximum(tmp28, tmp26)
    tmp30 = tmp17 & tmp5
    tmp31 = tl.load(in_ptr0 + (1 + 4 * x0), tmp30 & xmask, eviction_policy=
        'evict_last', other=float('-inf'))
    tmp32 = triton_helpers.maximum(tmp31, tmp29)
    tmp33 = tmp17 & tmp10
    tmp34 = tl.load(in_ptr0 + (2 + 4 * x0), tmp33 & xmask, eviction_policy=
        'evict_last', other=float('-inf'))
    tmp35 = triton_helpers.maximum(tmp34, tmp32)
    tmp36 = tmp17 & tmp17
    tmp37 = tl.load(in_ptr0 + (3 + 4 * x0), tmp36 & xmask, eviction_policy=
        'evict_last', other=float('-inf'))
    tmp38 = triton_helpers.maximum(tmp37, tmp35)
    tmp39 = tmp12 > tmp7
    tmp40 = tl.full([1], 1, tl.int8)
    tmp41 = tl.full([1], 0, tl.int8)
    tmp42 = tl.where(tmp39, tmp40, tmp41)
    tmp43 = tmp19 > tmp13
    tmp44 = tl.full([1], 2, tl.int8)
    tmp45 = tl.where(tmp43, tmp44, tmp42)
    tmp46 = tmp22 > tmp20
    tmp47 = tl.full([1], 3, tl.int8)
    tmp48 = tl.where(tmp46, tmp47, tmp45)
    tmp49 = tmp25 > tmp23
    tmp50 = tl.full([1], 4, tl.int8)
    tmp51 = tl.where(tmp49, tmp50, tmp48)
    tmp52 = tmp28 > tmp26
    tmp53 = tl.full([1], 5, tl.int8)
    tmp54 = tl.where(tmp52, tmp53, tmp51)
    tmp55 = tmp31 > tmp29
    tmp56 = tl.full([1], 6, tl.int8)
    tmp57 = tl.where(tmp55, tmp56, tmp54)
    tmp58 = tmp34 > tmp32
    tmp59 = tl.full([1], 7, tl.int8)
    tmp60 = tl.where(tmp58, tmp59, tmp57)
    tmp61 = tmp37 > tmp35
    tmp62 = tl.full([1], 8, tl.int8)
    tmp63 = tl.where(tmp61, tmp62, tmp60)
    tmp64 = tl.full([1], 0, tl.int32)
    tmp65 = triton_helpers.maximum(tmp64, tmp38)
    tl.store(out_ptr0 + x0, tmp38, xmask)
    tl.store(out_ptr1 + x0, tmp63, xmask)
    tl.store(out_ptr2 + x0, tmp65, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_7(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 32
    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_add_convolution_relu_8(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 32
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tl.store(out_ptr0 + x2, tmp6, xmask)


@triton.jit
def triton_poi_fused_add_convolution_9(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, xnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 32
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask)
    tmp4 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_out_ptr0 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp2 + tmp7
    tl.store(in_out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused_convolution_max_pool2d_with_indices_relu_10(in_out_ptr0,
    in_ptr0, out_ptr0, out_ptr1, out_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 32
    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], -1, tl.int64)
    tmp4 = tl.full([1], 0, tl.int64)
    tmp5 = tmp3 >= tmp4
    tmp6 = tl.full([1], 1, tl.int64)
    tmp7 = tmp3 < tmp6
    tmp8 = tmp5 & tmp7
    tmp8 & tmp8
    tmp10 = tmp4 >= tmp4
    tmp11 = tmp4 < tmp6
    tmp12 = tmp10 & tmp11
    tmp8 & tmp12
    tmp14 = triton_helpers.maximum(tmp2, tmp2)
    tmp15 = tmp6 >= tmp4
    tmp16 = tmp6 < tmp6
    tmp17 = tmp15 & tmp16
    tmp8 & tmp17
    tmp19 = triton_helpers.maximum(tmp2, tmp14)
    tmp12 & tmp8
    tmp21 = triton_helpers.maximum(tmp2, tmp19)
    tmp12 & tmp12
    tmp23 = triton_helpers.maximum(tmp2, tmp21)
    tmp12 & tmp17
    tmp25 = triton_helpers.maximum(tmp2, tmp23)
    tmp17 & tmp8
    tmp27 = triton_helpers.maximum(tmp2, tmp25)
    tmp17 & tmp12
    tmp29 = triton_helpers.maximum(tmp2, tmp27)
    tmp17 & tmp17
    tmp31 = triton_helpers.maximum(tmp2, tmp29)
    tmp32 = tmp2 > tmp2
    tmp33 = tl.full([1], 1, tl.int8)
    tmp34 = tl.full([1], 0, tl.int8)
    tmp35 = tl.where(tmp32, tmp33, tmp34)
    tmp36 = tmp2 > tmp14
    tmp37 = tl.full([1], 2, tl.int8)
    tmp38 = tl.where(tmp36, tmp37, tmp35)
    tmp39 = tmp2 > tmp19
    tmp40 = tl.full([1], 3, tl.int8)
    tmp41 = tl.where(tmp39, tmp40, tmp38)
    tmp42 = tmp2 > tmp21
    tmp43 = tl.full([1], 4, tl.int8)
    tmp44 = tl.where(tmp42, tmp43, tmp41)
    tmp45 = tmp2 > tmp23
    tmp46 = tl.full([1], 5, tl.int8)
    tmp47 = tl.where(tmp45, tmp46, tmp44)
    tmp48 = tmp2 > tmp25
    tmp49 = tl.full([1], 6, tl.int8)
    tmp50 = tl.where(tmp48, tmp49, tmp47)
    tmp51 = tmp2 > tmp27
    tmp52 = tl.full([1], 7, tl.int8)
    tmp53 = tl.where(tmp51, tmp52, tmp50)
    tmp54 = tmp2 > tmp29
    tmp55 = tl.full([1], 8, tl.int8)
    tmp56 = tl.where(tmp54, tmp55, tmp53)
    tmp57 = tl.full([1], 0, tl.int32)
    tmp58 = triton_helpers.maximum(tmp57, tmp31)
    tl.store(in_out_ptr0 + x2, tmp2, xmask)
    tl.store(out_ptr0 + x2, tmp31, xmask)
    tl.store(out_ptr1 + x2, tmp56, xmask)
    tl.store(out_ptr2 + x2, tmp58, xmask)


@triton.jit
def triton_poi_fused_add_convolution_relu_threshold_backward_11(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 32
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask)
    tmp4 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_out_ptr0 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp2 + tmp7
    tmp9 = tl.full([1], 0, tl.int32)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tmp11 = 0.0
    tmp12 = tmp10 <= tmp11
    tl.store(in_out_ptr0 + x2, tmp10, xmask)
    tl.store(out_ptr0 + x2, tmp12, xmask)


@triton.jit
def triton_poi_fused_relu_threshold_backward_12(in_out_ptr0, 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
    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)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + x2, tmp4, xmask)
    tl.store(out_ptr0 + x2, tmp6, xmask)


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, primals_32, primals_33
        ) = args
    args.clear()
    assert_size_stride(primals_1, (16, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_2, (16,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_5, (16,), (1,))
    assert_size_stride(primals_6, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_7, (16,), (1,))
    assert_size_stride(primals_8, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_9, (16,), (1,))
    assert_size_stride(primals_10, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_11, (16,), (1,))
    assert_size_stride(primals_12, (32, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_13, (32,), (1,))
    assert_size_stride(primals_14, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_15, (32,), (1,))
    assert_size_stride(primals_16, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_17, (32,), (1,))
    assert_size_stride(primals_18, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_19, (32,), (1,))
    assert_size_stride(primals_20, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_21, (32,), (1,))
    assert_size_stride(primals_22, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_23, (32,), (1,))
    assert_size_stride(primals_24, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_25, (32,), (1,))
    assert_size_stride(primals_26, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_27, (32,), (1,))
    assert_size_stride(primals_28, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_29, (32,), (1,))
    assert_size_stride(primals_30, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_31, (32,), (1,))
    assert_size_stride(primals_32, (256, 32), (32, 1))
    assert_size_stride(primals_33, (256,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 16, 4, 4), (256, 16, 4, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_0[grid(1024)](buf1, primals_2, 1024,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_2
        buf2 = empty_strided_cuda((4, 16, 2, 2), (64, 4, 2, 1), torch.float32)
        buf3 = empty_strided_cuda((4, 16, 2, 2), (64, 4, 2, 1), torch.int8)
        buf4 = empty_strided_cuda((4, 16, 2, 2), (64, 4, 2, 1), torch.float32)
        triton_poi_fused_max_pool2d_with_indices_relu_1[grid(256)](buf1,
            buf2, buf3, buf4, 256, XBLOCK=128, num_warps=4, num_stages=1)
        buf5 = extern_kernels.convolution(buf4, primals_4, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (4, 16, 2, 2), (64, 4, 2, 1))
        buf6 = buf5
        del buf5
        triton_poi_fused_convolution_relu_2[grid(256)](buf6, primals_5, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_5
        buf7 = extern_kernels.convolution(buf6, primals_6, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 16, 2, 2), (64, 4, 2, 1))
        buf8 = empty_strided_cuda((4, 16, 2, 2), (64, 4, 2, 1), torch.float32)
        triton_poi_fused_add_convolution_relu_3[grid(256)](buf7, primals_7,
            buf2, buf8, 256, XBLOCK=256, num_warps=4, num_stages=1)
        buf9 = extern_kernels.convolution(buf8, primals_8, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf9, (4, 16, 2, 2), (64, 4, 2, 1))
        buf10 = buf9
        del buf9
        triton_poi_fused_convolution_relu_2[grid(256)](buf10, primals_9, 
            256, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_9
        buf11 = extern_kernels.convolution(buf10, primals_10, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 16, 2, 2), (64, 4, 2, 1))
        buf12 = buf11
        del buf11
        triton_poi_fused_add_convolution_4[grid(256)](buf12, primals_11,
            buf7, primals_7, buf2, 256, XBLOCK=256, num_warps=4, num_stages=1)
        del buf2
        del buf7
        del primals_11
        del primals_7
        buf13 = extern_kernels.convolution(buf12, primals_12, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (4, 32, 2, 2), (128, 4, 2, 1))
        buf14 = buf13
        del buf13
        triton_poi_fused_convolution_5[grid(512)](buf14, primals_13, 512,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_13
        buf15 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        buf16 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 1, 1), torch.int8)
        buf17 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 1, 1), torch.float32)
        triton_poi_fused_max_pool2d_with_indices_relu_6[grid(128)](buf14,
            buf15, buf16, buf17, 128, XBLOCK=128, num_warps=4, num_stages=1)
        buf18 = extern_kernels.convolution(buf17, primals_14, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf18, (4, 32, 1, 1), (32, 1, 1, 1))
        buf19 = buf18
        del buf18
        triton_poi_fused_convolution_relu_7[grid(128)](buf19, primals_15, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_15
        buf20 = extern_kernels.convolution(buf19, primals_16, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf20, (4, 32, 1, 1), (32, 1, 1, 1))
        buf21 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 1, 1), torch.float32)
        triton_poi_fused_add_convolution_relu_8[grid(128)](buf20,
            primals_17, buf15, buf21, 128, XBLOCK=128, num_warps=4,
            num_stages=1)
        buf22 = extern_kernels.convolution(buf21, primals_18, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf22, (4, 32, 1, 1), (32, 1, 1, 1))
        buf23 = buf22
        del buf22
        triton_poi_fused_convolution_relu_7[grid(128)](buf23, primals_19, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_19
        buf24 = extern_kernels.convolution(buf23, primals_20, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf24, (4, 32, 1, 1), (32, 1, 1, 1))
        buf25 = reinterpret_tensor(buf15, (4, 32, 1, 1), (32, 1, 1, 1), 0)
        del buf15
        triton_poi_fused_add_convolution_9[grid(128)](buf25, buf24,
            primals_21, buf20, primals_17, 128, XBLOCK=128, num_warps=4,
            num_stages=1)
        del primals_17
        del primals_21
        buf26 = extern_kernels.convolution(buf25, primals_22, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf26, (4, 32, 1, 1), (32, 1, 1, 1))
        buf27 = buf26
        del buf26
        buf28 = reinterpret_tensor(buf24, (4, 32, 1, 1), (32, 1, 128, 128), 0)
        del buf24
        buf29 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 1, 1), torch.int8)
        buf30 = buf20
        del buf20
        triton_poi_fused_convolution_max_pool2d_with_indices_relu_10[grid(128)
            ](buf27, primals_23, buf28, buf29, buf30, 128, XBLOCK=128,
            num_warps=4, num_stages=1)
        del primals_23
        buf31 = extern_kernels.convolution(buf30, primals_24, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf31, (4, 32, 1, 1), (32, 1, 1, 1))
        buf32 = buf31
        del buf31
        triton_poi_fused_convolution_relu_7[grid(128)](buf32, primals_25, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_25
        buf33 = extern_kernels.convolution(buf32, primals_26, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf33, (4, 32, 1, 1), (32, 1, 1, 1))
        buf34 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 1, 1), torch.float32)
        triton_poi_fused_add_convolution_relu_8[grid(128)](buf33,
            primals_27, buf28, buf34, 128, XBLOCK=128, num_warps=4,
            num_stages=1)
        buf35 = extern_kernels.convolution(buf34, primals_28, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf35, (4, 32, 1, 1), (32, 1, 1, 1))
        buf36 = buf35
        del buf35
        triton_poi_fused_convolution_relu_7[grid(128)](buf36, primals_29, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_29
        buf37 = extern_kernels.convolution(buf36, primals_30, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf37, (4, 32, 1, 1), (32, 1, 1, 1))
        buf38 = reinterpret_tensor(buf28, (4, 32, 1, 1), (32, 1, 1, 1), 0)
        del buf28
        buf42 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 1, 1), torch.bool)
        triton_poi_fused_add_convolution_relu_threshold_backward_11[grid(128)](
            buf38, buf37, primals_31, buf33, primals_27, buf42, 128, XBLOCK
            =128, num_warps=4, num_stages=1)
        del buf33
        del buf37
        del primals_27
        del primals_31
        buf39 = empty_strided_cuda((4, 256), (256, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf38, (4, 32), (32, 1), 0),
            reinterpret_tensor(primals_32, (32, 256), (1, 32), 0), out=buf39)
        buf40 = buf39
        del buf39
        buf41 = empty_strided_cuda((4, 256), (256, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_12[grid(1024)](buf40,
            primals_33, buf41, 1024, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_33
    return (buf40, primals_1, primals_3, primals_4, primals_6, primals_8,
        primals_10, primals_12, primals_14, primals_16, primals_18,
        primals_20, primals_22, primals_24, primals_26, primals_28,
        primals_30, buf1, buf3, buf4, buf6, buf8, buf10, buf12, buf14,
        buf16, buf17, buf19, buf21, buf23, buf25, buf27, buf29, buf30,
        buf32, buf34, buf36, reinterpret_tensor(buf38, (4, 32), (32, 1), 0),
        buf41, primals_32, buf42)


class _ImpalaResBlock(nn.Module):

    def __init__(self, n_channels: 'int'):
        super().__init__()
        self.n_channels = n_channels
        kernel_size = 3
        padding = 1
        self.relu = nn.ReLU()
        self.relu_inplace = nn.ReLU()
        self.conv1 = nn.Conv2d(n_channels, n_channels, kernel_size, padding
            =padding)
        self.conv2 = nn.Conv2d(n_channels, n_channels, kernel_size, padding
            =padding)

    def forward(self, inputs):
        x = self.relu(inputs)
        x = self.conv1(x)
        x = self.relu_inplace(x)
        x = self.conv2(x)
        x += inputs
        return x


class _ImpalaBlock(nn.Module):

    def __init__(self, n_channels_in: 'int', n_channels_out: 'int'):
        super().__init__()
        self.n_channels_in = n_channels_in
        self.n_channels_out = n_channels_out
        kernel_size = 3
        padding = 1
        self.conv1 = nn.Conv2d(n_channels_in, n_channels_out, kernel_size,
            padding=padding)
        self.pool = nn.MaxPool2d(kernel_size, stride=2, padding=padding)
        self.res1 = _ImpalaResBlock(n_channels_out)
        self.res2 = _ImpalaResBlock(n_channels_out)

    def forward(self, x):
        x = self.conv1(x)
        x = self.pool(x)
        x = self.res1(x)
        x = self.res2(x)
        return x


class _ImpalaCNNNew(nn.Module):

    def __init__(self, img_shape: 'Tuple[int, int, int]', n_extra_feats:
        'int'=0, n_outputs: 'int'=256):
        super().__init__()
        self.n_outputs = n_outputs
        h, w, c = img_shape
        self.block1 = _ImpalaBlock(c, 16)
        self.block2 = _ImpalaBlock(16, 32)
        self.block3 = _ImpalaBlock(32, 32)
        self.relu = nn.ReLU()
        self.flatten = nn.Flatten()
        test_img = torch.empty(c, h, w)[None]
        n_feats = self.block3(self.block2(self.block1(test_img))).numel()
        self.linear = nn.Linear(n_feats + n_extra_feats, self.n_outputs)

    def forward(self, input_0):
        primals_1 = self.block1.conv1.weight
        primals_2 = self.block1.conv1.bias
        primals_4 = self.block1.res1.conv1.weight
        primals_5 = self.block1.res1.conv1.bias
        primals_6 = self.block1.res1.conv2.weight
        primals_7 = self.block1.res1.conv2.bias
        primals_8 = self.block1.res2.conv1.weight
        primals_9 = self.block1.res2.conv1.bias
        primals_10 = self.block1.res2.conv2.weight
        primals_11 = self.block1.res2.conv2.bias
        primals_12 = self.block2.conv1.weight
        primals_13 = self.block2.conv1.bias
        primals_14 = self.block2.res1.conv1.weight
        primals_15 = self.block2.res1.conv1.bias
        primals_16 = self.block2.res1.conv2.weight
        primals_17 = self.block2.res1.conv2.bias
        primals_18 = self.block2.res2.conv1.weight
        primals_19 = self.block2.res2.conv1.bias
        primals_20 = self.block2.res2.conv2.weight
        primals_21 = self.block2.res2.conv2.bias
        primals_22 = self.block3.conv1.weight
        primals_23 = self.block3.conv1.bias
        primals_24 = self.block3.res1.conv1.weight
        primals_25 = self.block3.res1.conv1.bias
        primals_26 = self.block3.res1.conv2.weight
        primals_27 = self.block3.res1.conv2.bias
        primals_28 = self.block3.res2.conv1.weight
        primals_29 = self.block3.res2.conv1.bias
        primals_30 = self.block3.res2.conv2.weight
        primals_31 = self.block3.res2.conv2.bias
        primals_32 = self.linear.weight
        primals_33 = self.linear.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, 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, primals_32, primals_33])
        return output[0]


Measured latency_ms: 0.053975