Skip to content

Instantly share code, notes, and snippets.

@leslie-fang-intel
Created February 17, 2023 02:43
Show Gist options
  • Select an option

  • Save leslie-fang-intel/056a111ef63aabee225b980b671fa8a0 to your computer and use it in GitHub Desktop.

Select an option

Save leslie-fang-intel/056a111ef63aabee225b980b671fa8a0 to your computer and use it in GitHub Desktop.
kernel_cpp_0 = async_compile.cpp('''
#include <ATen/record_function.h>
#include "/tmp/torchinductor_root/dm/cdmaihqxwe73zkb3he2zizktpq5uujetg2db26c3r4lgsmlx3b4c.h"
extern "C" void kernel(const float* __restrict__ in_ptr0,
const float* __restrict__ in_ptr1,
const long* __restrict__ in_ptr2,
unsigned char* __restrict__ out_ptr0)
{
RECORD_FUNCTION("graph_1_kernel_cpp_0", c10::ArrayRef<c10::IValue>({}));
#pragma omp parallel num_threads(28)
{
{
#pragma omp for
for(long i0=0; i0<17461248; i0+=1)
{
auto tmp2 = in_ptr0[i0];
auto tmp3 = in_ptr1[0];
auto tmp6 = in_ptr2[0];
auto tmp0 = static_cast<float>(0);
auto tmp1 = static_cast<float>(127);
auto tmp4 = tmp2 / tmp3;
auto tmp5 = std::nearbyint(tmp4);
auto tmp7 = static_cast<float>(tmp6);
auto tmp8 = tmp5 + tmp7;
auto tmp9 = (tmp8 != tmp8) ? tmp8 : std::min(tmp1, tmp8);
auto tmp10 = (tmp9 != tmp9) ? tmp9 : std::max(tmp0, tmp9);
auto tmp11 = static_cast<unsigned char>(tmp10);
out_ptr0[i0] = tmp11;
}
}
}
}
''')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment