mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-19 20:40:07 +00:00
* ad gelu and fast_gelu
* added GeLU and fast GeLU
* clean up
* add gemm+fastgelu example
* add gemm+gelu instances
* update profiler
* clean up
* clean up
* adding gemm+bias+activation
* clean
* adding bias
* clean
* adding gemm multiple d
* debugging
* add gemm bias add fastgelu
* rename, clean
* refactoring; add readme
* refactor
* refactor
* refactor
* refactor
* refactor
* refactor
* fix
* fix
* update example
* update example
* rename
* update example
* add ckProfiler
* clean
* clean
* clean
* clean
* add client app example
* update readme
* delete obselete files
* remove old client app
* delete old file
* cleaning
* clean
* remove half
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path for all examples
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path
* fix header path
* revert client app example
* clean build
* fix build
* temporary disable client test on Jenkins
* clean
* clean
* clean
[ROCm/composable_kernel commit: d1db6a0c3e]
115 lines
2.4 KiB
C++
115 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <cmath>
|
|
|
|
#include "ck/utility/data_type.hpp"
|
|
#include "ck/utility/type.hpp"
|
|
|
|
namespace ck {
|
|
namespace math {
|
|
|
|
// math functions for the host, some are implemented by calling C++ std functions
|
|
|
|
static inline __host__ float abs(float x) { return std::abs(x); };
|
|
|
|
static inline __host__ double abs(double x) { return std::abs(x); };
|
|
|
|
static inline __host__ int8_t abs(int8_t x)
|
|
{
|
|
int8_t sgn = x >> (8 - 1);
|
|
|
|
return (x ^ sgn) - sgn;
|
|
};
|
|
|
|
static inline __host__ int32_t abs(int32_t x)
|
|
{
|
|
int32_t sgn = x >> (32 - 1);
|
|
|
|
return (x ^ sgn) - sgn;
|
|
};
|
|
|
|
static inline __host__ half_t abs(half_t x)
|
|
{
|
|
uint16_t xx = ck::bit_cast<uint16_t>(x);
|
|
|
|
uint16_t abs_xx = xx & 0x7fff;
|
|
|
|
half_t abs_x = ck::bit_cast<half_t>(abs_xx);
|
|
|
|
return abs_x;
|
|
};
|
|
|
|
static inline __host__ bool isnan(float x) { return std::isnan(x); };
|
|
|
|
static inline __host__ bool isnan(double x) { return std::isnan(x); };
|
|
|
|
static inline __host__ bool isnan(int8_t x)
|
|
{
|
|
(void)x;
|
|
return false;
|
|
};
|
|
|
|
static inline __host__ bool isnan(int32_t x)
|
|
{
|
|
(void)x;
|
|
return false;
|
|
};
|
|
|
|
static inline __host__ bool isnan(half_t x)
|
|
{
|
|
uint16_t xx = ck::bit_cast<uint16_t>(x);
|
|
|
|
return (xx & 0x7FFF) > 0x7C00;
|
|
};
|
|
|
|
static inline __host__ float sqrt(float x) { return std::sqrt(x); };
|
|
|
|
static inline __host__ double sqrt(double x) { return std::sqrt(x); };
|
|
|
|
// math functions for the HIP kernel, some are implemented by calling hip builtin functions
|
|
|
|
static inline __device__ float abs(float x) { return ::abs(x); };
|
|
|
|
static inline __device__ double abs(double x) { return ::abs(x); };
|
|
|
|
static inline __device__ int8_t abs(int8_t x)
|
|
{
|
|
int8_t sgn = x >> (8 - 1);
|
|
|
|
return (x ^ sgn) - sgn;
|
|
};
|
|
|
|
static inline __device__ int32_t abs(int32_t x)
|
|
{
|
|
int32_t sgn = x >> (32 - 1);
|
|
|
|
return (x ^ sgn) - sgn;
|
|
};
|
|
|
|
static inline __device__ half_t abs(half_t x) { return ::__habs(x); };
|
|
|
|
static inline __device__ bool isnan(float x) { return ::isnan(x); };
|
|
|
|
static inline __device__ bool isnan(double x) { return ::isnan(x); };
|
|
|
|
static inline __device__ bool isnan(int8_t x)
|
|
{
|
|
(void)x;
|
|
return false;
|
|
};
|
|
|
|
static inline __device__ bool isnan(int32_t x)
|
|
{
|
|
(void)x;
|
|
return false;
|
|
};
|
|
|
|
static inline __device__ bool isnan(half_t x) { return ::__hisnan(x); };
|
|
|
|
static inline __device__ float sqrt(float x) { return ::sqrtf(x); };
|
|
|
|
static inline __device__ double sqrt(double x) { return ::sqrt(x); };
|
|
|
|
} // namespace math
|
|
} // namespace ck
|