Source code for afe.backends.mla.afe_to_n2a_compiler.create_ofm_chk_mlc

#########################################################
# Copyright (C) 2024 SiMa Technologies, Inc.
#
# This material is SiMa proprietary and confidential.
#
# This material may not be copied or distributed without
# the express prior written permission of SiMa.
#
# All rights reserved.
#########################################################
import time

# An external script to be created to call create_ofm_chk_mlc().
_executable_script: str = '''
import argparse
import afe.backends.mla.afe_to_n2a_compiler.create_ofm_chk_mlc as _mlc
parser = argparse.ArgumentParser(description='Run evaluate_model to create ofm_chk.mlc.')
parser.add_argument('--in', dest='in_json', required=True, help='Input JSON file')
parser.add_argument('--out', dest='out_mlc', required=True, help='Output chk.mlc file')
args = parser.parse_args()

_mlc.create_ofm_chk_mlc(args.in_json, args.out_mlc)
'''


[docs] def get_ofm_executable_script() -> str: return _executable_script
[docs] def create_ofm_chk_mlc(in_json: str, out_mlc: str): from afe.backends.mla.afe_to_n2a_compiler.defines import evaluate_model, import_model_from_json from afe.backends.mla.afe_to_n2a_compiler.n2a_backend_runner import N2ACompiledBackendRunner start = time.process_time() # Create model graph from input json file model_graph, untessellated_inputs = import_model_from_json(in_json) # Evaluate model graph untessellated_outputs = evaluate_model(model_graph, untessellated_inputs) # Write ofm_chk.mlc file N2ACompiledBackendRunner.pack_and_write_outputs_to_ofm_chk_file( untessellated_outputs, model_graph.compile_properties.unpack_parameters, out_mlc ) print(f'Evaluate model and writing chk file done in {int(time.process_time() - start)}s.')