Class ExpansionTranslatorFactory<IbaseT,​ObaseT>

    • Constructor Detail

      • ExpansionTranslatorFactory

        public ExpansionTranslatorFactory()
    • Method Detail

      • getSupportedTypes

        public java.util.Set<ai.djl.util.Pair<java.lang.reflect.Type,​java.lang.reflect.Type>> getSupportedTypes()
        Returns supported input/output classes.
        Specified by:
        getSupportedTypes in interface TranslatorFactory
        Returns:
        a set of supported input/output classes
      • newInstance

        public <I,​O> Translator<I,​O> newInstance​(java.lang.Class<I> input,
                                                             java.lang.Class<O> output,
                                                             Model model,
                                                             java.util.Map<java.lang.String,​?> arguments)
        Returns a new instance of the Translator class.
        Specified by:
        newInstance in interface TranslatorFactory
        Type Parameters:
        I - the input data type
        O - the output data type
        Parameters:
        input - the input class
        output - the output class
        model - the Model that uses the Translator
        arguments - the configurations for a new Translator instance
        Returns:
        a new instance of the Translator class
      • withTranslator

        public ai.djl.translate.ExpansionTranslatorFactory.ExpandedTranslatorOptions withTranslator​(Translator<IbaseT,​ObaseT> translator)
        Creates a set of TranslatorOptions based on the expansions of a given translator.
        Parameters:
        translator - the translator to expand
        Returns:
        the TranslatorOptions
      • buildBaseTranslator

        protected abstract Translator<IbaseT,​ObaseT> buildBaseTranslator​(Model model,
                                                                               java.util.Map<java.lang.String,​?> arguments)
        Builds the base translator that can be expanded.
        Parameters:
        model - the Model that uses the Translator
        arguments - the configurations for a new Translator instance
        Returns:
        a base translator that can be expanded to form the factory options
      • getBaseInputType

        public abstract java.lang.Class<IbaseT> getBaseInputType()
        Returns the input type for the base translator.
        Returns:
        the input type for the base translator
      • getBaseOutputType

        public abstract java.lang.Class<ObaseT> getBaseOutputType()
        Returns the output type for the base translator.
        Returns:
        the output type for the base translator
      • getExpansions

        protected java.util.Map<ai.djl.util.Pair<java.lang.reflect.Type,​java.lang.reflect.Type>,​ExpansionTranslatorFactory.TranslatorExpansion<IbaseT,​ObaseT>> getExpansions()
        Returns the possible expansions of this factory.
        Returns:
        the possible expansions of this factory
      • getPreprocessorExpansions

        protected java.util.Map<java.lang.reflect.Type,​java.util.function.Function<PreProcessor<IbaseT>,​PreProcessor<?>>> getPreprocessorExpansions()
        Returns the possible expansions of this factory.
        Returns:
        the possible expansions of this factory
      • getPostprocessorExpansions

        protected java.util.Map<java.lang.reflect.Type,​java.util.function.Function<PostProcessor<ObaseT>,​PostProcessor<?>>> getPostprocessorExpansions()
        Returns the possible expansions of this factory.
        Returns:
        the possible expansions of this factory