aboutsummaryrefslogtreecommitdiff
path: root/reference_model/include
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2023-08-22 08:25:57 +0100
committerEric Kunze <eric.kunze@arm.com>2023-09-07 16:03:50 +0000
commit7021ef064f7daeca260bb1f1bd61b5bbc6473aa5 (patch)
tree24a488954ab0a7c6e29e811429ad194af67c3880 /reference_model/include
parent391cc5e80559e46081b6aa12c344d820dc685c95 (diff)
downloadreference_model-7021ef064f7daeca260bb1f1bd61b5bbc6473aa5.tar.gz
Rework TOSA verification API
Change verifier API to consume verification configuration in a JSON format and enable appropriate validation to be performed within the verifier code in the reference model. Also update to latest spec changes for main compliance but not yet including bias support. Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: I0ceaa1714dd041b00b5b29cd937c8f05e701bc4c
Diffstat (limited to 'reference_model/include')
-rw-r--r--reference_model/include/operators.h43
-rw-r--r--reference_model/include/types.h75
-rw-r--r--reference_model/include/verify.h53
3 files changed, 90 insertions, 81 deletions
diff --git a/reference_model/include/operators.h b/reference_model/include/operators.h
index 25477d7..e7907f5 100644
--- a/reference_model/include/operators.h
+++ b/reference_model/include/operators.h
@@ -21,6 +21,7 @@
#include "func_config.h"
#include "func_debug.h"
+#include "types.h"
#include <stddef.h>
#include <stdint.h>
@@ -30,48 +31,6 @@ extern "C"
{
#endif /* __cplusplus */
- // Note status needs to be aligned with graph_status
- enum tosa_status_t
- {
- tosa_status_valid = 0,
- tosa_status_unpredictable = 1,
- tosa_status_error = 2
- };
-
- enum tosa_mode_t
- {
- tosa_mode_unknown = 0,
- tosa_mode_nearest = 1,
- tosa_mode_bilinear = 2,
- tosa_mode_min = 3,
- tosa_mode_max = 4
- };
-
- enum tosa_datatype_t
- {
- tosa_datatype_bf16_t = 0,
- tosa_datatype_bool_t = 1,
- tosa_datatype_fp16_t = 2,
- tosa_datatype_fp32_t = 3,
- tosa_datatype_int16_t = 4,
- tosa_datatype_int32_t = 5,
- tosa_datatype_int48_t = 6,
- tosa_datatype_int4_t = 7,
- tosa_datatype_int8_t = 8,
- tosa_datatype_uint16_t = 9,
- tosa_datatype_uint8_t = 10,
- tosa_datatype_shape_t = 11,
- };
-
- struct tosa_tensor_t
- {
- int32_t* shape;
- int32_t num_dims;
- tosa_datatype_t data_type;
- uint8_t* data;
- size_t size;
- };
-
tosa_status_t tosa_run_argmax(tosa_tensor_t client_input,
const int32_t client_axis,
tosa_tensor_t client_output,
diff --git a/reference_model/include/types.h b/reference_model/include/types.h
new file mode 100644
index 0000000..42040bf
--- /dev/null
+++ b/reference_model/include/types.h
@@ -0,0 +1,75 @@
+
+// Copyright (c) 2022-2023, ARM Limited.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef TYPES_H_
+#define TYPES_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+ // Note status needs to be aligned with graph_status
+ enum tosa_status_t
+ {
+ tosa_status_valid = 0,
+ tosa_status_unpredictable = 1,
+ tosa_status_error = 2
+ };
+
+ enum tosa_mode_t
+ {
+ tosa_mode_unknown = 0,
+ tosa_mode_nearest = 1,
+ tosa_mode_bilinear = 2,
+ tosa_mode_min = 3,
+ tosa_mode_max = 4
+ };
+
+ enum tosa_datatype_t
+ {
+ tosa_datatype_bf16_t = 0,
+ tosa_datatype_bool_t = 1,
+ tosa_datatype_fp16_t = 2,
+ tosa_datatype_fp32_t = 3,
+ tosa_datatype_int16_t = 4,
+ tosa_datatype_int32_t = 5,
+ tosa_datatype_int48_t = 6,
+ tosa_datatype_int4_t = 7,
+ tosa_datatype_int8_t = 8,
+ tosa_datatype_uint16_t = 9,
+ tosa_datatype_uint8_t = 10,
+ tosa_datatype_shape_t = 11,
+ tosa_datatype_fp64_t = 99
+ };
+
+ struct tosa_tensor_t
+ {
+ const char* name;
+ int32_t* shape;
+ int32_t num_dims;
+ tosa_datatype_t data_type;
+ uint8_t* data;
+ size_t size;
+ };
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif // TYPES_H_ \ No newline at end of file
diff --git a/reference_model/include/verify.h b/reference_model/include/verify.h
index d294388..e449ff7 100644
--- a/reference_model/include/verify.h
+++ b/reference_model/include/verify.h
@@ -18,54 +18,29 @@
//
//===----------------------------------------------------------------------===//
-#include <cstddef>
+#include "types.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
- // Check result
- //
- // Error is valid only and only if is_valid is true
- struct CheckResult
- {
- bool is_valid;
- double error;
- };
-
- /// Validate and calculate tensor element error when using an fp32 accumulator
- ///
- /// \param ref Tensor element calculated using fp64
- /// \param bnd Tensor element calculated using fp64 on abs(input, weights)
- /// \param imp Tensor element calculated through the implementation
- /// \param KS The kernel size
- ///
- /// \return Output error
- CheckResult tosa_validate_element_accfp32(double ref, double bnd, float imp, size_t KS);
-
- /// Validate the accumulated output error
- ///
- /// \param err_sum Sum of error of all the tensor elements within a tensor
- /// \param err_sum_sq Sum of error squares of all the tensor elements within a tensor
- /// \param T Number of output (dot-product) elements
- /// \param KS The kernel size
- /// \param S Test set used as a input/weight generator
+ /// \brief Perform compliance validation between a reference and a target output
///
- /// \return True if the error is within margin else false
- bool tosa_validate_output_error(double err_sum, double err_sum_sq, size_t T, size_t KS, int S);
-
- /// Validate error of whole vector of output data
+ /// A compliance configuration is expected as it provides information about
+ /// the type of validation to be performed alongside with all the relevant
+ /// meta-data. Configuration is provided in JSON format.
///
- /// \param ref Output elements calculated using fp64
- /// \param bnd Output elements calculated using fp64 on abs(input, weights)
- /// \param imp Output elements calculated using the implementation
- /// \param T Number of elements in outputs (need to match)
- /// \param KS The kernel size
- /// \param S Test set used as a input/weight generator
+ /// \param ref Reference tensor to compare against
+ /// \param ref_bnd (Optional) Reference tensor when run on absolute inputs
+ /// \param imp Implementation resulting tensor
+ /// \param config_json Compliance configuration that indicates how and what compliance need to be performed
///
- /// \return True if the error is within margin else false
- bool tosa_validate_data_fp32(const double* ref, const double* bnd, const float* imp, size_t T, size_t KS, int S);
+ /// \return True in case of successful validation else false
+ bool tvf_verify_data(const tosa_tensor_t* ref,
+ const tosa_tensor_t* ref_bnd,
+ const tosa_tensor_t* imp,
+ const char* config_json);
#ifdef __cplusplus
}