def load_meta_compound_component_library( path="project_io/searcher_input/meta_components", instance_order_file="_instance_order.yaml"): """ Loads the meta-compound-components from a given folder, and places them into the global meta_compound_component_library :param path: Path of the compound components folder :param instance_order_file: File name of the _instance_order file, which describes the order in which the compound components should be initialized in. :return: None. Will Populate the meta_compound_component_library global. """ meta_cc_load_order = [] # Detect the instance order YAML file if instance_order_file in os.listdir(path): meta_cc_load_order = read_yaml_file( os.path.join(path, instance_order_file)) print("Found instance order YAML, listing order as follows: %s" % meta_cc_load_order) else: meta_cc_load_order = sorted(os.listdir(path)) print("Instance order YAML not found, initiating alphabetically: %s" % meta_cc_load_order) for file in meta_cc_load_order: yaml_data = read_yaml_file(os.path.join(path, file)) if type(yaml_data ) != OrderedDict or 'meta_compound_component' not in yaml_data: print("Incorrect formatting of compound component! File %s: " % file) continue # Create the Meta Compound Component mcc = MetaCompoundComponent(yaml_data) meta_compound_component_library[mcc.base_cc.comp_class] = deepcopy(mcc)
def load_compound_components(path="project_io/estimator_input/components", instance_order_file="_instance_order.yaml"): """ Will initiate CC objects in the order listed in instance_order_file :param path: directory containing compound components descriptions :param instance_order_file: A YAML folder containing a specific order to instantiate the CCs :return: None. Compound Components loaded in compound_component_library """ # Detect the instance order YAML file if instance_order_file in os.listdir(path): cc_load_order = read_yaml_file(os.path.join(path, instance_order_file)) print("Found instance order YAML, listing order as follows: %s" % cc_load_order) else: cc_load_order = sorted(os.listdir(path)) print("Instance order YAML not found, initiating alphabetically: %s" % cc_load_order) for file in cc_load_order: # We assume one file one Compound Component yaml_data = read_yaml_file(os.path.join(path, file)) # Check is a compound component file if type(yaml_data ) != OrderedDict or 'compound_component' not in yaml_data: print("Incorrect formatting of compound component! File %s: " % file) continue compound_component_factory(yaml_data['compound_component'])
def run_compiler(): comp = Compiler( read_yaml_file("mappers/compiler/compiler_io/neural_network_asr.yaml")) comp.compile() comp.write_out("mappers/compiler/compiler_io/pure_compiled_descriptor.txt", comment=False) comp.write_out( "mappers/compiler/compiler_io/comment_compiled_descriptor.txt", comment=True)
def set_meta_arch(self, meta_arch_path, meta_cc_path): """ Sets the meta-architecture to be searched. A meta-architecture describes the constraints of the architecture and the range of different possibilities to be searched. A Meta-Compound-Component similarly describes the possibility space where SMART should search for valid architectures :param meta_arch_path: Path to the meta-architecture YAML file :param meta_cc_path: Path to the meta-compound-component directory :return: None """ self.meta_arch = MetaArchitecture(read_yaml_file(meta_arch_path), meta_cc_path) self.meta_arch.load_argument_combinations()
def run_arch_finder(): database_handler.set_ipcl_table("TH2Components") meta_arch = read_yaml_file( "project_io/searcher_input/meta_architecture.yaml") start_time = time.time() ma = MetaArchitecture(meta_arch) ma.load_argument_combinations() counter = 0 for c in ma.iter_architectures(): print(c) counter += 1 end_time = time.time() print(f"Architectures searched: {counter} possibilities") print("Execution time: ", end_time - start_time, "seconds")