aboutsummaryrefslogtreecommitdiff
path: root/verif
diff options
context:
space:
mode:
authorJeremy Johnson <jeremy.johnson@arm.com>2023-09-14 16:43:48 +0100
committerJeremy Johnson <jeremy.johnson@arm.com>2023-10-02 11:33:03 +0100
commitbb0935f868a5ab09403cf3628848655b06ac1dec (patch)
tree259a157d7c32a6134cbc83d2a2961c7f2e3529fa /verif
parent62737b15a30e431dcefaaf28001f304e46598fc6 (diff)
downloadreference_model-bb0935f868a5ab09403cf3628848655b06ac1dec.tar.gz
Update verifier library data-type support
Make compliance meta-data data-type required for all. Add data-type checking for all verifier modes. Add initial enum support for new ROUND compliance mode. Improve print out information from library. Use numpy ctypes.data_as to get f16 support compared to ctypes_lib. Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Ie983ba4ea958a88556f30c09b3ebc19cd9ec96b7
Diffstat (limited to 'verif')
-rw-r--r--verif/checker/verifier.py2
-rw-r--r--verif/generator/tosa_test_gen.py14
-rw-r--r--verif/generator/tosa_utils.py1
-rw-r--r--verif/tests/test_schemavalidation.py6
-rw-r--r--verif/tests/test_tosa_verifier.py3
5 files changed, 15 insertions, 11 deletions
diff --git a/verif/checker/verifier.py b/verif/checker/verifier.py
index 06ffcfb..684bea3 100644
--- a/verif/checker/verifier.py
+++ b/verif/checker/verifier.py
@@ -72,7 +72,7 @@ class VerifierLibrary:
ct.cast(shape, ct.POINTER(ct.c_int32)),
ct.c_int32(len(array.shape)),
ct.c_int(NUMPY_DATATYPE_TO_CLIENTTYPE[array.dtype]["type"]),
- ct.cast(np.ctypeslib.as_ctypes(array), ct.POINTER(ct.c_uint8)),
+ array.ctypes.data_as(ct.POINTER(ct.c_uint8)),
ct.c_size_t(size_in_bytes),
)
return tensor
diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py
index d15f785..8beb2ae 100644
--- a/verif/generator/tosa_test_gen.py
+++ b/verif/generator/tosa_test_gen.py
@@ -282,17 +282,21 @@ class TosaTestGen:
)
def tensorComplianceMetaData(self, op, argsDict, outputTensor, errorName):
- if errorName:
- # No compliance for error tests
+ if errorName or not gtu.dtypeIsFloat(outputTensor.dtype):
+ # No compliance for error tests or integer tests currently
return None
+
# Create compliance meta data for expected output tensor
- compliance_tens = {"mode": None}
+ compliance_tens = {
+ "mode": None,
+ # Data type is needed for all FP runs, as refmodel precise mode produces FP64
+ "data_type": gtu.DTYPE_ATTRIBUTES[outputTensor.dtype]["json"],
+ }
if argsDict["dg_type"] == gtu.DataGenType.DOT_PRODUCT:
mode = gtu.ComplianceMode.DOT_PRODUCT
compliance_tens["dot_product_info"] = {
"s": argsDict["s"],
"ks": argsDict["ks"],
- "data_type": gtu.DTYPE_ATTRIBUTES[outputTensor.dtype]["json"],
}
elif argsDict["dg_type"] == gtu.DataGenType.OP_SPECIAL:
mode = gtu.ComplianceMode.FP_SPECIAL
@@ -301,6 +305,8 @@ class TosaTestGen:
compliance_tens["ulp_info"] = {"ulp": op["compliance"]["ulp"]}
elif op["op"] == Op.REDUCE_PRODUCT:
mode = gtu.ComplianceMode.REDUCE_PRODUCT
+ elif op["op"] in (Op.ADD, Op.MUL, Op.SUB, Op.CEIL, Op.FLOOR, Op.CAST):
+ mode = gtu.ComplianceMode.ROUND
else:
mode = gtu.ComplianceMode.EXACT
compliance_tens["mode"] = gtu.ComplianceMode(mode).name
diff --git a/verif/generator/tosa_utils.py b/verif/generator/tosa_utils.py
index 75a0df5..dddc320 100644
--- a/verif/generator/tosa_utils.py
+++ b/verif/generator/tosa_utils.py
@@ -38,6 +38,7 @@ class ComplianceMode(IntEnum):
ULP = 2
FP_SPECIAL = 3
REDUCE_PRODUCT = 4
+ ROUND = 5
class DataGenType(IntEnum):
diff --git a/verif/tests/test_schemavalidation.py b/verif/tests/test_schemavalidation.py
index 1ecd3ee..664e3a4 100644
--- a/verif/tests/test_schemavalidation.py
+++ b/verif/tests/test_schemavalidation.py
@@ -72,11 +72,7 @@ def test_schemavalidation_full_unexpected():
def test_schemavalidation_compliance_minimal():
json = {
"version": "v",
- "tensors": {
- "output": {
- "mode": "mode",
- }
- },
+ "tensors": {"output": {"mode": "mode", "data_type": "type"}},
}
sv = sch.TestDescSchemaValidator()
diff --git a/verif/tests/test_tosa_verifier.py b/verif/tests/test_tosa_verifier.py
index 996939c..864fa9c 100644
--- a/verif/tests/test_tosa_verifier.py
+++ b/verif/tests/test_tosa_verifier.py
@@ -40,7 +40,8 @@ JSON_COMPLIANCE_DOT_PRODUCT = {
"tensors": {
"output1": {
"mode": "DOT_PRODUCT",
- "dot_product_info": {"ks": 1000, "s": 0, "data_type": "FP32"},
+ "data_type": "FP32",
+ "dot_product_info": {"ks": 1000, "s": 0},
}
},
}