diff options
author | Jerry Ge <jerry.ge@arm.com> | 2023-07-19 23:08:16 +0000 |
---|---|---|
committer | Jerry Ge <jerry.ge@arm.com> | 2023-07-25 22:49:17 +0000 |
commit | 9c9c8dafe8f9a32bd70aee268cd537b93865a3ba (patch) | |
tree | e94fc471261b9f72bef86033fbc76022f55d5de8 /reference_model/include | |
parent | c1e13432b4a218781afd6b0171d4afff11730433 (diff) | |
download | reference_model-9c9c8dafe8f9a32bd70aee268cd537b93865a3ba.tar.gz |
Run clang-format and update copyright
- Also added run clang-format to pre-commit runs
Signed-off-by: Jerry Ge <jerry.ge@arm.com>
Change-Id: I4e59ac0afbaa30dce0773aa63d92a1a3b119e2f3
Diffstat (limited to 'reference_model/include')
-rw-r--r-- | reference_model/include/debug_types.h | 2 | ||||
-rw-r--r-- | reference_model/include/dtype.h | 2 | ||||
-rw-r--r-- | reference_model/include/func_config.h | 34 | ||||
-rw-r--r-- | reference_model/include/func_debug.h | 28 | ||||
-rw-r--r-- | reference_model/include/graph_status.h | 4 | ||||
-rw-r--r-- | reference_model/include/model_runner.h | 4 | ||||
-rw-r--r-- | reference_model/include/verify.h | 79 | ||||
-rw-r--r-- | reference_model/include/version.h | 4 |
8 files changed, 79 insertions, 78 deletions
diff --git a/reference_model/include/debug_types.h b/reference_model/include/debug_types.h index 9ff0098..4b97710 100644 --- a/reference_model/include/debug_types.h +++ b/reference_model/include/debug_types.h @@ -19,7 +19,7 @@ * Defines fundamental debugger datatypes for the functional model */ -#include<stdint.h> +#include <stdint.h> #ifndef DEBUG_TYPES_H_ #define DEBUG_TYPES_H_ diff --git a/reference_model/include/dtype.h b/reference_model/include/dtype.h index 59b7fcd..bde678a 100644 --- a/reference_model/include/dtype.h +++ b/reference_model/include/dtype.h @@ -82,7 +82,7 @@ inline const char* EnumNameTOSAREFTYPE(TOSA_REF_TYPE e) // return corresponding TOSA_REF_TYPE for DType inline TOSA_REF_TYPE ConvertDType(const DType dtype) { - assert(DType_MAX == DType_BF16); // must update whenever DType_MAX changes + assert(DType_MAX == DType_BF16); // must update whenever DType_MAX changes if (g_func_config.precise_mode) { diff --git a/reference_model/include/func_config.h b/reference_model/include/func_config.h index 900ebab..1e93b89 100644 --- a/reference_model/include/func_config.h +++ b/reference_model/include/func_config.h @@ -19,29 +19,31 @@ #include <iostream> #include <stdio.h> -struct tosa_level_t { +struct tosa_level_t +{ int32_t MAX_RANK = 0; int32_t MAX_KERNEL = 0; int32_t MAX_STRIDE = 0; int32_t MAX_SCALE = 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); + 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); } }; struct func_config_t { - std::string operator_fbs = "tosa.fbs"; - std::string test_desc = "desc.json"; - std::string flatbuffer_dir = ""; - std::string output_dir = ""; - std::string tosa_file = ""; - std::string ifm_name = ""; - std::string ifm_file = ""; - std::string ofm_name = ""; - std::string ofm_file = ""; + std::string operator_fbs = "tosa.fbs"; + std::string test_desc = "desc.json"; + std::string flatbuffer_dir = ""; + std::string output_dir = ""; + std::string tosa_file = ""; + std::string ifm_name = ""; + std::string ifm_file = ""; + std::string ofm_name = ""; + std::string ofm_file = ""; uint32_t eval = 1; uint32_t validate_only = 0; uint32_t output_tensors = 1; @@ -49,12 +51,12 @@ struct func_config_t uint32_t dump_intermediates = 0; std::string fp_format = "0.5"; uint32_t precise_mode = 0; - bool abs_mode = 0; // set in main as second run of precise_mode - bool float_is_big_endian = false; // Set in arith_util.h by float_is_big_endian() + bool abs_mode = 0; // set in main as second run of precise_mode + 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, 64 }; - static constexpr tosa_level_t NONE = { 0, 0, 0, 0 }; + static constexpr tosa_level_t NONE = { 0, 0, 0, 0 }; }; #endif diff --git a/reference_model/include/func_debug.h b/reference_model/include/func_debug.h index 3794a35..556faf2 100644 --- a/reference_model/include/func_debug.h +++ b/reference_model/include/func_debug.h @@ -60,12 +60,12 @@ void func_enable_signal_handlers(); struct func_debug_t { - uint32_t func_debug_verbosity = 0; // What verbosity level is set? (bitmask) - uint64_t func_debug_mask = 0; // Which units have debugging enabled? (bitmask) - uint64_t func_debug_inst_mask = 0; // Which instances have debugging enabled (bitmask) - uint64_t inst_id = 0; // The instance id for multiple model instances - FILE* func_debug_file = stderr; // Output file - bool is_output_unbuffered = false; // should log files be opened with unbuffered I/O. + uint32_t func_debug_verbosity = 0; // What verbosity level is set? (bitmask) + uint64_t func_debug_mask = 0; // Which units have debugging enabled? (bitmask) + uint64_t func_debug_inst_mask = 0; // Which instances have debugging enabled (bitmask) + uint64_t inst_id = 0; // The instance id for multiple model instances + FILE* func_debug_file = stderr; // Output file + bool is_output_unbuffered = false; // should log files be opened with unbuffered I/O. int init_debug(uint64_t inst_id); int fini_debug(); @@ -115,13 +115,13 @@ struct func_debug_t #endif #ifndef LEVEL_CHECK -#define LEVEL_CHECK(COND, fmt, ...) \ - if (g_func_config.tosa_level != func_config_t::NONE && (!(COND))) \ - { \ - fprintf(g_func_debug.func_debug_file, COL_FATAL("LEVEL_CHECK() fails AT %s:%d %s(): (%s)\n"), __FILE__, __LINE__, \ - __func__, #COND); \ - fprintf(g_func_debug.func_debug_file, COL_FATAL(fmt) "\n", ##__VA_ARGS__); \ - this->parent_sgt->setGraphStatus(GraphStatus::TOSA_UNPREDICTABLE); \ +#define LEVEL_CHECK(COND, fmt, ...) \ + if (g_func_config.tosa_level != func_config_t::NONE && (!(COND))) \ + { \ + fprintf(g_func_debug.func_debug_file, COL_FATAL("LEVEL_CHECK() fails AT %s:%d %s(): (%s)\n"), __FILE__, \ + __LINE__, __func__, #COND); \ + fprintf(g_func_debug.func_debug_file, COL_FATAL(fmt) "\n", ##__VA_ARGS__); \ + this->parent_sgt->setGraphStatus(GraphStatus::TOSA_UNPREDICTABLE); \ } #endif @@ -174,8 +174,6 @@ void func_debug_warning( fprintf(stderr, COL_WARN(fmt) "\n", ##__VA_ARGS__); #endif - - // Is this debug verbosity and unit level enabled? // Provide compiler hints that this is unlikely // Two versions, depending on whether DEBUG_INSTANCE_EXPR is defined in a file or not diff --git a/reference_model/include/graph_status.h b/reference_model/include/graph_status.h index f3be004..91330df 100644 --- a/reference_model/include/graph_status.h +++ b/reference_model/include/graph_status.h @@ -1,4 +1,4 @@ -// Copyright (c) 2022, ARM Limited. +// 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. @@ -22,4 +22,4 @@ enum class GraphStatus : int TOSA_ERROR = 2, }; -#endif // GRAPH_STATUS_H +#endif // GRAPH_STATUS_H diff --git a/reference_model/include/model_runner.h b/reference_model/include/model_runner.h index 86d0056..2c610b8 100644 --- a/reference_model/include/model_runner.h +++ b/reference_model/include/model_runner.h @@ -1,5 +1,5 @@ -// Copyright (c) 2022, ARM Limited. +// 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. @@ -16,8 +16,8 @@ #ifndef MODEL_RUNNER_H_ #define MODEL_RUNNER_H_ -#include "model_common.h" #include "graph_status.h" +#include "model_common.h" #include "tosa_serialization_handler.h" diff --git a/reference_model/include/verify.h b/reference_model/include/verify.h index 0ac35fe..d294388 100644 --- a/reference_model/include/verify.h +++ b/reference_model/include/verify.h @@ -21,50 +21,51 @@ #include <cstddef> #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif /* __cplusplus */ -// Check result -// -// Error is valid only and only if is_valid is true -struct CheckResult -{ - bool is_valid; - double error; -}; + // 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 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 -/// -/// \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 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 + /// + /// \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 -/// -/// \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 -/// -/// \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); + /// Validate error of whole vector of output data + /// + /// \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 + /// + /// \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); #ifdef __cplusplus } diff --git a/reference_model/include/version.h b/reference_model/include/version.h index c81eedd..481a934 100644 --- a/reference_model/include/version.h +++ b/reference_model/include/version.h @@ -1,4 +1,4 @@ -// Copyright (c) 2022, ARM Limited. +// 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. @@ -20,4 +20,4 @@ #define TOSA_REFERENCE_MODEL_VERSION_PATCH 0 #define TOSA_REFERENCE_MODEL_VERSION_DRAFT true -#endif //VERSION_H +#endif //VERSION_H |