Source code for chop.actions.search.search

import logging
from os import PathLike

import toml
import torch

from ...tools.checkpoint_load import load_model
from ...tools.config_load import load_config
from ...tools.get_input import get_dummy_input
from .search_space import get_search_space_cls
from .strategies import get_search_strategy_cls
from chop.tools.utils import device
from chop.tools.utils import parse_accelerator

logger = logging.getLogger(__name__)


[docs] def parse_search_config( search_config: dict, ): """ Parse search config from a dict or a toml file and do sanity check. The search config must consist of two parts: strategy and search_space. Args: search_config: A dictionary or a path to a toml file containing the search config. Returns: _type_: _description_ """ if not isinstance(search_config, dict): search_config = load_config(search_config) search_config = search_config["search"] # the actual config for action search strategy_config = search_config["strategy"] search_space_config = search_config["search_space"] return strategy_config, search_space_config