diff options
author | Jerry Ge <jerry.ge@arm.com> | 2023-04-11 00:05:02 +0000 |
---|---|---|
committer | Jerry Ge <jerry.ge@arm.com> | 2023-04-20 22:53:37 +0000 |
commit | a793f4645d2c04543572de4d0bc84bf0a3689604 (patch) | |
tree | cfa8ff162c9315f079682c0913110ad25eb22cad /reference_model/include | |
parent | 714aa6039a7e3585bf81ac90ce301767c08295af (diff) | |
download | reference_model-a793f4645d2c04543572de4d0bc84bf0a3689604.tar.gz |
Add level checking to TOSA Ref model
Signed-off-by: Jerry Ge <jerry.ge@arm.com>
Change-Id: I5689d7c6b902a319a68fa4628b59e0bcc23aeca4
Diffstat (limited to 'reference_model/include')
-rw-r--r-- | reference_model/include/func_config.h | 18 | ||||
-rw-r--r-- | reference_model/include/func_debug.h | 13 |
2 files changed, 29 insertions, 2 deletions
diff --git a/reference_model/include/func_config.h b/reference_model/include/func_config.h index d9b51d5..c1f8ef6 100644 --- a/reference_model/include/func_config.h +++ b/reference_model/include/func_config.h @@ -1,5 +1,5 @@ -// Copyright (c) 2020-2022, ARM Limited. +// Copyright (c) 2020-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. @@ -19,6 +19,18 @@ #include <iostream> #include <stdio.h> +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); + } +}; + struct func_config_t { std::string operator_fbs = "tosa.fbs"; @@ -37,6 +49,10 @@ struct func_config_t uint32_t dump_intermediates = 0; std::string fp_format = "0.5"; 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 }; }; #endif diff --git a/reference_model/include/func_debug.h b/reference_model/include/func_debug.h index d762026..3794a35 100644 --- a/reference_model/include/func_debug.h +++ b/reference_model/include/func_debug.h @@ -1,5 +1,5 @@ -// Copyright (c) 2020, ARM Limited. +// Copyright (c) 2020-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. @@ -114,6 +114,17 @@ 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); \ + } +#endif + #ifndef ERROR_IF #define ERROR_IF(COND, fmt, ...) \ if ((COND)) \ |