aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/ops/type_conversion.h
diff options
context:
space:
mode:
authorJames Ward <james.ward@arm.com>2023-01-23 17:13:37 +0000
committerJames Ward <james.ward@arm.com>2023-01-31 11:45:21 +0000
commit736fd1a7e4083153ccc4cf360b44dd07b6788494 (patch)
tree42f34388dddb504650be0e17dbda8c9073223313 /reference_model/src/ops/type_conversion.h
parent2138a19ae830ec7d9ce5b15f15cbd7a22864bb8f (diff)
downloadreference_model-736fd1a7e4083153ccc4cf360b44dd07b6788494.tar.gz
Create MI tests for Type Conversion: CAST
* Add exclusion regex's to conformance generation Signed-off-by: James Ward <james.ward@arm.com> Change-Id: I15bef7451efd5662065060242d35bd7fa3381487
Diffstat (limited to 'reference_model/src/ops/type_conversion.h')
-rw-r--r--reference_model/src/ops/type_conversion.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/reference_model/src/ops/type_conversion.h b/reference_model/src/ops/type_conversion.h
index b0de30c..e2fc6e2 100644
--- a/reference_model/src/ops/type_conversion.h
+++ b/reference_model/src/ops/type_conversion.h
@@ -136,6 +136,76 @@ private:
FcnType fcn;
};
+template <>
+class CastHelper<DType_FP32, DType_FP16>
+{
+public:
+ using InEigenType = typename GetEigenType<DType_FP32>::type;
+ using OutEigenType = typename GetEigenType<DType_FP16>::type;
+ using FcnType = std::function<OutEigenType(InEigenType)>;
+ CastHelper();
+ const FcnType& get_fcn() const
+ {
+ return fcn;
+ }
+
+private:
+ FcnType fcn;
+};
+
+template <DType InDtype>
+class CastHelper<InDtype, DType_BF16>
+{
+public:
+ using InEigenType = typename GetEigenType<InDtype>::type;
+ using OutEigenType = typename GetEigenType<DType_BF16>::type;
+ using FcnType = std::function<OutEigenType(InEigenType)>;
+ CastHelper();
+ const FcnType& get_fcn() const
+ {
+ return fcn;
+ }
+
+private:
+ FcnType fcn;
+};
+
+template <DType OutDtype>
+class CastHelper<DType_BF16, OutDtype>
+{
+public:
+ using InEigenType = typename GetEigenType<DType_BF16>::type;
+ using OutEigenType = typename GetEigenType<OutDtype>::type;
+ using FcnType = std::function<OutEigenType(InEigenType)>;
+ static constexpr int32_t OutMin = GetQMin<OutDtype>::value;
+ static constexpr int32_t OutMax = GetQMax<OutDtype>::value;
+ CastHelper();
+ const FcnType& get_fcn() const
+ {
+ return fcn;
+ }
+
+private:
+ FcnType fcn;
+};
+
+template <>
+class CastHelper<DType_FP32, DType_BF16>
+{
+public:
+ using InEigenType = typename GetEigenType<DType_FP32>::type;
+ using OutEigenType = typename GetEigenType<DType_BF16>::type;
+ using FcnType = std::function<OutEigenType(InEigenType)>;
+ CastHelper();
+ const FcnType& get_fcn() const
+ {
+ return fcn;
+ }
+
+private:
+ FcnType fcn;
+};
+
template <DType InDtype>
class CastHelper<InDtype, DType_FP32>
{
@@ -153,6 +223,40 @@ private:
FcnType fcn;
};
+template <>
+class CastHelper<DType_FP16, DType_FP32>
+{
+public:
+ using InEigenType = typename GetEigenType<DType_FP16>::type;
+ using OutEigenType = typename GetEigenType<DType_FP32>::type;
+ using FcnType = std::function<OutEigenType(InEigenType)>;
+ CastHelper();
+ const FcnType& get_fcn() const
+ {
+ return fcn;
+ }
+
+private:
+ FcnType fcn;
+};
+
+template <>
+class CastHelper<DType_BF16, DType_FP32>
+{
+public:
+ using InEigenType = typename GetEigenType<DType_BF16>::type;
+ using OutEigenType = typename GetEigenType<DType_FP32>::type;
+ using FcnType = std::function<OutEigenType(InEigenType)>;
+ CastHelper();
+ const FcnType& get_fcn() const
+ {
+ return fcn;
+ }
+
+private:
+ FcnType fcn;
+};
+
template <DType OutDtype>
class CastHelper<DType_FP32, OutDtype>
{