diff options
-rw-r--r-- | reference_model/include/func_config.h | 17 | ||||
-rw-r--r-- | reference_model/src/ops/control_flow.cc | 16 | ||||
-rw-r--r-- | reference_model/src/ops/custom.cc | 11 | ||||
-rw-r--r-- | reference_model/src/ops/data_layout.cc | 2 | ||||
-rw-r--r-- | setup.cfg | 1 | ||||
m--------- | thirdparty/serialization_lib | 0 | ||||
-rw-r--r-- | verif/conformance/tosa_ext_profile_ops_info.json | 47 | ||||
-rwxr-xr-x | verif/frameworks/tosa_verif_framework_compiler_runner.py | 9 | ||||
-rw-r--r-- | verif/generator/tosa_test_gen.py | 6 |
9 files changed, 85 insertions, 24 deletions
diff --git a/reference_model/include/func_config.h b/reference_model/include/func_config.h index 97afa82..554f8dc 100644 --- a/reference_model/include/func_config.h +++ b/reference_model/include/func_config.h @@ -1,5 +1,5 @@ -// Copyright (c) 2020-2023, ARM Limited. +// Copyright (c) 2020-2024, ARM Limited. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,15 +21,16 @@ struct tosa_level_t { - int32_t MAX_RANK = 0; - int32_t MAX_KERNEL = 0; - int32_t MAX_STRIDE = 0; - int32_t MAX_SCALE = 0; + int32_t MAX_RANK = 0; + int32_t MAX_KERNEL = 0; + int32_t MAX_STRIDE = 0; + int32_t MAX_SCALE = 0; + int32_t MAX_TENSOR_LIST_SIZE = 0; bool operator!=(const tosa_level_t& rhs) { return !(MAX_RANK == rhs.MAX_RANK && MAX_KERNEL == rhs.MAX_KERNEL && MAX_STRIDE == rhs.MAX_STRIDE && - MAX_SCALE == rhs.MAX_SCALE); + MAX_SCALE == rhs.MAX_SCALE && MAX_TENSOR_LIST_SIZE == rhs.MAX_TENSOR_LIST_SIZE); } }; @@ -60,8 +61,8 @@ struct func_config_t bool float_is_big_endian = false; // Set in arith_util.h by float_is_big_endian() tosa_level_t tosa_level; - static constexpr tosa_level_t EIGHTK = { 6, 8192, 8192, 256 }; - static constexpr tosa_level_t NONE = { 0, 0, 0, 0 }; + static constexpr tosa_level_t EIGHTK = { 6, 8192, 8192, 256, 64 }; + static constexpr tosa_level_t NONE = { 0, 0, 0, 0, 0 }; }; #endif diff --git a/reference_model/src/ops/control_flow.cc b/reference_model/src/ops/control_flow.cc index ac09bbb..4b0553e 100644 --- a/reference_model/src/ops/control_flow.cc +++ b/reference_model/src/ops/control_flow.cc @@ -1,5 +1,5 @@ -// Copyright (c) 2020-2023, ARM Limited. +// Copyright (c) 2020-2024, ARM Limited. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -172,12 +172,17 @@ int OpCondIf::checkTensorAttributes() { ERROR_IF(!tsh, "OpCondIf: tosa serialization handler must not be null"); - ERROR_IF(getInputs().size() < 1, "OpCondIf: must have at least 1 operand"); + int32_t num_inputs = getInputs().size(); + ERROR_IF(num_inputs < 1, "OpCondIf: must have at least 1 operand"); ERROR_IF(inputs[0]->getDtype() != TOSA_REF_TYPE_BOOL || inputs[0]->getRank() != 0, "OpCondIf: invalid tensor dtype=%s, rank=%d", EnumNameTOSAREFTYPE(inputs[0]->getDtype()), inputs[0]->getRank()); + auto tosa_level = g_func_config.tosa_level; + LEVEL_CHECK(num_inputs <= tosa_level.MAX_TENSOR_LIST_SIZE, + "num_inputs should be smaller than or equal to MAX_TENSOR_LIST_SIZE"); + cond = dynamic_cast<TosaReference::Tensor0<bool>*>(inputs[0]); ASSERT_MEM(cond); @@ -315,7 +320,8 @@ int OpWhileLoop::checkTensorAttributes() return 1; } - if (getInputs().size() <= 0) + int32_t num_inputs = getInputs().size(); + if (num_inputs <= 0) { WARNING("OpWhileLoop: must have at least 1 operands"); return 1; @@ -327,6 +333,10 @@ int OpWhileLoop::checkTensorAttributes() return 1; } + auto tosa_level = g_func_config.tosa_level; + LEVEL_CHECK(num_inputs <= tosa_level.MAX_TENSOR_LIST_SIZE, + "num_inputs should be smaller than or equal to MAX_TENSOR_LIST_SIZE"); + auto cond_region = tsh->GetRegionByName(attribute->cond_graph()); auto body_region = tsh->GetRegionByName(attribute->body_graph()); if (cond_region && body_region) diff --git a/reference_model/src/ops/custom.cc b/reference_model/src/ops/custom.cc index 39a6f87..3773592 100644 --- a/reference_model/src/ops/custom.cc +++ b/reference_model/src/ops/custom.cc @@ -1,5 +1,5 @@ -// Copyright (c) 2020, 2023, ARM Limited. +// Copyright (c) 2020, 2023-2024, ARM Limited. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -51,8 +51,15 @@ int OpCustom::checkTensorAttributes() int OpCustom::eval() { + auto inputs = getInputs(); + int32_t num_inputs = inputs.size(); + auto tosa_level = g_func_config.tosa_level; + LEVEL_CHECK(num_inputs <= tosa_level.MAX_TENSOR_LIST_SIZE, + "num_inputs should be smaller than or equal to MAX_TENSOR_LIST_SIZE"); + auto implementation_attrs_vec = attribute->implementation_attrs(); std::string implementation_attrs(implementation_attrs_vec.begin(), implementation_attrs_vec.end()); - custom_op_ptr->eval(getInputs(), getOutputs(), implementation_attrs); + custom_op_ptr->eval(inputs, getOutputs(), implementation_attrs); + return GraphNode::eval(); } diff --git a/reference_model/src/ops/data_layout.cc b/reference_model/src/ops/data_layout.cc index 3e3770e..3b8d13a 100644 --- a/reference_model/src/ops/data_layout.cc +++ b/reference_model/src/ops/data_layout.cc @@ -54,6 +54,8 @@ int OpConcat<Rank, Dtype>::checkTensorAttributes() } int32_t num_inputs = inputs.size(); + LEVEL_CHECK(num_inputs <= tosa_level.MAX_TENSOR_LIST_SIZE, + "num_inputs should be smaller than or equal to MAX_TENSOR_LIST_SIZE"); // output and input must be the same types and rank for (int32_t i = 0; i < num_inputs; i++) @@ -22,6 +22,7 @@ install_requires = numpy flatbuffers == 23.5.26 jsonschema + ml-dtypes python_requires = >=3.6 include_package_data = True packages = diff --git a/thirdparty/serialization_lib b/thirdparty/serialization_lib -Subproject 2b4150711fda65e8e92194404e20f28d29215a9 +Subproject 6058ac8b547c470e3ec4a225623b884f98b4409 diff --git a/verif/conformance/tosa_ext_profile_ops_info.json b/verif/conformance/tosa_ext_profile_ops_info.json index c0ef593..f5329b8 100644 --- a/verif/conformance/tosa_ext_profile_ops_info.json +++ b/verif/conformance/tosa_ext_profile_ops_info.json @@ -2252,7 +2252,8 @@ "const": { "group": "data_nodes", "support_for": [ - "lazy_data_gen" + "lazy_data_gen", + "stable_random_gen" ], "generation": { "tosa-bi": { @@ -2297,6 +2298,7 @@ "supports_all": [ "tosa-mi" ], + "selector": "tosa-mi", "no_negative_tests": "true", "generator_args": [ [ @@ -2307,6 +2309,8 @@ "--fp-values-range", "-max,max", "--target-rank", + "0", + "--target-rank", "1", "2", "3" @@ -2322,7 +2326,10 @@ "1,16", "--target-rank", "4", - "5" + "--target-rank", + "5", + "--target-rank", + "6" ], [ "--target-dtype", @@ -2339,6 +2346,7 @@ "supports_all": [ "tosa-ext-bf16" ], + "selector": "tosa-mi", "no_negative_tests": "true", "generator_args": [ [ @@ -2347,6 +2355,8 @@ "--fp-values-range", "-max,max", "--target-rank", + "0", + "--target-rank", "1", "2", "3" @@ -2360,7 +2370,10 @@ "1,16", "--target-rank", "4", - "5" + "--target-rank", + "5", + "--target-rank", + "6" ] ] }, @@ -2368,6 +2381,7 @@ "supports_all": [ "tosa-ext-fp8e4m3" ], + "selector": "tosa-mi", "no_negative_tests": "true", "from_version": "v0.100.0", "generator_args": [ @@ -2391,6 +2405,7 @@ "supports_all": [ "tosa-ext-fp8e5m2" ], + "selector": "tosa-mi", "no_negative_tests": "true", "from_version": "v0.100.0", "generator_args": [ @@ -2443,6 +2458,9 @@ "shape", "type" ] + }, + "tosa-mi": { + "generator_select": "true" } } }, @@ -4697,6 +4715,7 @@ "tosa-ext-bf16" ], "no_negative_tests": "true", + "selector": "tosa-mi", "generator_args": [ [ "--target-dtype", @@ -4730,13 +4749,18 @@ "shape", "type" ] + }, + "tosa-mi": { + "generator_select": "true" } } }, "identity": { "group": "data_nodes", "support_for": [ - "lazy_data_gen" + "lazy_data_gen", + "stable_random_gen", + "random_const_inputs" ], "generation": { "tosa-bi": { @@ -4785,6 +4809,7 @@ "supports_all": [ "tosa-mi" ], + "selector": "tosa-mi", "no_negative_tests": "true", "generator_args": [ [ @@ -4796,6 +4821,8 @@ "--tensor-dim-range", "1,67", "--target-rank", + "0", + "--target-rank", "1", "2", "3" @@ -4810,7 +4837,10 @@ "1,19", "--target-rank", "4", - "5" + "--target-rank", + "5", + "--target-rank", + "6" ], [ "--target-dtype", @@ -4837,6 +4867,8 @@ "--tensor-dim-range", "1,67", "--target-rank", + "0", + "--target-rank", "1", "2", "3" @@ -4850,7 +4882,10 @@ "1,19", "--target-rank", "4", - "5" + "--target-rank", + "5", + "--target-rank", + "6" ] ] }, diff --git a/verif/frameworks/tosa_verif_framework_compiler_runner.py b/verif/frameworks/tosa_verif_framework_compiler_runner.py index 86e3c01..070df15 100755 --- a/verif/frameworks/tosa_verif_framework_compiler_runner.py +++ b/verif/frameworks/tosa_verif_framework_compiler_runner.py @@ -324,7 +324,7 @@ def compile_dynamic_model( def convert_shape_tuple_to_string(tup): string = "" for dim in tup: - string = string + str(dim) + "," + string = string + str(dim) + "x" # skip the last `,` character. return string[0:-1] @@ -332,7 +332,7 @@ def compile_dynamic_model( if not isinstance(shape, tuple): raise Exception("Only single input is supported currently") - arg0_argument = '"arg0=' + convert_shape_tuple_to_string(shape) + '"' + arg0_argument = '"args=arg0:' + convert_shape_tuple_to_string(shape) + '"' compile_and_shape_infer_cmd = compiler_cmd.copy() compile_and_shape_infer_cmd.extend( @@ -725,6 +725,11 @@ def run_test(args, test_path, framework): ref_model_result_files = list((test_path / flatbuffer_dir).glob("ref_model_*.npy")) ref_model_result = np.load(ref_model_result_files[0]) + if np.issubdtype(tf_result.dtype, np.unsignedinteger) and ( + tf_result.dtype != ref_model_result.dtype + ): + ref_model_result = ref_model_result.astype(tf_result.dtype) + assert ( tf_result.dtype == ref_model_result.dtype ), f"Numpy type mismatch {tf_result.dtype} != {ref_model_result.dtype} when comparing result" diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py index beb3da3..d982508 100644 --- a/verif/generator/tosa_test_gen.py +++ b/verif/generator/tosa_test_gen.py @@ -2062,7 +2062,7 @@ class TosaTestGen: attr = ts.TosaSerializerAttribute() # write empty scale/offset/border into ResizeAttribute - attr.ResizeAttribute([], [], [], mode) + attr.ResizeAttribute(mode) self.ser.addOperator(op["op"], input_list, output_list, attr) compliance = self.tensorComplianceMetaData( @@ -4707,7 +4707,7 @@ class TosaTestGen: TosaArgGen.agNone, ), "types": TYPE_FIB + [DType.INT48, DType.FP8E4M3, DType.FP8E5M2], - "data_gen": PSEUDO_RANDOM_DATAGEN, + "data_gen": PR_FS_DATAGEN, }, "identity": { "op": Op.IDENTITY, @@ -4719,7 +4719,7 @@ class TosaTestGen: TosaArgGen.agNone, ), "types": TYPE_FIB + [DType.INT4, DType.INT48], - "data_gen": PSEUDO_RANDOM_DATAGEN, + "data_gen": PR_FS_DATAGEN, }, # Scatter/Gather "gather": { |