From 1adff8301ac7e4933382549ad22b3b47cdb01eda Mon Sep 17 00:00:00 2001 From: evacha01 Date: Wed, 6 Mar 2024 17:33:44 +0000 Subject: Add INT48 and INT4 datatype support to IDENTITY Added support to ref model and testing Signed-off-by: evacha01 Change-Id: Iece53d07c8986332fdd8f1ce5ed6265349df1b6a --- reference_model/src/ops/data_nodes.cc | 2 ++ reference_model/src/ops/op_factory.cc | 2 ++ verif/conformance/tosa_base_profile_ops_info.json | 8 ++++++++ verif/generator/tosa_test_gen.py | 4 +++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/reference_model/src/ops/data_nodes.cc b/reference_model/src/ops/data_nodes.cc index 64001a9..8b480ee 100644 --- a/reference_model/src/ops/data_nodes.cc +++ b/reference_model/src/ops/data_nodes.cc @@ -100,9 +100,11 @@ int OpIdentity::eval() DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP16); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, BF16); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP32); +DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT4); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT8); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT16); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT32); +DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT48); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, BOOL); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP64); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP8E4M3); diff --git a/reference_model/src/ops/op_factory.cc b/reference_model/src/ops/op_factory.cc index 1891ff4..5dc375d 100644 --- a/reference_model/src/ops/op_factory.cc +++ b/reference_model/src/ops/op_factory.cc @@ -569,8 +569,10 @@ GraphNode* OpFactory::newOp(SubgraphTraverser* sgt, DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, BF16); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP32); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT32); + DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT4); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT8); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT16); + DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, INT48); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, BOOL); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP64); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpIdentity, FP8E4M3); diff --git a/verif/conformance/tosa_base_profile_ops_info.json b/verif/conformance/tosa_base_profile_ops_info.json index c8f3442..25a6076 100644 --- a/verif/conformance/tosa_base_profile_ops_info.json +++ b/verif/conformance/tosa_base_profile_ops_info.json @@ -1794,6 +1794,8 @@ "no_negative_tests": "true", "generator_args": [ [ + "--target-dtype", + "int4", "--target-dtype", "int8", "--target-dtype", @@ -1801,6 +1803,8 @@ "--target-dtype", "int32", "--target-dtype", + "int48", + "--target-dtype", "bool", "--tensor-dim-range", "1,61", @@ -1812,6 +1816,8 @@ "3" ], [ + "--target-dtype", + "int4", "--target-dtype", "int8", "--target-dtype", @@ -1819,6 +1825,8 @@ "--target-dtype", "int32", "--target-dtype", + "int48", + "--target-dtype", "bool", "--tensor-dim-range", "1,15", diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py index a1f54c6..4309024 100644 --- a/verif/generator/tosa_test_gen.py +++ b/verif/generator/tosa_test_gen.py @@ -191,6 +191,8 @@ class TosaTestGen: if dtype == DType.BOOL: return np.bool_(self.rng.choice(a=[False, True], size=shape)) + elif dtype == DType.INT4: + return np.int8(self.rng.integers(low=low, high=high, size=shape)) elif dtype == DType.INT8: return np.int8(self.rng.integers(low=low, high=high, size=shape)) elif dtype == DType.UINT8: @@ -4652,7 +4654,7 @@ class TosaTestGen: TosaTensorValuesGen.tvgLazyGenDefault, TosaArgGen.agNone, ), - "types": TYPE_FIB, + "types": TYPE_FIB + [DType.INT4, DType.INT48], "data_gen": { "fp": (gtu.DataGenType.PSEUDO_RANDOM,), }, -- cgit v1.2.1