Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MIOPEN_BETA_API defines around f8 #2430

Merged
merged 21 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ include(ROCMCreatePackage)
include(CheckCXXCompilerFlag)
include(ROCMHeaderWrapper)

# Build library with Beta APIs
add_definitions("-DMIOPEN_BETA_API=1")

Comment on lines +71 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Recommendation] Remove all conditionals like

#ifdef MIOPEN_BETA_API
...
#endif

from the library sources EXCEPT miopen.h.

But this can be done later.

set(MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK On CACHE BOOL "Enable AI-based fallback for Immediate Mode")
set(MIOPEN_ENABLE_AI_KERNEL_TUNING On CACHE BOOL "Enable AI heuristic for kernel tuning")
set(MIOPEN_ENABLE_SQLITE On CACHE BOOL "")
Expand Down
6 changes: 3 additions & 3 deletions driver/layernorm_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,19 @@ int LayerNormDriver<Tgpu, Tref>::AllocateBuffersAndCopy()

for(int i = 0; i < in_sz; i++)
{
in[i] = RAN_GEN<Tgpu>(static_cast<Tgpu>(0.0), static_cast<Tgpu>(1.0));
in[i] = prng::gen_A_to_B<Tgpu>(static_cast<Tgpu>(0.0), static_cast<Tgpu>(1.0));
}
status = in_dev->ToGPU(q, in.data());

for(int i = 0; i < weight_sz; i++)
{
weight[i] = RAN_GEN<Tgpu>(static_cast<Tgpu>(0.0), static_cast<Tgpu>(1.0));
weight[i] = prng::gen_A_to_B<Tgpu>(static_cast<Tgpu>(0.0), static_cast<Tgpu>(1.0));
}
status = weight_dev->ToGPU(q, weight.data());

for(int i = 0; i < bias_sz; i++)
{
bias[i] = RAN_GEN<Tgpu>(static_cast<Tgpu>(0.0), static_cast<Tgpu>(1.0));
bias[i] = prng::gen_A_to_B<Tgpu>(static_cast<Tgpu>(0.0), static_cast<Tgpu>(1.0));
}
status = bias_dev->ToGPU(q, bias.data());

Expand Down
2 changes: 1 addition & 1 deletion fin
Submodule fin updated from b2f3f4 to 26b5c3
17 changes: 15 additions & 2 deletions include/miopen/miopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ typedef enum
miopenStatusVersionMismatch = 10, /*!< Version mismatch of the supplied binary data argment. */
} miopenStatus_t;

#ifdef MIOPEN_BETA_API
typedef enum
{
miopenF8RoundingModeStandard = 0,
miopenF8RoundingModeStochastic = 1,
} miopenF8RoundingMode_t;
#endif

/*! @brief Get character string for an error code.
*
Expand Down Expand Up @@ -354,9 +356,14 @@ typedef enum
4, /*!< Pack of four 8-bit int points in NCHW_VECT_C format (Partially supported) */
miopenBFloat16 = 5, /*!< 16-bit binary floating point (8-bit exponent, 7-bit fraction)
(Partially supported) */
miopenDouble = 6, /*!< 64-bit floating point (Partially supported) */
miopenDouble = 6, /*!< 64-bit floating point (Partially supported) */
#ifdef MIOPEN_BETA_API
miopenFloat8 = 7,
miopenBFloat8 = 8
miopenBFloat8 = 8,
#else
// miopenReserved1 = 7,
// miopenReserved2 = 8,
#endif
cderb marked this conversation as resolved.
Show resolved Hide resolved
} miopenDataType_t;

/*! @ingroup tensor
Expand Down Expand Up @@ -601,11 +608,15 @@ typedef enum
MIOPEN_CONVOLUTION_ATTRIB_DETERMINISTIC =
1, /*!< Restrict MIOpen convolutions to kernels which produce numerically deterministic
results. 0 - disabled (default), 1 - enabled >*/
#ifdef MIOPEN_BETA_API
cderb marked this conversation as resolved.
Show resolved Hide resolved
MIOPEN_CONVOLUTION_ATTRIB_FP8_ROUNDING_MODE =
2, /*!<Specifies the rounding mode for the 8-bit floating data types. Currently, two
rounding modes are supported miopenF8RoundingModeStandard and
miopenF8RoundingModeStochastic. These are listed as part of the miopenF8RoundingMode_t
enum.>*/
#else
// miopenReserved1 = 2,
#endif
} miopenConvolutionAttrib_t;

/** @addtogroup tensor
Expand Down Expand Up @@ -723,6 +734,7 @@ MIOPEN_EXPORT miopenStatus_t miopenSetTensorDescriptor(miopenTensorDescriptor_t
const int* dimsA,
const int* stridesA);

#ifdef MIOPEN_BETA_API
/*! @brief Set the tensor cast type
*
* For tensors where the cast_type attribute is set, the tensor elements would be converted to the
Expand All @@ -734,6 +746,7 @@ MIOPEN_EXPORT miopenStatus_t miopenSetTensorDescriptor(miopenTensorDescriptor_t
*/
MIOPEN_EXPORT miopenStatus_t miopenSetTensorCastType(miopenTensorDescriptor_t tensorDesc,
miopenDataType_t cast_type);
#endif

/*! @brief Set shape of N-dimensional tensor
*
Expand Down
4 changes: 2 additions & 2 deletions src/include/miopen/layernorm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ miopenStatus_t LayerNormForward(const Handle& handle,
const TensorDescriptor& rstdDesc,
Data_t rstd,
miopenLayerNormMode_t mode,
const float epsilon,
const int32_t normalized_dim);
float epsilon,
int32_t normalized_dim);

} // namespace miopen
#endif // _MIOPEN_LAYERNORM_HPP_
Expand Down
4 changes: 2 additions & 2 deletions src/layer_norm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ miopenStatus_t LayerNormForward(const Handle& handle,
const TensorDescriptor& rstdDesc,
Data_t rstd,
miopenLayerNormMode_t mode,
const float epsilon,
const int32_t normalized_dim)
float epsilon,
int32_t normalized_dim)
{
if(x == nullptr || y == nullptr)
{
Expand Down
6 changes: 3 additions & 3 deletions src/solver/batchnorm/backward_ck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ static bool CheckCKApplicability(const miopen::batchnorm::ProblemDescription& pr

#endif

bool BnCKBwdBackward::IsApplicable(const ExecutionContext& ctx,
bool BnCKBwdBackward::IsApplicable(const ExecutionContext& context,
const miopen::batchnorm::ProblemDescription& bn_problem) const
{
#if !MIOPEN_BACKEND_HIP || !MIOPEN_USE_COMPOSABLEKERNEL
std::ignore = ctx;
std::ignore = context;
std::ignore = fdesc_problem;
return false;
#else
if(miopen::IsDisabled(MIOPEN_DEBUG_CONV_CK_BN_BACK{}))
return false;
if(!bn_problem.IsLayoutNHWC())
return false;
if(!ck_utility::is_ck_supported_hardware(ctx.GetStream()))
if(!ck_utility::is_ck_supported_hardware(context.GetStream()))
return false;
if(bn_problem.GetXDesc().GetType() != bn_problem.GetScaleBiasDiffDesc().GetType())
return false;
Expand Down