diff options
author | Jeremy Johnson <jeremy.johnson@arm.com> | 2022-09-27 13:50:00 +0100 |
---|---|---|
committer | Jeremy Johnson <jeremy.johnson@arm.com> | 2022-10-13 18:21:15 +0100 |
commit | bc2a3db54ecee48fe2236f7fc03da8fd07d81ca0 (patch) | |
tree | c3908f23c369fd3226e840f81c3ba4b49cc409a0 /verif/generator | |
parent | 93d4390f9aa5c4369f889e1cd336aa4e809ff6a7 (diff) | |
download | reference_model-bc2a3db54ecee48fe2236f7fc03da8fd07d81ca0.tar.gz |
Rename FLOAT type to FP32
Update tensor operations naming to state input type as TxT in
all cases. Effects CONV2D, CONV3D, DEPTHWISE_CONV2D,
FULLY_CONNECTED, TRANSPOSE_CONV2D.
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Change-Id: Ic959acfcb3aa0a910b33b774a5a85fac08219205
Diffstat (limited to 'verif/generator')
-rw-r--r-- | verif/generator/tosa_arg_gen.py | 38 | ||||
-rw-r--r-- | verif/generator/tosa_error_if.py | 56 | ||||
-rw-r--r-- | verif/generator/tosa_test_gen.py | 148 | ||||
-rw-r--r-- | verif/generator/tosa_utils.py | 25 |
4 files changed, 129 insertions, 138 deletions
diff --git a/verif/generator/tosa_arg_gen.py b/verif/generator/tosa_arg_gen.py index e0c6cf0..791fbf7 100644 --- a/verif/generator/tosa_arg_gen.py +++ b/verif/generator/tosa_arg_gen.py @@ -776,7 +776,7 @@ class TosaTensorValuesGen: ), "Op.MUL must have 2 placeholders, 0 consts" tens = [] - if dtypeList[0] in (DType.FP16, DType.FLOAT): + if dtypeList[0] in (DType.FP16, DType.FP32): tens.extend(testGen.buildPlaceholderTensors(shapeList[:], dtypeList[:])) else: placeholders = [] @@ -1106,10 +1106,10 @@ class TosaArgGen: @staticmethod def agFullyConnected(testGen, opName, shapeList, dtypes, error_name=None): - if isinstance(dtypes, list) or isinstance(dtypes, tuple): - input_dtype = dtypes[0] - else: - input_dtype = dtypes + assert isinstance(dtypes, list) or isinstance( + dtypes, tuple + ), f"{dtypes} unexpected" + input_dtype = dtypes[0] if error_name == ErrorIf.WrongOutputType: accum_dtype = get_wrong_output_type(opName, testGen.rng, input_dtype) @@ -1129,9 +1129,9 @@ class TosaArgGen: elif dtype == DType.INT16: accum_dtypes = [DType.INT48] elif dtype == DType.FP16: - accum_dtypes = [DType.FP16, DType.FLOAT] - elif dtype == DType.FLOAT: - accum_dtypes = [DType.FLOAT] + accum_dtypes = [DType.FP16, DType.FP32] + elif dtype == DType.FP32: + accum_dtypes = [DType.FP32] elif error_name is None: assert False, f"Invalid I/O DType for MatMul: {DTypeNames[dtype]}" @@ -1245,7 +1245,7 @@ class TosaArgGen: if dtype in [DType.BOOL, DType.INT8, DType.INT16, DType.INT32]: pad_const_int = testGen.getRandNumberDType(dtype) pad_const_fp = 0 - elif dtype in (DType.FP16, DType.FLOAT): + elif dtype in (DType.FP16, DType.FP32): pad_const_int = 0 pad_const_fp = testGen.getRandNumberDType(dtype) else: @@ -1303,9 +1303,9 @@ class TosaArgGen: elif dtype == DType.INT8 or dtype == DType.INT16: accum_dtypes = [DType.INT32] elif dtype == DType.FP16: - accum_dtypes = [DType.FP16, DType.FLOAT] - elif dtype == DType.FLOAT: - accum_dtypes = [DType.FLOAT] + accum_dtypes = [DType.FP16, DType.FP32] + elif dtype == DType.FP32: + accum_dtypes = [DType.FP32] elif error_name is None: assert False, f"Invalid I/O DType for pooling: {DTypeNames[dtype]}" else: @@ -1408,20 +1408,20 @@ class TosaArgGen: if error_name == ErrorIf.WrongOutputType: dtypeList = TosaErrorIfArgGen.eiCastErrorIf(testGen, inDtype) elif inDtype == DType.INT8: - dtypeList = [DType.BOOL, DType.INT16, DType.INT32, DType.FLOAT] + dtypeList = [DType.BOOL, DType.INT16, DType.INT32, DType.FP32] elif inDtype == DType.INT16: - dtypeList = [DType.BOOL, DType.INT8, DType.INT32, DType.FLOAT] + dtypeList = [DType.BOOL, DType.INT8, DType.INT32, DType.FP32] elif inDtype == DType.INT32: - dtypeList = [DType.BOOL, DType.INT8, DType.INT16, DType.FLOAT] + dtypeList = [DType.BOOL, DType.INT8, DType.INT16, DType.FP32] elif inDtype == DType.BOOL: dtypeList = [DType.INT8, DType.INT16, DType.INT32] elif inDtype == DType.FP16: dtypeList = [DType.INT8, DType.INT16, DType.INT32] - elif inDtype == DType.FLOAT: + elif inDtype == DType.FP32: dtypeList = [DType.INT8, DType.INT16, DType.INT32] elif error_name == ErrorIf.WrongInputType: # Pick some potentially correct output type for incorrect input type - dtypeList = [DType.BOOL, DType.INT8, DType.INT16, DType.FLOAT] + dtypeList = [DType.BOOL, DType.INT8, DType.INT16, DType.FP32] else: raise Exception("Unexpected input dtype: {}".format(inDtype)) @@ -1826,8 +1826,8 @@ class TosaArgGen: outputDTypeList = [DType.INT48] elif dtype == DType.FP16: outputDTypeList = [DType.FP16] - elif dtype == DType.FLOAT: - outputDTypeList = [DType.FLOAT] + elif dtype == DType.FP32: + outputDTypeList = [DType.FP32] elif error_name == ErrorIf.WrongInputType: # If an incorrect input type is used then we set a 'correct' # output type to avoid other errors diff --git a/verif/generator/tosa_error_if.py b/verif/generator/tosa_error_if.py index a766803..abe1a97 100644 --- a/verif/generator/tosa_error_if.py +++ b/verif/generator/tosa_error_if.py @@ -119,7 +119,7 @@ class TosaErrorIfArgGen: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, DType.FP16, ) elif mode == ResizeMode.NEAREST and dtype == DType.INT16: @@ -128,7 +128,7 @@ class TosaErrorIfArgGen: DType.INT8, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, DType.FP16, ) elif mode == ResizeMode.BILINEAR and dtype == DType.INT8: @@ -137,7 +137,7 @@ class TosaErrorIfArgGen: DType.INT8, DType.INT16, DType.INT48, - DType.FLOAT, + DType.FP32, DType.FP16, ) elif mode == ResizeMode.BILINEAR and dtype == DType.INT16: @@ -146,7 +146,7 @@ class TosaErrorIfArgGen: DType.INT8, DType.INT16, DType.INT32, - DType.FLOAT, + DType.FP32, DType.FP16, ) elif dtype == DType.FP16: @@ -156,9 +156,9 @@ class TosaErrorIfArgGen: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ) - elif dtype == DType.FLOAT: + elif dtype == DType.FP32: incorrect_types = ( DType.INT4, DType.INT8, @@ -299,8 +299,8 @@ class TosaErrorIfArgGen: @staticmethod def eiCastErrorIf(testGen, input_dtype): - if input_dtype in [DType.BOOL, DType.FP16, DType.FLOAT]: - outputDType = [DType.BOOL, DType.INT48, DType.FP16, DType.FLOAT] + if input_dtype in [DType.BOOL, DType.FP16, DType.FP32]: + outputDType = [DType.BOOL, DType.INT48, DType.FP16, DType.FP32] elif input_dtype in [DType.INT8, DType.INT16, DType.INT32]: outputDType = [DType.INT48] else: @@ -366,6 +366,16 @@ class TosaErrorValidator: } wrong_input_dtypes = list(usableDTypes(excludes=allowed_input_dtypes)) + # Turn the wrong dtypes into required list of types + if op["op"] in [ + Op.FULLY_CONNECTED, + Op.CONV2D, + Op.CONV3D, + Op.DEPTHWISE_CONV2D, + Op.TRANSPOSE_CONV2D, + ]: + wrong_input_dtypes = [[t, t, t] for t in wrong_input_dtypes] + if op["op"] == Op.CLAMP: wrong_input_dtypes.remove(DType.INT48) @@ -415,7 +425,7 @@ class TosaErrorValidator: and output_dtype != DType.INT48 ) or (input_dtype == DType.FP16 and output_dtype != DType.FP16) - or (input_dtype == DType.FLOAT and output_dtype != DType.FLOAT) + or (input_dtype == DType.FP32 and output_dtype != DType.FP32) ): error_result = True @@ -430,28 +440,28 @@ class TosaErrorValidator: or (input_dtype == DType.INT16 and output_dtype != DType.INT48) or ( input_dtype == DType.FP16 - and output_dtype not in (DType.FP16, DType.FLOAT) + and output_dtype not in (DType.FP16, DType.FP32) ) - or (input_dtype == DType.FLOAT and output_dtype != DType.FLOAT) + or (input_dtype == DType.FP32 and output_dtype != DType.FP32) ): error_result = True elif op["op"] == Op.ARGMAX: if ( - input_dtype in [DType.INT8, DType.INT16, DType.FP16, DType.FLOAT] + input_dtype in [DType.INT8, DType.INT16, DType.FP16, DType.FP32] and output_dtype != DType.INT32 ): error_result = True elif op["op"] == Op.MUL: if ( - input_dtype not in (DType.FP16, DType.FLOAT) + input_dtype not in (DType.FP16, DType.FP32) and output_dtype != DType.INT32 ): error_result = True elif input_dtype == DType.FP16 and output_dtype != DType.FP16: error_result = True - elif input_dtype == DType.FLOAT and output_dtype != DType.FLOAT: + elif input_dtype == DType.FP32 and output_dtype != DType.FP32: error_result = True elif op["op"] == Op.TABLE: @@ -477,7 +487,7 @@ class TosaErrorValidator: DType.BOOL, DType.INT16, DType.INT32, - DType.FLOAT, + DType.FP32, DType.FP16, ] ) @@ -488,7 +498,7 @@ class TosaErrorValidator: DType.BOOL, DType.INT8, DType.INT32, - DType.FLOAT, + DType.FP32, DType.FP16, ] ) @@ -499,7 +509,7 @@ class TosaErrorValidator: DType.BOOL, DType.INT8, DType.INT16, - DType.FLOAT, + DType.FP32, DType.FP16, ] ) @@ -508,7 +518,7 @@ class TosaErrorValidator: and output_dtype not in [DType.INT8, DType.INT16, DType.INT32] ) or ( - input_dtype == DType.FLOAT + input_dtype == DType.FP32 and output_dtype not in [DType.INT8, DType.INT16, DType.INT32] ) ): @@ -526,9 +536,9 @@ class TosaErrorValidator: or input_dtype == DType.INT16 and output_dtype != DType.INT48 or input_dtype == DType.FP16 - and output_dtype not in (DType.FP16, DType.FLOAT) - or input_dtype == DType.FLOAT - and output_dtype != DType.FLOAT + and output_dtype not in (DType.FP16, DType.FP32) + or input_dtype == DType.FP32 + and output_dtype != DType.FP32 ): error_result = True # invalid input types are ignored, to avoid reporting multiple errors @@ -2306,12 +2316,12 @@ class TosaInvalidValidator: not (input_dtype == DType.INT8 and output_dtype == DType.INT32) and not (input_dtype == DType.INT16 and output_dtype == DType.INT48) and not (input_dtype == DType.FP16 and output_dtype == DType.FP16) - and not (input_dtype == DType.FLOAT and output_dtype == DType.FLOAT) + and not (input_dtype == DType.FP32 and output_dtype == DType.FP32) ) elif mode == ResizeMode.NEAREST: # Invalid output data type / Invalid input datatype return (input_dtype != output_dtype) or ( - input_dtype not in [DType.INT8, DType.INT16, DType.FP16, DType.FLOAT] + input_dtype not in [DType.INT8, DType.INT16, DType.FP16, DType.FP32] ) else: # Invalid resize mode diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py index 9ff6ec5..78d86cd 100644 --- a/verif/generator/tosa_test_gen.py +++ b/verif/generator/tosa_test_gen.py @@ -13,6 +13,7 @@ from generator.tosa_error_if import ErrorIf from generator.tosa_error_if import TosaErrorIfArgGen from generator.tosa_error_if import TosaErrorValidator from generator.tosa_error_if import TosaInvalidValidator +from generator.tosa_utils import DTYPE_ATTRIBUTES from generator.tosa_utils import MAX_RESIZE_DIMENSION from generator.tosa_utils import usableDTypes from tosa.DType import DType @@ -83,7 +84,7 @@ class TosaTestGen: ) elif dtype == DType.FP16: return np.float16(self.rng.random(size=shape)) - elif dtype == DType.FLOAT: + elif dtype == DType.FP32: return np.float32(self.rng.random(size=shape)) else: raise Exception("Unrecognized Dtype: {}".format(dtype)) @@ -128,7 +129,7 @@ class TosaTestGen: return np.int32(self.rng.integers(low=low, high=high, size=1))[0] def getRandNumberDType(self, dtype): - if dtype == DType.FLOAT: + if dtype == DType.FP32: return self.rng.random() elif dtype == DType.FP16: rand_f32 = self.rng.random() @@ -162,58 +163,26 @@ class TosaTestGen: return "x".join(sStr) - def typeStr(self, t): - if isinstance(t, list): - assert len(t) >= 2 - return "{}x{}".format(self.typeStr(t[0]), self.typeStr(t[1])) + def typeStr(self, dtype): + if isinstance(dtype, list) or isinstance(dtype, tuple): + assert len(dtype) >= 2 + strs = [self.typeStr(t) for t in dtype] + # Limit types to the first 2 as the 3rd is the accumulator + return "x".join(strs[:2]) else: - if t == DType.BOOL: - return "b" - elif t == DType.INT4: - return "i4" - elif t == DType.INT8: - return "i8" - elif t == DType.UINT8: - return "u8" - elif t == DType.INT16: - return "i16" - elif t == DType.UINT16: - return "u16" - elif t == DType.INT32: - return "i32" - elif t == DType.INT48: - return "i48" - elif t == DType.FP16: - return "f16" - elif t == DType.FLOAT: - return "float" + if dtype in DTYPE_ATTRIBUTES: + return DTYPE_ATTRIBUTES[dtype]["str"] else: - raise Exception("Unknown dtype, cannot convert to string: {}".format(t)) + raise Exception( + "Unknown dtype, cannot convert to string: {}".format(dtype) + ) - def typeWidth(self, t): + def typeWidth(self, dtype): """Get the datatype width for data types""" - if t == DType.INT4: - return 4 - elif t == DType.INT8: - return 8 - elif t == DType.UINT8: - return 8 - elif t == DType.INT16: - return 16 - elif t == DType.UINT16: - return 16 - elif t == DType.INT32: - return 32 - elif t == DType.INT48: - return 48 - elif t == DType.FP16: - return 16 - elif t == DType.FLOAT: - return 32 - elif t == DType.BOOL: - return 1 + if dtype in DTYPE_ATTRIBUTES: + return DTYPE_ATTRIBUTES[dtype]["width"] else: - raise Exception(f"Unknown dtype, cannot determine width: {t}") + raise Exception(f"Unknown dtype, cannot determine width: {dtype}") # Argument generators # Returns a list of tuples (stringDescriptor, [build_fcn_arg_list]) @@ -355,7 +324,7 @@ class TosaTestGen: # Special for multiply: # Force the result to INT32 for INT types - if a.dtype not in (DType.FP16, DType.FLOAT): + if a.dtype not in (DType.FP16, DType.FP32): result_tens.setDtype(DType.INT32) if error_name == ErrorIf.WrongOutputType: all_dtypes = [DType.INT8, DType.INT16, DType.INT48] @@ -1074,7 +1043,7 @@ class TosaTestGen: return None attr = ts.TosaSerializerAttribute() - if a.dtype in (DType.FP16, DType.FLOAT): + if a.dtype in (DType.FP16, DType.FP32): attr.ClampAttribute(0, 0, min_val, max_val) else: attr.ClampAttribute(min_val, max_val, 0, 0) @@ -1086,7 +1055,7 @@ class TosaTestGen: result_tens = OutputShaper.unaryOp(self.ser, self.rng, a, error_name) attr = ts.TosaSerializerAttribute() - attr.LeakyReluAttribute(self.getRandNumberDType(DType.FLOAT)) + attr.LeakyReluAttribute(self.getRandNumberDType(DType.FP32)) self.ser.addOperator(op["op"], [a.name], [result_tens.name], attr) return result_tens @@ -1890,7 +1859,7 @@ class TosaTestGen: op["op"], [cond_tens.name, a.name, b.name], [result_tens.name], attr ) - if a.dtype in (DType.FLOAT, DType.FP16, DType.INT32): + if a.dtype in (DType.FP32, DType.FP16, DType.INT32): then_op, else_op = Op.ADD, Op.SUB elif a.dtype in (DType.INT8, DType.INT16): then_op, else_op = Op.LOGICAL_RIGHT_SHIFT, Op.LOGICAL_LEFT_SHIFT @@ -2001,7 +1970,7 @@ class TosaTestGen: if error_name == ErrorIf.CondGraphOutputNotMatchingBool: cond_tens = self.ser.addOutput( - [], self.rng.choice([DType.INT8, DType.INT32, DType.FLOAT]) + [], self.rng.choice([DType.INT8, DType.INT32, DType.FP32]) ) else: cond_tens = self.ser.addOutput([], DType.BOOL) @@ -2429,7 +2398,7 @@ class TosaTestGen: # if not specified, defaults to (1, 4) # 'build_fcn': tuple of the function to (build_operator(), TensorGen function, ArgGen enum) # 'types': array of datatypes to be tested - TYPE_FP = [DType.FLOAT, DType.FP16] + TYPE_FP = [DType.FP32, DType.FP16] TYPE_INT = [DType.INT8, DType.INT16, DType.INT32] # Excludes INT4 TYPE_INT_FP = [ @@ -2437,30 +2406,31 @@ class TosaTestGen: DType.INT16, DType.INT32, DType.FP16, - DType.FLOAT, + DType.FP32, ] # Excludes INT4 TYPE_BOOL = [DType.BOOL] - TYPE_FI32 = [DType.FLOAT, DType.FP16, DType.INT32] # floating-types and INT32 + TYPE_FI32 = [DType.FP32, DType.FP16, DType.INT32] # floating-types and INT32 TYPE_FIB = [ DType.FP16, - DType.FLOAT, + DType.FP32, DType.INT8, DType.INT16, DType.INT32, DType.BOOL, ] - TYPE_FI16 = [DType.FLOAT, DType.INT16] + TYPE_FI16 = [DType.FP32, DType.INT16] - TYPE_NARROW_INT_FP = [DType.INT8, DType.INT16, DType.FP16, DType.FLOAT] + TYPE_NARROW_INT_FP = [DType.INT8, DType.INT16, DType.FP16, DType.FP32] + # List of [Input Type 1, Input Type 2, Accumulator Type] TYPE_CONV = [ [DType.INT8, DType.INT4, DType.INT32], [DType.INT8, DType.INT8, DType.INT32], [DType.INT16, DType.INT8, DType.INT48], [DType.FP16, DType.FP16, DType.FP16], - [DType.FP16, DType.FP16, DType.FLOAT], - DType.FLOAT, + [DType.FP16, DType.FP16, DType.FP32], + [DType.FP32, DType.FP32, DType.FP32], ] DEFAULT_RANK_RANGE = (1, TOSA_TENSOR_MAX_RANK) @@ -3478,7 +3448,7 @@ class TosaTestGen: TosaTensorValuesGen.tvgReduceSum, TosaArgGen.agAxis, ), - "types": (DType.FP16, DType.FLOAT, DType.INT32), + "types": (DType.FP16, DType.FP32, DType.INT32), "error_if_validators": ( TosaErrorValidator.evAxisLargerRank, TosaErrorValidator.evAxisSmallerZero, @@ -3665,7 +3635,7 @@ class TosaTestGen: TosaTensorValuesGen.tvgDefault, None, ), - "types": (DType.INT8, DType.INT16, DType.INT32, DType.FP16, DType.FLOAT), + "types": (DType.INT8, DType.INT16, DType.INT32, DType.FP16, DType.FP32), "error_if_validators": ( TosaErrorValidator.evWrongInputType, TosaErrorValidator.evWrongOutputType, @@ -3706,7 +3676,7 @@ class TosaTestGen: TosaTensorValuesGen.tvgDefault, TosaArgGen.agResize, ), - "types": (DType.INT8, DType.INT16, DType.FP16, DType.FLOAT), + "types": (DType.INT8, DType.INT16, DType.FP16, DType.FP32), "invalid_test_validators": ( TosaInvalidValidator.ivWrongDataTypeOrModeResize, ), @@ -3742,7 +3712,7 @@ class TosaTestGen: ), "types": ( DType.FP16, - DType.FLOAT, + DType.FP32, DType.INT8, DType.INT16, DType.INT32, @@ -3872,7 +3842,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -3901,7 +3871,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -3929,7 +3899,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -3958,7 +3928,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] outputDType = rng.choice(wrong_dtypes) else: @@ -3984,7 +3954,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4016,7 +3986,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([DType.INT32])) outputDType = rng.choice(wrong_dtypes) @@ -4069,7 +4039,7 @@ class OutputShaper: if error_name == ErrorIf.WrongOutputType: if ifm.dtype == DType.FP16: - excludes = [DType.FP16, DType.FLOAT] + excludes = [DType.FP16, DType.FP32] else: excludes = [out_dtype] wrong_dtypes = list(usableDTypes(excludes=excludes)) @@ -4131,7 +4101,7 @@ class OutputShaper: if error_name == ErrorIf.WrongOutputType: if ifm.dtype == DType.FP16: - excludes = [DType.FP16, DType.FLOAT] + excludes = [DType.FP16, DType.FP32] else: excludes = [out_dtype] wrong_dtypes = list(usableDTypes(excludes=excludes)) @@ -4182,7 +4152,7 @@ class OutputShaper: if error_name == ErrorIf.WrongOutputType: if ifm.dtype == DType.FP16: - excludes = [DType.FP16, DType.FLOAT] + excludes = [DType.FP16, DType.FP32] else: excludes = [out_dtype] wrong_dtypes = list(usableDTypes(excludes=excludes)) @@ -4217,7 +4187,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, DType.FP16, ] wrong_dtypes = list(set(all_dtypes) - set([ifm.dtype])) @@ -4255,7 +4225,7 @@ class OutputShaper: DType.INT8, DType.INT16, DType.INT48, - DType.FLOAT, + DType.FP32, ) elif a.dtype == DType.INT16: incorrect_types = ( @@ -4263,9 +4233,9 @@ class OutputShaper: DType.INT8, DType.INT16, DType.INT32, - DType.FLOAT, + DType.FP32, ) - elif a.dtype == DType.FLOAT or a.dtype == DType.FP16: + elif a.dtype == DType.FP32 or a.dtype == DType.FP16: incorrect_types = ( DType.INT4, DType.INT8, @@ -4307,7 +4277,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, } wrong_dtypes = list(all_dtypes - set([input1.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4334,7 +4304,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, DType.FP16, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) @@ -4358,7 +4328,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4376,7 +4346,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4412,7 +4382,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4440,7 +4410,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([a.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4464,7 +4434,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([values.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4491,7 +4461,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes = list(set(all_dtypes) - set([values_in.dtype])) outputDType = rng.choice(wrong_dtypes) @@ -4512,7 +4482,7 @@ class OutputShaper: DType.INT16, DType.INT32, DType.INT48, - DType.FLOAT, + DType.FP32, ] wrong_dtypes.remove(output_dtype) output_dtype = rng.choice(wrong_dtypes) @@ -4619,7 +4589,7 @@ class OutputShaper: if error_name == ErrorIf.WrongOutputType: if ifm.dtype == DType.FP16: - excludes = [DType.FP16, DType.FLOAT] + excludes = [DType.FP16, DType.FP32] else: excludes = [out_dtype] wrong_dtypes = list(usableDTypes(excludes=excludes)) diff --git a/verif/generator/tosa_utils.py b/verif/generator/tosa_utils.py index 7fa31e7..104d9bb 100644 --- a/verif/generator/tosa_utils.py +++ b/verif/generator/tosa_utils.py @@ -5,6 +5,19 @@ from tosa.DType import DType # Maximum dimension size for output and inputs for RESIZE MAX_RESIZE_DIMENSION = 16384 +DTYPE_ATTRIBUTES = { + DType.BOOL: {"str": "b", "width": 1}, + DType.INT4: {"str": "i4", "width": 4}, + DType.INT8: {"str": "i8", "width": 8}, + DType.UINT8: {"str": "u8", "width": 8}, + DType.INT16: {"str": "i16", "width": 16}, + DType.UINT16: {"str": "u16", "width": 16}, + DType.INT32: {"str": "i32", "width": 32}, + DType.INT48: {"str": "i48", "width": 48}, + DType.FP16: {"str": "f16", "width": 16}, + DType.FP32: {"str": "f32", "width": 32}, +} + def valueToName(item, value): """Get the name of an attribute with the given value. @@ -88,10 +101,8 @@ def product(shape): def get_accum_dtype_from_tgTypes(dtypes): # Get accumulate data-type from the test generator's defined types - if isinstance(dtypes, list) or isinstance(dtypes, tuple): - return dtypes[-1] - else: - return dtypes + assert isinstance(dtypes, list) or isinstance(dtypes, tuple) + return dtypes[-1] def get_wrong_output_type(op_name, rng, input_dtype): @@ -102,7 +113,7 @@ def get_wrong_output_type(op_name, rng, input_dtype): DType.INT8, DType.INT16, DType.INT48, - DType.FLOAT, + DType.FP32, DType.FP16, ) elif input_dtype == DType.INT16: @@ -111,10 +122,10 @@ def get_wrong_output_type(op_name, rng, input_dtype): DType.INT8, DType.INT16, DType.INT32, - DType.FLOAT, + DType.FP32, DType.FP16, ) - elif input_dtype == DType.FLOAT or input_dtype == DType.FP16: + elif input_dtype == DType.FP32 or input_dtype == DType.FP16: incorrect_types = ( DType.INT4, DType.INT8, |