mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-05 22:22:27 +00:00
This commit is contained in:
27
example/ck_tile/21_elementwise/elementwise_common.hpp
Normal file
27
example/ck_tile/21_elementwise/elementwise_common.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <variant>
|
||||
#include "ck_tile/core/arch/arch.hpp"
|
||||
|
||||
auto string_to_datatype(const std::string& datatype)
|
||||
{
|
||||
using PrecVariant = std::variant<ck_tile::half_t, ck_tile::bf16_t, float>;
|
||||
|
||||
if(datatype == "fp16")
|
||||
{
|
||||
return PrecVariant{ck_tile::half_t{}};
|
||||
}
|
||||
else if(datatype == "bf16")
|
||||
{
|
||||
return PrecVariant{ck_tile::bf16_t{}};
|
||||
}
|
||||
else if(datatype == "fp32")
|
||||
{
|
||||
return PrecVariant{float{}};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Unsupported data type: " + datatype);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user