Interface TranslatorFactory

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.util.Set<ai.djl.util.Pair<java.lang.reflect.Type,​java.lang.reflect.Type>> getSupportedTypes()
      Returns supported input/output classes.
      default boolean isSupported​(java.lang.Class<?> input, java.lang.Class<?> output)
      Returns if the input/output is supported by the TranslatorFactory.
      <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.
    • Method Detail

      • getSupportedTypes

        java.util.Set<ai.djl.util.Pair<java.lang.reflect.Type,​java.lang.reflect.Type>> getSupportedTypes()
        Returns supported input/output classes.
        Returns:
        a set of supported input/output classes
      • isSupported

        default boolean isSupported​(java.lang.Class<?> input,
                                    java.lang.Class<?> output)
        Returns if the input/output is supported by the TranslatorFactory.
        Parameters:
        input - the input class
        output - the output class
        Returns:
        true if the input/output type is supported
      • newInstance

        <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)
                                               throws TranslateException
        Returns a new instance of the Translator class.
        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
        Throws:
        TranslateException - if failed to create Translator instance