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.triton_helpers import libdevice, math as tl_math
import torch.nn as nn
import torch.utils.data
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_div_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = 1e-05
    tmp13 = tmp11 + tmp12
    tmp14 = libdevice.sqrt(tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_add_cos_mul_pow_rsub_sin_sqrt_sub_sum_1(in_ptr0,
    in_ptr1, out_ptr0, out_ptr1, out_ptr2, out_ptr3, out_ptr4, out_ptr5,
    out_ptr6, out_ptr7, out_ptr8, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (x0 + 64 * x1), xmask)
    tmp4 = tl.load(in_ptr1 + (x0 + 64 * x1), xmask)
    tmp6 = tl.load(in_ptr1 + (16 + x0 + 64 * x1), xmask)
    tmp9 = tl.load(in_ptr1 + (32 + x0 + 64 * x1), xmask)
    tmp12 = tl.load(in_ptr1 + (48 + x0 + 64 * x1), xmask)
    tmp21 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp25 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp1 = tmp0 * tmp0
    tmp2 = 1.0
    tmp3 = tmp2 - tmp1
    tmp5 = tmp4 * tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp13 = tmp12 * tmp12
    tmp14 = tmp11 + tmp13
    tmp15 = 1e-05
    tmp16 = tmp14 + tmp15
    tmp17 = libdevice.sqrt(tmp16)
    tmp18 = tl_math.cos(tmp17)
    tmp19 = tmp3 * tmp18
    tmp20 = tmp1 + tmp19
    tmp22 = tmp0 * tmp21
    tmp23 = tmp2 - tmp18
    tmp24 = tmp22 * tmp23
    tmp26 = tl_math.sin(tmp17)
    tmp27 = tmp25 * tmp26
    tmp28 = tmp24 - tmp27
    tmp29 = tmp0 * tmp25
    tmp30 = tmp29 * tmp23
    tmp31 = tmp21 * tmp26
    tmp32 = tmp30 + tmp31
    tmp33 = tmp24 + tmp27
    tmp34 = tmp21 * tmp25
    tmp35 = tmp34 * tmp23
    tmp36 = tmp0 * tmp26
    tmp37 = tmp35 - tmp36
    tmp38 = tmp30 - tmp31
    tmp39 = tmp35 + tmp36
    tmp40 = tmp21 * tmp21
    tmp41 = tmp2 - tmp40
    tmp42 = tmp41 * tmp18
    tmp43 = tmp40 + tmp42
    tmp44 = tmp25 * tmp25
    tmp45 = tmp2 - tmp44
    tmp46 = tmp45 * tmp18
    tmp47 = tmp44 + tmp46
    tl.store(out_ptr0 + (x0 + 144 * x1), tmp20, xmask)
    tl.store(out_ptr1 + (x0 + 144 * x1), tmp28, xmask)
    tl.store(out_ptr2 + (x0 + 144 * x1), tmp32, xmask)
    tl.store(out_ptr3 + (x0 + 144 * x1), tmp33, xmask)
    tl.store(out_ptr4 + (x0 + 144 * x1), tmp37, xmask)
    tl.store(out_ptr5 + (x0 + 144 * x1), tmp38, xmask)
    tl.store(out_ptr6 + (x0 + 144 * x1), tmp39, xmask)
    tl.store(out_ptr7 + (x0 + 144 * x1), tmp43, xmask)
    tl.store(out_ptr8 + (x0 + 144 * x1), tmp47, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_div_0[grid(256)](arg0_1, buf0, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf10 = empty_strided_cuda((4, 36, 4), (144, 4, 1), torch.float32)
        buf1 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 0)
        buf2 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 16)
        buf3 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 32)
        buf4 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 48)
        buf6 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 80)
        buf7 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 96)
        buf8 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 112)
        buf5 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 64)
        buf9 = reinterpret_tensor(buf10, (4, 4, 4), (144, 4, 1), 128)
        triton_poi_fused_add_cos_mul_pow_rsub_sin_sqrt_sub_sum_1[grid(64)](buf0
            , arg0_1, buf1, buf2, buf3, buf4, buf6, buf7, buf8, buf5, buf9,
            64, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        del buf0
    return reinterpret_tensor(buf10, (64, 3, 3), (9, 3, 1), 0),


class RodriguesNew(nn.Module):

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

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


Measured latency_ms: 0.03754