aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src
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 /reference_model/src
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 'reference_model/src')
-rw-r--r--reference_model/src/verify/verify_dot_product.cc7
-rw-r--r--reference_model/src/verify/verify_entry.cc32
-rw-r--r--reference_model/src/verify/verify_exact.cc2
-rw-r--r--reference_model/src/verify/verify_ulp.cc1
-rw-r--r--reference_model/src/verify/verify_utils.cc3
-rw-r--r--reference_model/src/verify/verify_utils.h7
6 files changed, 36 insertions, 16 deletions
diff --git a/reference_model/src/verify/verify_dot_product.cc b/reference_model/src/verify/verify_dot_product.cc
index a96befa..39895b1 100644
--- a/reference_model/src/verify/verify_dot_product.cc
+++ b/reference_model/src/verify/verify_dot_product.cc
@@ -105,9 +105,6 @@ bool verifyDotProduct(const CTensor* ref, const CTensor* refBnd, const CTensor*
TOSA_REF_REQUIRE(refBnd != nullptr, "reference bounds tensor is missing");
TOSA_REF_REQUIRE(imp != nullptr, "implementation tensor is missing");
- // Validate data-type
- TOSA_REF_REQUIRE(dpInfo.dataType == mapToDType(imp->data_type), "invalid data type in config");
-
// Get number of dot-product elements
const int64_t T = numElements(std::vector<int32_t>(ref->shape, ref->shape + ref->num_dims));
TOSA_REF_REQUIRE(T > 0, "invalid shape for reference tensor");
@@ -124,8 +121,10 @@ bool verifyDotProduct(const CTensor* ref, const CTensor* refBnd, const CTensor*
return validateData(refData, refBndData, impData, static_cast<size_t>(T), dpInfo);
break;
}
- default:
+ default: {
+ WARNING("tosa verifier: data-type not supported.");
break;
+ }
}
return false;
diff --git a/reference_model/src/verify/verify_entry.cc b/reference_model/src/verify/verify_entry.cc
index 1f7c680..32614b6 100644
--- a/reference_model/src/verify/verify_entry.cc
+++ b/reference_model/src/verify/verify_entry.cc
@@ -38,7 +38,7 @@ bool verify(const CTensor* ref, const CTensor* refBnd, const CTensor* imp, const
return verifyULP(ref, imp, cfg.ulpInfo.ulp);
}
default: {
- WARNING("unsupported verification mode.");
+ WARNING("tosa verifier: unsupported verification mode.");
break;
}
}
@@ -57,40 +57,58 @@ extern "C"
// Check inputs for nullptr
if (!ref || !imp || !config_json)
{
- WARNING("one of the inputs is missing.");
+ WARNING("tosa verifier: one of the inputs is missing.");
return false;
}
// Extract verification config
if (!ref->name)
{
- WARNING("tensor name is not specified.");
+ WARNING("tosa verifier: tensor name is not specified.");
return false;
}
auto cfg = TosaReference::parseVerifyConfig(ref->name, config_json);
if (!cfg)
{
- WARNING("invalid json config.");
+ WARNING("tosa verifier: invalid json config.");
return false;
}
// Validate shape
if (ref->num_dims != imp->num_dims)
{
- WARNING("tensors have different number of dimensions.");
+ WARNING("tosa verifier: tensors have different number of dimensions.");
return false;
}
if (!ref->shape || !imp->shape)
{
- WARNING("one of tensors' shape is missing.");
+ WARNING("tosa verifier: one of tensors' shape is missing.");
return false;
}
if (std::vector(ref->shape, ref->shape + ref->num_dims) != std::vector(imp->shape, imp->shape + imp->num_dims))
{
- WARNING("tensors have different shapes.");
+ WARNING("tosa verifier: tensors have different shapes.");
return false;
}
+ // Validate data-type
+ if (ref->data_type == tosa_datatype_fp64_t)
+ {
+ if (cfg->dataType != TosaReference::mapToDType(imp->data_type))
+ {
+ WARNING("tosa verifier: incorrect tensor data type.");
+ return false;
+ }
+ }
+ else
+ {
+ if (ref->data_type != imp->data_type)
+ {
+ WARNING("tosa verifier: tensors have different data types.");
+ return false;
+ }
+ }
+
// Run verification
return verify(ref, ref_bnd, imp, *cfg);
}
diff --git a/reference_model/src/verify/verify_exact.cc b/reference_model/src/verify/verify_exact.cc
index 7fde5bb..1a0c44c 100644
--- a/reference_model/src/verify/verify_exact.cc
+++ b/reference_model/src/verify/verify_exact.cc
@@ -44,7 +44,7 @@ bool verifyExact(const CTensor* referenceTensor, const CTensor* implementationTe
});
}
default:
- WARNING("data-type not supported.");
+ WARNING("tosa verifier: data-type not supported.");
break;
}
diff --git a/reference_model/src/verify/verify_ulp.cc b/reference_model/src/verify/verify_ulp.cc
index 622fba4..223bc48 100644
--- a/reference_model/src/verify/verify_ulp.cc
+++ b/reference_model/src/verify/verify_ulp.cc
@@ -145,6 +145,7 @@ bool verifyULP(const CTensor* referenceTensor, const CTensor* implementationTens
});
}
default:
+ WARNING("tosa verifier: data-type not supported.");
break;
}
diff --git a/reference_model/src/verify/verify_utils.cc b/reference_model/src/verify/verify_utils.cc
index bb4feaa..786ab40 100644
--- a/reference_model/src/verify/verify_utils.cc
+++ b/reference_model/src/verify/verify_utils.cc
@@ -48,6 +48,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(VerifyMode,
{ VerifyMode::DotProduct, "DOT_PRODUCT" },
{ VerifyMode::ReduceProduct, "REDUCE_PRODUCT" },
{ VerifyMode::FpSpecial, "FP_SPECIAL" },
+ { VerifyMode::Round, "ROUND" },
})
void from_json(const nlohmann::json& j, UlpInfo& ulpInfo)
@@ -57,7 +58,6 @@ void from_json(const nlohmann::json& j, UlpInfo& ulpInfo)
void from_json(const nlohmann::json& j, DotProductVerifyInfo& dotProductInfo)
{
- j.at("data_type").get_to(dotProductInfo.dataType);
j.at("s").get_to(dotProductInfo.s);
j.at("ks").get_to(dotProductInfo.ks);
}
@@ -65,6 +65,7 @@ void from_json(const nlohmann::json& j, DotProductVerifyInfo& dotProductInfo)
void from_json(const nlohmann::json& j, VerifyConfig& cfg)
{
j.at("mode").get_to(cfg.mode);
+ j.at("data_type").get_to(cfg.dataType);
if (j.contains("ulp_info"))
{
j.at("ulp_info").get_to(cfg.ulpInfo);
diff --git a/reference_model/src/verify/verify_utils.h b/reference_model/src/verify/verify_utils.h
index 510b9cb..5b98f5c 100644
--- a/reference_model/src/verify/verify_utils.h
+++ b/reference_model/src/verify/verify_utils.h
@@ -26,7 +26,7 @@
#define TOSA_REF_REQUIRE(COND, MESSAGE) \
if (!(COND)) \
{ \
- WARNING(MESSAGE); \
+ WARNING("tosa verifier: " MESSAGE "."); \
return false; \
}
@@ -43,7 +43,8 @@ enum class VerifyMode
Ulp,
DotProduct,
ReduceProduct,
- FpSpecial
+ FpSpecial,
+ Round
};
/// \brief ULP verification meta-data
@@ -59,7 +60,6 @@ struct DotProductVerifyInfo
{
DotProductVerifyInfo() = default;
- DType dataType;
int32_t s;
int32_t ks;
};
@@ -70,6 +70,7 @@ struct VerifyConfig
VerifyConfig() = default;
VerifyMode mode;
+ DType dataType;
UlpInfo ulpInfo;
DotProductVerifyInfo dotProductInfo;
};