# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_0/inductor_cache/ip/ciphktz7r6maftyty3k7lvyxrzyoxmr2cm64z2e5h5nsrp7z3viz.py
# Topologically Sorted Source Nodes: [grid], Original ATen: [aten.stack]
# Source node to ATen node mapping:
#   grid => cat_1
# Graph fragment:
#   %cat_1 : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%unsqueeze_6, %unsqueeze_7], -1), kwargs = {})
triton_poi_fused_stack_0 = async_compile.triton('triton_poi_fused_stack_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[128], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_stack_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_stack_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 2
    x1 = (xindex // 2) % 4
    x2 = (xindex // 8)
    x3 = xindex
    tmp0 = x0
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = x1
    tmp6 = tmp5.to(tl.float32)
    tmp7 = 2.0
    tmp8 = tmp6 < tmp7
    tmp9 = 0.6666666666666666
    tmp10 = tmp6 * tmp9
    tmp11 = -1.0
    tmp12 = tmp10 + tmp11
    tmp13 = 3 + ((-1)*x1)
    tmp14 = tmp13.to(tl.float32)
    tmp15 = tmp14 * tmp9
    tmp16 = 1.0
    tmp17 = tmp16 - tmp15
    tmp18 = tl.where(tmp8, tmp12, tmp17)
    tmp19 = tmp16 * tmp18
    tmp20 = tl.full(tmp19.shape, 0.0, tmp19.dtype)
    tmp21 = tl.where(tmp4, tmp19, tmp20)
    tmp22 = tmp0 >= tmp3
    tmp23 = tl.full([1], 2, tl.int64)
    tmp24 = tmp0 < tmp23
    tmp25 = tmp5 >= tmp1
    tmp26 = tmp5 < tmp3
    tmp27 = tmp26 & tmp22
    tmp28 = tl.load(in_ptr0 + (x2), tmp27 & xmask, eviction_policy='evict_last', other=0.0)
    tmp29 = tmp5 >= tmp3
    tmp30 = tmp5 < tmp23
    tmp31 = tmp29 & tmp30
    tmp32 = tmp31 & tmp22
    tmp33 = tl.load(in_ptr0 + (x2), tmp32 & xmask, eviction_policy='evict_last', other=0.0)
    tmp34 = tmp5 >= tmp23
    tmp35 = tl.full([1], 3, tl.int64)
    tmp36 = tmp5 < tmp35
    tmp37 = tmp34 & tmp36
    tmp38 = tmp37 & tmp22
    tmp39 = tl.load(in_ptr0 + (x2), tmp38 & xmask, eviction_policy='evict_last', other=0.0)
    tmp40 = tmp5 >= tmp35
    tmp41 = tl.full([1], 4, tl.int64)
    tmp42 = tmp5 < tmp41
    tmp43 = tmp40 & tmp22
    tmp44 = tl.load(in_ptr0 + (x2), tmp43 & xmask, eviction_policy='evict_last', other=0.0)
    tmp45 = tl.where(tmp37, tmp39, tmp44)
    tmp46 = tl.where(tmp31, tmp33, tmp45)
    tmp47 = tl.where(tmp26, tmp28, tmp46)
    tmp48 = tl.full(tmp47.shape, 0.0, tmp47.dtype)
    tmp49 = tl.where(tmp22, tmp47, tmp48)
    tmp50 = tl.where(tmp4, tmp21, tmp49)
    tl.store(out_ptr0 + (x3), tmp50, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_0/inductor_cache/is/cisrqzvop2qq4acfte26goiyf5wuyunfh2lpx7kuhv3muv3kofy5.py
# Topologically Sorted Source Nodes: [x_warped], Original ATen: [aten.grid_sampler_2d]
# Source node to ATen node mapping:
#   x_warped => abs_1, abs_2, add_1, add_2, add_3, add_4, add_5, add_6, add_7, add_8, add_9, bitwise_and, bitwise_and_1, clamp_max, clamp_max_1, clamp_min, clamp_min_1, convert_element_type_10, convert_element_type_11, convert_element_type_2, convert_element_type_3, convert_element_type_4, convert_element_type_5, convert_element_type_6, convert_element_type_7, convert_element_type_9, div, div_1, eq, eq_1, floor, floor_1, floor_2, floor_3, fmod, fmod_1, full_default_1, full_default_10, full_default_11, full_default_12, full_default_2, full_default_3, full_default_4, full_default_5, full_default_6, full_default_8, full_default_9, ge, ge_1, ge_2, ge_3, ge_4, ge_5, ge_6, ge_7, index, index_1, index_2, index_3, logical_and, logical_and_1, logical_and_10, logical_and_11, logical_and_2, logical_and_3, logical_and_4, logical_and_5, logical_and_6, logical_and_7, logical_and_8, logical_and_9, lt_1, lt_2, lt_3, lt_4, lt_5, lt_6, lt_7, lt_8, mul_10, mul_11, mul_12, mul_3, mul_4, mul_5, mul_6, mul_7, mul_8, mul_9, sub_10, sub_11, sub_12, sub_13, sub_2, sub_3, sub_4, sub_5, sub_6, sub_7, sub_8, sub_9, where_1, where_10, where_11, where_12, where_13, where_14, where_2, where_3, where_4, where_5, where_6, where_7, where_8
# Graph fragment:
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select, 1.5), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_3, 1.5), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_1, 0.0), kwargs = {})
#   %abs_1 : [num_users=2] = call_function[target=torch.ops.aten.abs.default](args = (%sub_2,), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%abs_1, 3.0), kwargs = {})
#   %floor : [num_users=1] = call_function[target=torch.ops.aten.floor.default](args = (%div,), kwargs = {})
#   %convert_element_type_2 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%floor, torch.int8), kwargs = {})
#   %bitwise_and : [num_users=1] = call_function[target=torch.ops.aten.bitwise_and.Scalar](args = (%convert_element_type_2, 1), kwargs = {})
#   %eq : [num_users=1] = call_function[target=torch.ops.aten.eq.Scalar](args = (%bitwise_and, 0), kwargs = {})
#   %fmod : [num_users=2] = call_function[target=torch.ops.aten.fmod.Scalar](args = (%abs_1, 3.0), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%fmod, 0.0), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (3.0, %fmod), kwargs = {})
#   %where_1 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq, %add_2, %sub_3), kwargs = {})
#   %clamp_min : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%where_1, 0), kwargs = {})
#   %clamp_max : [num_users=5] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min, 3), kwargs = {})
#   %floor_2 : [num_users=9] = call_function[target=torch.ops.aten.floor.default](args = (%clamp_max,), kwargs = {})
#   %ge : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%floor_2, 0), kwargs = {})
#   %lt_1 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%floor_2, 4), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_1, 1.5), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_4, 1.5), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_3, 0.0), kwargs = {})
#   %abs_2 : [num_users=2] = call_function[target=torch.ops.aten.abs.default](args = (%sub_4,), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%abs_2, 3.0), kwargs = {})
#   %floor_1 : [num_users=1] = call_function[target=torch.ops.aten.floor.default](args = (%div_1,), kwargs = {})
#   %convert_element_type_3 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%floor_1, torch.int8), kwargs = {})
#   %bitwise_and_1 : [num_users=1] = call_function[target=torch.ops.aten.bitwise_and.Scalar](args = (%convert_element_type_3, 1), kwargs = {})
#   %eq_1 : [num_users=1] = call_function[target=torch.ops.aten.eq.Scalar](args = (%bitwise_and_1, 0), kwargs = {})
#   %fmod_1 : [num_users=2] = call_function[target=torch.ops.aten.fmod.Scalar](args = (%abs_2, 3.0), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%fmod_1, 0.0), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (3.0, %fmod_1), kwargs = {})
#   %where_2 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_1, %add_4, %sub_5), kwargs = {})
#   %clamp_min_1 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%where_2, 0), kwargs = {})
#   %clamp_max_1 : [num_users=5] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_1, 3), kwargs = {})
#   %floor_3 : [num_users=9] = call_function[target=torch.ops.aten.floor.default](args = (%clamp_max_1,), kwargs = {})
#   %ge_1 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%floor_3, 0), kwargs = {})
#   %lt_2 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%floor_3, 4), kwargs = {})
#   %logical_and : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_1, %lt_2), kwargs = {})
#   %logical_and_1 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%lt_1, %logical_and), kwargs = {})
#   %logical_and_2 : [num_users=3] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge, %logical_and_1), kwargs = {})
#   %convert_element_type_5 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%floor_3, torch.int64), kwargs = {})
#   %full_default_2 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_4 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_2, %convert_element_type_5, %full_default_2), kwargs = {})
#   %convert_element_type_4 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%floor_2, torch.int64), kwargs = {})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_3 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_2, %convert_element_type_4, %full_default_1), kwargs = {})
#   %index : [num_users=1] = call_function[target=torch.ops.aten.index.Tensor](args = (%arg0_1, [%view_1, %view_2, %where_4, %where_3]), kwargs = {})
#   %add_5 : [num_users=8] = call_function[target=torch.ops.aten.add.Tensor](args = (%floor_2, 1), kwargs = {})
#   %sub_6 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_5, %clamp_max), kwargs = {})
#   %add_6 : [num_users=8] = call_function[target=torch.ops.aten.add.Tensor](args = (%floor_3, 1), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_6, %clamp_max_1), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_6, %sub_7), kwargs = {})
#   %full_default_3 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_5 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_2, %mul_5, %full_default_3), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%index, %where_5), kwargs = {})
#   %ge_2 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%add_5, 0), kwargs = {})
#   %lt_3 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%add_5, 4), kwargs = {})
#   %ge_3 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%floor_3, 0), kwargs = {})
#   %lt_4 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%floor_3, 4), kwargs = {})
#   %logical_and_3 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_3, %lt_4), kwargs = {})
#   %logical_and_4 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%lt_3, %logical_and_3), kwargs = {})
#   %logical_and_5 : [num_users=3] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_2, %logical_and_4), kwargs = {})
#   %convert_element_type_7 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%floor_3, torch.int64), kwargs = {})
#   %full_default_5 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_7 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_5, %convert_element_type_7, %full_default_5), kwargs = {})
#   %convert_element_type_6 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_5, torch.int64), kwargs = {})
#   %full_default_4 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_6 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_5, %convert_element_type_6, %full_default_4), kwargs = {})
#   %index_1 : [num_users=1] = call_function[target=torch.ops.aten.index.Tensor](args = (%arg0_1, [%view_1, %view_2, %where_7, %where_6]), kwargs = {})
#   %sub_8 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_max, %floor_2), kwargs = {})
#   %sub_9 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_6, %clamp_max_1), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_8, %sub_9), kwargs = {})
#   %full_default_6 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_8 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_5, %mul_6, %full_default_6), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%index_1, %where_8), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_9, %mul_10), kwargs = {})
#   %ge_4 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%floor_2, 0), kwargs = {})
#   %lt_5 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%floor_2, 4), kwargs = {})
#   %ge_5 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%add_6, 0), kwargs = {})
#   %lt_6 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%add_6, 4), kwargs = {})
#   %logical_and_6 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_5, %lt_6), kwargs = {})
#   %logical_and_7 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%lt_5, %logical_and_6), kwargs = {})
#   %logical_and_8 : [num_users=3] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_4, %logical_and_7), kwargs = {})
#   %convert_element_type_9 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_6, torch.int64), kwargs = {})
#   %full_default_8 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_10 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_8, %convert_element_type_9, %full_default_8), kwargs = {})
#   %index_2 : [num_users=1] = call_function[target=torch.ops.aten.index.Tensor](args = (%arg0_1, [%view_1, %view_2, %where_10, %where_9]), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_5, %clamp_max), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_max_1, %floor_3), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_10, %sub_11), kwargs = {})
#   %full_default_9 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_11 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_8, %mul_7, %full_default_9), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%index_2, %where_11), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_7, %mul_11), kwargs = {})
#   %ge_6 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%add_5, 0), kwargs = {})
#   %lt_7 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%add_5, 4), kwargs = {})
#   %ge_7 : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%add_6, 0), kwargs = {})
#   %lt_8 : [num_users=1] = call_function[target=torch.ops.aten.lt.Scalar](args = (%add_6, 4), kwargs = {})
#   %logical_and_9 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_7, %lt_8), kwargs = {})
#   %logical_and_10 : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%lt_7, %logical_and_9), kwargs = {})
#   %logical_and_11 : [num_users=3] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge_6, %logical_and_10), kwargs = {})
#   %convert_element_type_11 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_6, torch.int64), kwargs = {})
#   %full_default_11 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_13 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_11, %convert_element_type_11, %full_default_11), kwargs = {})
#   %convert_element_type_10 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_5, torch.int64), kwargs = {})
#   %full_default_10 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_12 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_11, %convert_element_type_10, %full_default_10), kwargs = {})
#   %index_3 : [num_users=1] = call_function[target=torch.ops.aten.index.Tensor](args = (%arg0_1, [%view_1, %view_2, %where_13, %where_12]), kwargs = {})
#   %sub_12 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_max, %floor_2), kwargs = {})
#   %sub_13 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_max_1, %floor_3), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_12, %sub_13), kwargs = {})
#   %full_default_12 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_14 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%logical_and_11, %mul_8, %full_default_12), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%index_3, %where_14), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_8, %mul_12), kwargs = {})
triton_poi_fused_grid_sampler_2d_1 = async_compile.triton('triton_poi_fused_grid_sampler_2d_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_grid_sampler_2d_1', 'mutated_arg_names': ['in_out_ptr2'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_grid_sampler_2d_1(in_out_ptr2, in_ptr0, in_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x2 = (xindex // 64)
    x3 = xindex
    x4 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (1 + (2*x0) + (32*x2)), xmask, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr0 + ((2*x0) + (32*x2)), xmask, eviction_policy='evict_last')
    tmp1 = 1.5
    tmp2 = tmp0 * tmp1
    tmp3 = tmp2 + tmp1
    tmp4 = 0.0
    tmp5 = tmp3 - tmp4
    tmp6 = tl_math.abs(tmp5)
    tmp7 = 0.3333333333333333
    tmp8 = tmp6 * tmp7
    tmp9 = libdevice.floor(tmp8)
    tmp10 = tmp9.to(tl.int8)
    tmp11 = tl.full([1], 1, tl.int8)
    tmp12 = tmp10 & tmp11
    tmp13 = tl.full([1], 0, tl.int8)
    tmp14 = tmp12 == tmp13
    tmp15 = 3.0
    tmp16 = libdevice.fmod(tmp6, tmp15)
    tmp17 = tmp16 + tmp4
    tmp18 = tmp15 - tmp16
    tmp19 = tl.where(tmp14, tmp17, tmp18)
    tmp20 = triton_helpers.maximum(tmp19, tmp4)
    tmp21 = triton_helpers.minimum(tmp20, tmp15)
    tmp22 = libdevice.floor(tmp21)
    tmp23 = 1.0
    tmp24 = tmp22 + tmp23
    tmp25 = tmp24 >= tmp4
    tmp26 = 4.0
    tmp27 = tmp24 < tmp26
    tmp28 = tmp25 & tmp27
    tmp30 = tmp29 * tmp1
    tmp31 = tmp30 + tmp1
    tmp32 = tmp31 - tmp4
    tmp33 = tl_math.abs(tmp32)
    tmp34 = tmp33 * tmp7
    tmp35 = libdevice.floor(tmp34)
    tmp36 = tmp35.to(tl.int8)
    tmp37 = tmp36 & tmp11
    tmp38 = tmp37 == tmp13
    tmp39 = libdevice.fmod(tmp33, tmp15)
    tmp40 = tmp39 + tmp4
    tmp41 = tmp15 - tmp39
    tmp42 = tl.where(tmp38, tmp40, tmp41)
    tmp43 = triton_helpers.maximum(tmp42, tmp4)
    tmp44 = triton_helpers.minimum(tmp43, tmp15)
    tmp45 = libdevice.floor(tmp44)
    tmp46 = tmp45 >= tmp4
    tmp47 = tmp45 < tmp26
    tmp48 = tmp47 & tmp28
    tmp49 = tmp46 & tmp48
    tmp50 = tmp45 + tmp23
    tmp51 = tmp50 < tmp26
    tmp52 = tmp51 & tmp28
    tmp53 = tmp22 >= tmp4
    tmp54 = tmp22 < tmp26
    tmp55 = tmp53 & tmp54
    tmp56 = tmp51 & tmp55
    tmp57 = tmp47 & tmp55
    tmp58 = tmp44 - tmp45
    tmp59 = tmp24 - tmp21
    tmp60 = tmp58 * tmp59
    tmp61 = tmp50 >= tmp4
    tmp62 = tmp61 & tmp56
    tmp63 = tl.where(tmp62, tmp60, tmp4)
    tmp64 = tmp50 - tmp44
    tmp65 = tmp21 - tmp22
    tmp66 = tmp64 * tmp65
    tmp67 = tmp58 * tmp65
    tmp68 = tmp61 & tmp52
    tmp69 = tl.where(tmp68, tmp67, tmp4)
    tmp70 = tmp64 * tmp59
    tmp71 = tmp46 & tmp57
    tmp72 = tmp22.to(tl.int64)
    tmp73 = tl.full([1], 0, tl.int64)
    tmp74 = tl.where(tmp71, tmp72, tmp73)
    tmp75 = tmp45.to(tl.int64)
    tmp76 = tl.where(tmp71, tmp75, tmp73)
    tmp77 = tl.full([XBLOCK], 4, tl.int32)
    tmp78 = tmp74 + tmp77
    tmp79 = tmp74 < 0
    tmp80 = tl.where(tmp79, tmp78, tmp74)
    tl.device_assert(((0 <= tmp80) & (tmp80 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp80 < 4")
    tmp82 = tmp76 + tmp77
    tmp83 = tmp76 < 0
    tmp84 = tl.where(tmp83, tmp82, tmp76)
    tl.device_assert(((0 <= tmp84) & (tmp84 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp84 < 4")
    tmp86 = tl.load(in_ptr1 + (tmp84 + (4*tmp80) + (16*x4)), xmask, eviction_policy='evict_last')
    tmp87 = tl.where(tmp71, tmp70, tmp4)
    tmp88 = tmp86 * tmp87
    tmp89 = tl.where(tmp62, tmp72, tmp73)
    tmp90 = tmp50.to(tl.int64)
    tmp91 = tl.where(tmp62, tmp90, tmp73)
    tmp92 = tmp24.to(tl.int64)
    tmp93 = tl.where(tmp68, tmp92, tmp73)
    tmp94 = tl.where(tmp68, tmp90, tmp73)
    tmp95 = tl.where(tmp49, tmp92, tmp73)
    tmp96 = tmp95 + tmp77
    tmp97 = tmp95 < 0
    tmp98 = tl.where(tmp97, tmp96, tmp95)
    tl.device_assert(((0 <= tmp98) & (tmp98 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp98 < 4")
    tmp100 = tl.where(tmp49, tmp75, tmp73)
    tmp101 = tmp100 + tmp77
    tmp102 = tmp100 < 0
    tmp103 = tl.where(tmp102, tmp101, tmp100)
    tl.device_assert(((0 <= tmp103) & (tmp103 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp103 < 4")
    tmp105 = tl.load(in_ptr1 + (tmp103 + (4*tmp98) + (16*x4)), xmask, eviction_policy='evict_last')
    tmp106 = tmp89 + tmp77
    tmp107 = tmp89 < 0
    tmp108 = tl.where(tmp107, tmp106, tmp89)
    tl.device_assert(((0 <= tmp108) & (tmp108 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp108 < 4")
    tmp110 = tmp91 + tmp77
    tmp111 = tmp91 < 0
    tmp112 = tl.where(tmp111, tmp110, tmp91)
    tl.device_assert(((0 <= tmp112) & (tmp112 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp112 < 4")
    tmp114 = tl.load(in_ptr1 + (tmp112 + (4*tmp108) + (16*x4)), xmask, eviction_policy='evict_last')
    tmp115 = tmp114 * tmp63
    tmp116 = tmp88 + tmp115
    tmp117 = tl.where(tmp49, tmp66, tmp4)
    tmp118 = tmp105 * tmp117
    tmp119 = tmp116 + tmp118
    tmp120 = tmp93 + tmp77
    tmp121 = tmp93 < 0
    tmp122 = tl.where(tmp121, tmp120, tmp93)
    tl.device_assert(((0 <= tmp122) & (tmp122 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp122 < 4")
    tmp124 = tmp94 + tmp77
    tmp125 = tmp94 < 0
    tmp126 = tl.where(tmp125, tmp124, tmp94)
    tl.device_assert(((0 <= tmp126) & (tmp126 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp126 < 4")
    tmp128 = tl.load(in_ptr1 + (tmp126 + (4*tmp122) + (16*x4)), xmask, eviction_policy='evict_last')
    tmp129 = tmp128 * tmp69
    tmp130 = tmp119 + tmp129
    tl.store(in_out_ptr2 + (x3), tmp130, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 2), (32, 8, 2, 1), torch.float32)
        # Topologically Sorted Source Nodes: [grid], Original ATen: [aten.stack]
        stream0 = get_raw_stream(0)
        triton_poi_fused_stack_0.run(arg1_1, buf0, 128, grid=grid(128), stream=stream0)
        del arg1_1
        buf9 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf10 = buf9; del buf9  # reuse
        buf22 = buf10; del buf10  # reuse
        # Topologically Sorted Source Nodes: [x_warped], Original ATen: [aten.grid_sampler_2d]
        triton_poi_fused_grid_sampler_2d_1.run(buf22, buf0, arg0_1, 256, grid=grid(256), stream=stream0)
        del arg0_1
        del buf0
    return (buf22, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
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_stack_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 2
    x1 = xindex // 2 % 4
    x2 = xindex // 8
    x3 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = x1
    tmp6 = tmp5.to(tl.float32)
    tmp7 = 2.0
    tmp8 = tmp6 < tmp7
    tmp9 = 0.6666666666666666
    tmp10 = tmp6 * tmp9
    tmp11 = -1.0
    tmp12 = tmp10 + tmp11
    tmp13 = 3 + -1 * x1
    tmp14 = tmp13.to(tl.float32)
    tmp15 = tmp14 * tmp9
    tmp16 = 1.0
    tmp17 = tmp16 - tmp15
    tmp18 = tl.where(tmp8, tmp12, tmp17)
    tmp19 = tmp16 * tmp18
    tmp20 = tl.full(tmp19.shape, 0.0, tmp19.dtype)
    tmp21 = tl.where(tmp4, tmp19, tmp20)
    tmp22 = tmp0 >= tmp3
    tmp23 = tl.full([1], 2, tl.int64)
    tmp26 = tmp5 < tmp3
    tmp27 = tmp26 & tmp22
    tmp28 = tl.load(in_ptr0 + x2, tmp27 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp29 = tmp5 >= tmp3
    tmp30 = tmp5 < tmp23
    tmp31 = tmp29 & tmp30
    tmp32 = tmp31 & tmp22
    tmp33 = tl.load(in_ptr0 + x2, tmp32 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp34 = tmp5 >= tmp23
    tmp35 = tl.full([1], 3, tl.int64)
    tmp36 = tmp5 < tmp35
    tmp37 = tmp34 & tmp36
    tmp38 = tmp37 & tmp22
    tmp39 = tl.load(in_ptr0 + x2, tmp38 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp40 = tmp5 >= tmp35
    tl.full([1], 4, tl.int64)
    tmp43 = tmp40 & tmp22
    tmp44 = tl.load(in_ptr0 + x2, tmp43 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp45 = tl.where(tmp37, tmp39, tmp44)
    tmp46 = tl.where(tmp31, tmp33, tmp45)
    tmp47 = tl.where(tmp26, tmp28, tmp46)
    tmp48 = tl.full(tmp47.shape, 0.0, tmp47.dtype)
    tmp49 = tl.where(tmp22, tmp47, tmp48)
    tmp50 = tl.where(tmp4, tmp21, tmp49)
    tl.store(out_ptr0 + x3, tmp50, xmask)


@triton.jit
def triton_poi_fused_grid_sampler_2d_1(in_out_ptr2, in_ptr0, in_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x2 = xindex // 64
    x3 = xindex
    x4 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (1 + 2 * x0 + 32 * x2), xmask, eviction_policy
        ='evict_last')
    tmp29 = tl.load(in_ptr0 + (2 * x0 + 32 * x2), xmask, eviction_policy=
        'evict_last')
    tmp1 = 1.5
    tmp2 = tmp0 * tmp1
    tmp3 = tmp2 + tmp1
    tmp4 = 0.0
    tmp5 = tmp3 - tmp4
    tmp6 = tl_math.abs(tmp5)
    tmp7 = 0.3333333333333333
    tmp8 = tmp6 * tmp7
    tmp9 = libdevice.floor(tmp8)
    tmp10 = tmp9.to(tl.int8)
    tmp11 = tl.full([1], 1, tl.int8)
    tmp12 = tmp10 & tmp11
    tmp13 = tl.full([1], 0, tl.int8)
    tmp14 = tmp12 == tmp13
    tmp15 = 3.0
    tmp16 = libdevice.fmod(tmp6, tmp15)
    tmp17 = tmp16 + tmp4
    tmp18 = tmp15 - tmp16
    tmp19 = tl.where(tmp14, tmp17, tmp18)
    tmp20 = triton_helpers.maximum(tmp19, tmp4)
    tmp21 = triton_helpers.minimum(tmp20, tmp15)
    tmp22 = libdevice.floor(tmp21)
    tmp23 = 1.0
    tmp24 = tmp22 + tmp23
    tmp25 = tmp24 >= tmp4
    tmp26 = 4.0
    tmp27 = tmp24 < tmp26
    tmp28 = tmp25 & tmp27
    tmp30 = tmp29 * tmp1
    tmp31 = tmp30 + tmp1
    tmp32 = tmp31 - tmp4
    tmp33 = tl_math.abs(tmp32)
    tmp34 = tmp33 * tmp7
    tmp35 = libdevice.floor(tmp34)
    tmp36 = tmp35.to(tl.int8)
    tmp37 = tmp36 & tmp11
    tmp38 = tmp37 == tmp13
    tmp39 = libdevice.fmod(tmp33, tmp15)
    tmp40 = tmp39 + tmp4
    tmp41 = tmp15 - tmp39
    tmp42 = tl.where(tmp38, tmp40, tmp41)
    tmp43 = triton_helpers.maximum(tmp42, tmp4)
    tmp44 = triton_helpers.minimum(tmp43, tmp15)
    tmp45 = libdevice.floor(tmp44)
    tmp46 = tmp45 >= tmp4
    tmp47 = tmp45 < tmp26
    tmp48 = tmp47 & tmp28
    tmp49 = tmp46 & tmp48
    tmp50 = tmp45 + tmp23
    tmp51 = tmp50 < tmp26
    tmp52 = tmp51 & tmp28
    tmp53 = tmp22 >= tmp4
    tmp54 = tmp22 < tmp26
    tmp55 = tmp53 & tmp54
    tmp56 = tmp51 & tmp55
    tmp57 = tmp47 & tmp55
    tmp58 = tmp44 - tmp45
    tmp59 = tmp24 - tmp21
    tmp60 = tmp58 * tmp59
    tmp61 = tmp50 >= tmp4
    tmp62 = tmp61 & tmp56
    tmp63 = tl.where(tmp62, tmp60, tmp4)
    tmp64 = tmp50 - tmp44
    tmp65 = tmp21 - tmp22
    tmp66 = tmp64 * tmp65
    tmp67 = tmp58 * tmp65
    tmp68 = tmp61 & tmp52
    tmp69 = tl.where(tmp68, tmp67, tmp4)
    tmp70 = tmp64 * tmp59
    tmp71 = tmp46 & tmp57
    tmp72 = tmp22.to(tl.int64)
    tmp73 = tl.full([1], 0, tl.int64)
    tmp74 = tl.where(tmp71, tmp72, tmp73)
    tmp75 = tmp45.to(tl.int64)
    tmp76 = tl.where(tmp71, tmp75, tmp73)
    tmp77 = tl.full([XBLOCK], 4, tl.int32)
    tmp78 = tmp74 + tmp77
    tmp79 = tmp74 < 0
    tmp80 = tl.where(tmp79, tmp78, tmp74)
    tl.device_assert((0 <= tmp80) & (tmp80 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp80 < 4')
    tmp82 = tmp76 + tmp77
    tmp83 = tmp76 < 0
    tmp84 = tl.where(tmp83, tmp82, tmp76)
    tl.device_assert((0 <= tmp84) & (tmp84 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp84 < 4')
    tmp86 = tl.load(in_ptr1 + (tmp84 + 4 * tmp80 + 16 * x4), xmask,
        eviction_policy='evict_last')
    tmp87 = tl.where(tmp71, tmp70, tmp4)
    tmp88 = tmp86 * tmp87
    tmp89 = tl.where(tmp62, tmp72, tmp73)
    tmp90 = tmp50.to(tl.int64)
    tmp91 = tl.where(tmp62, tmp90, tmp73)
    tmp92 = tmp24.to(tl.int64)
    tmp93 = tl.where(tmp68, tmp92, tmp73)
    tmp94 = tl.where(tmp68, tmp90, tmp73)
    tmp95 = tl.where(tmp49, tmp92, tmp73)
    tmp96 = tmp95 + tmp77
    tmp97 = tmp95 < 0
    tmp98 = tl.where(tmp97, tmp96, tmp95)
    tl.device_assert((0 <= tmp98) & (tmp98 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp98 < 4')
    tmp100 = tl.where(tmp49, tmp75, tmp73)
    tmp101 = tmp100 + tmp77
    tmp102 = tmp100 < 0
    tmp103 = tl.where(tmp102, tmp101, tmp100)
    tl.device_assert((0 <= tmp103) & (tmp103 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp103 < 4')
    tmp105 = tl.load(in_ptr1 + (tmp103 + 4 * tmp98 + 16 * x4), xmask,
        eviction_policy='evict_last')
    tmp106 = tmp89 + tmp77
    tmp107 = tmp89 < 0
    tmp108 = tl.where(tmp107, tmp106, tmp89)
    tl.device_assert((0 <= tmp108) & (tmp108 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp108 < 4')
    tmp110 = tmp91 + tmp77
    tmp111 = tmp91 < 0
    tmp112 = tl.where(tmp111, tmp110, tmp91)
    tl.device_assert((0 <= tmp112) & (tmp112 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp112 < 4')
    tmp114 = tl.load(in_ptr1 + (tmp112 + 4 * tmp108 + 16 * x4), xmask,
        eviction_policy='evict_last')
    tmp115 = tmp114 * tmp63
    tmp116 = tmp88 + tmp115
    tmp117 = tl.where(tmp49, tmp66, tmp4)
    tmp118 = tmp105 * tmp117
    tmp119 = tmp116 + tmp118
    tmp120 = tmp93 + tmp77
    tmp121 = tmp93 < 0
    tmp122 = tl.where(tmp121, tmp120, tmp93)
    tl.device_assert((0 <= tmp122) & (tmp122 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp122 < 4')
    tmp124 = tmp94 + tmp77
    tmp125 = tmp94 < 0
    tmp126 = tl.where(tmp125, tmp124, tmp94)
    tl.device_assert((0 <= tmp126) & (tmp126 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp126 < 4')
    tmp128 = tl.load(in_ptr1 + (tmp126 + 4 * tmp122 + 16 * x4), xmask,
        eviction_policy='evict_last')
    tmp129 = tmp128 * tmp69
    tmp130 = tmp119 + tmp129
    tl.store(in_out_ptr2 + x3, tmp130, xmask)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 2), (32, 8, 2, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_stack_0[grid(128)](arg1_1, buf0, 128, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg1_1
        buf9 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf10 = buf9
        del buf9
        buf22 = buf10
        del buf10
        triton_poi_fused_grid_sampler_2d_1[grid(256)](buf22, buf0, arg0_1, 
            256, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        del buf0
    return buf22,


class WarpNew(torch.nn.Module):
    """Custom warping layer."""

    def __init__(self, mode='bilinear', padding_mode='reflection'):
        super().__init__()
        self.mode = mode
        self.padding_mode = padding_mode

    def forward(self, input_0, input_1):
        arg0_1 = input_0
        arg1_1 = input_1
        output = call([arg0_1, arg1_1])
        return output[0]
