From f0348ea4206a7e02497515ffb6d88546e0121cc7 Mon Sep 17 00:00:00 2001 From: Jeremy Johnson Date: Wed, 27 Sep 2023 16:10:59 +0100 Subject: Refactor path arguments to tosa-tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tosa_verif_conformance_generator - Move to using ref-model-path instead of ref-model-dir - Add schema-path and flatc-path - Add model_files module to locate default places for files convert2conformance - Remove default paths verifier - Switch to using exact path of verifier library tosa_verif_run_tests - Use conformance model_files to locate defaults Change-Id: Ieca3b164670e2a7dcb047743667cc4e8317daa97 Signed-off-by: Josef Malmström Signed-off-by: Jeremy Johnson --- scripts/convert2conformance/convert2conformance.py | 46 +++++++++------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'scripts') diff --git a/scripts/convert2conformance/convert2conformance.py b/scripts/convert2conformance/convert2conformance.py index adb163f..3654f9a 100755 --- a/scripts/convert2conformance/convert2conformance.py +++ b/scripts/convert2conformance/convert2conformance.py @@ -22,10 +22,6 @@ from schemavalidation.schemavalidation import TestDescSchemaValidator logging.basicConfig(level=logging.INFO) logger = logging.getLogger("convert2conformance") -LOCATION_REF_MODEL_SCHEMA = Path("thirdparty/serialization_lib/schema/tosa.fbs") -LOCATION_REF_MODEL_FLATC = Path( - "build/thirdparty/serialization_lib/third_party/flatbuffers/flatc" -) NAME_FLATBUFFER_DIR = ["flatbuffer-", "_FW_"] NAME_DESC_FILENAME = "desc.json" @@ -47,11 +43,19 @@ def parse_args(argv): help="The test directory to convert (default is CWD)", ) parser.add_argument( - "--ref-model-directory", - dest="ref_model_dir", + "--schema-path", + "--operator-fbs", + dest="schema_path", type=Path, required=True, - help="Reference Model directory (must be pre-built)", + help=("Path to reference model schema."), + ) + parser.add_argument( + "--flatc-path", + dest="flatc_path", + type=Path, + required=True, + help=("Path to flatc executable."), ) parser.add_argument( "--output-directory", @@ -107,21 +111,6 @@ def parse_args(argv): return args -def find_ref_model_artifacts(path: Path): - """Check the location of the flatc compiler and schema artifacts.""" - flatc = path / LOCATION_REF_MODEL_FLATC - schema = path / LOCATION_REF_MODEL_SCHEMA - if not flatc.is_file(): - raise Exception( - f"flatc not found in {flatc}\nHave you built the flatbuffers compiler?" - ) - if not schema.is_file(): - raise Exception( - f"TOSA schema not found at {schema}\nHave you checked out the submodules?" - ) - return flatc, schema - - def find_framework_artifacts(framework: str, schema_path: Path, desc_file: Path): """Check that any required schema has been supplied for conversion.""" if framework == "tflite": @@ -240,10 +229,11 @@ def main(argv=None): logger.setLevel(logging.DEBUG) # Check we can get the files we need - try: - flatc, schema = find_ref_model_artifacts(args.ref_model_dir) - except Exception as err: - logger.error(err) + if not args.flatc_path.is_file(): + logger.error("flatc not found at %s", args.flatc_path) + return 2 + if not args.schema_path.is_file(): + logger.error("TOSA schema not found at %s", args.schema_path) return 2 # Work out where the desc.json file is @@ -307,7 +297,7 @@ def main(argv=None): # Convert the TOSA flatbuffer binary tosa_filename = desc_filename.parent / test_desc["tosa_file"] tosa_filename = convert_flatbuffer_file( - flatc, schema, tosa_filename, args.output_dir + args.flatc_path, args.schema_path, tosa_filename, args.output_dir ) if not tosa_filename: # Failed to convert the file, json2fbbin will have printed an error @@ -319,7 +309,7 @@ def main(argv=None): if framework_conversion and framework_filename: # Convert the framework flatbuffer binary framework_filename = convert_flatbuffer_file( - flatc, framework_schema, framework_filename, args.output_dir + args.flatc_path, framework_schema, framework_filename, args.output_dir ) if not framework_filename: # Failed to convert the file, json2fbbin will have printed an error -- cgit v1.2.1