Exemple #1
0
    def schemaToSimplifiedAndSearchSpace(
            self, longName: str, name: str,
            schema: Schema) -> Tuple[Schema, Optional[SearchSpace]]:
        relevantFields = findRelevantFields(schema)
        if relevantFields:
            schema = narrowToGivenRelevantFields(schema, relevantFields)

        if has_operator(schema):
            atomize_schema_enumerations(schema)
        simplified_schema = simplify(schema, True)
        #    from . import pretty_print
        #    print(f'SIMPLIFIED_{longName}: {pretty_print.to_string(simplified_schema)}')

        filtered_schema = filterForOptimizer(simplified_schema)
        #    print(f'SIMPLIFIED_{longName}: {pretty_print.to_string(filtered_schema)}')

        if logger.isEnabledFor(logging.WARNING):
            op_warnings: List[str] = []
            check_operators_schema(filtered_schema, op_warnings)
            if op_warnings:
                for w in op_warnings:
                    logger.warning(w)

        return (filtered_schema,
                self.schemaToSearchSpaceHelper(longName,
                                               filtered_schema,
                                               relevantFields,
                                               pgo_freqs=pgo_lookup(
                                                   self.pgo, name)))
Exemple #2
0
def schemaToSimplifiedAndSearchSpace(
        longName: str,
        name: str,
        schema: Schema,
        pgo: Optional[PGO] = None) -> Tuple[Schema, Optional[SearchSpace]]:
    relevantFields = findRelevantFields(schema)
    if relevantFields:
        schema = narrowToGivenRelevantFields(schema, relevantFields)
    simplified_schema = simplify(schema, True)
    #    from . import helpers
    #    helpers.print_yaml('SIMPLIFIED_' + longName, simplified_schema)

    filtered_schema = filterForOptimizer(simplified_schema)
    #    helpers.print_yaml('FILTERED_' + longName, filtered_schema)

    return (filtered_schema,
            schemaToSearchSpaceHelper(longName,
                                      filtered_schema,
                                      relevantFields,
                                      pgo_freqs=pgo_lookup(pgo, name)))