All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linkedin.dagli.dag.PreparableDAGTransformer Maven / Gradle / Ivy

Go to download

DAG-oriented machine learning framework for bug-resistant, readable, efficient, maintainable and trivially deployable models in Java and other JVM languages

There is a newer version: 15.0.0-beta9
Show newest version
package com.linkedin.dagli.dag;

import com.linkedin.dagli.placeholder.Placeholder;
import com.linkedin.dagli.producer.Producer;
import com.linkedin.dagli.transformer.PreparableTransformer;
import com.linkedin.dagli.transformer.internal.PreparableTransformerInternalAPI;
import java.util.List;


/**
 * Subtype for Preparable DAGs
 *
 * @param  the type of result of the DAG
 * @param  the type of the DAG
 */
public interface PreparableDAGTransformer, S extends PreparableDAGTransformer & PreparableTransformer>
    extends DAGTransformer, PreparableTransformer {
  interface InternalAPI, S extends PreparableDAGTransformer & PreparableTransformer>
      extends DAGTransformer.InternalAPI, PreparableTransformerInternalAPI {
    @Override
    DAGExecutor getDAGExecutor();

    /**
     * Returns a copy of this DAG that has the same properties (other than the DAG structure itself) as another DAG.
     *
     * @param other the other DAG's whose properties should be copied
     * @return a copy of this DAG that has the same properties (other than the DAG structure itself) as another DAG
     */
    default S withSameProperties(PreparableDAGTransformer other) {
      return getInstance()
          .withExecutor(other.internalAPI().getDAGExecutor())
          .withReduction(other.internalAPI().getReductionLevel());
    }

    /**
     * Given a list of placeholders and outputs, returns the prepared DAG corresponding to this preparable DAG.
     *
     * @param placeholders the placeholders of the prepared DAG
     * @param outputs the outputs of the prepared dAG
     * @return a prepared DAG of the appropriate type (given that this DAG was its progenitor)
     */
    @SuppressWarnings("unchecked")
    default PreparedDAGTransformer createPreparedDAG(List> placeholders,
        List> outputs) {
      if (getInstance() instanceof DynamicDAG) {
        return (PreparedDAGTransformer) new DynamicDAG.Prepared<>((DynamicDAG) getInstance(), placeholders,
            outputs);
      } else {
        return DAGUtil.createPreparedDAG(placeholders, outputs);
      }
    }
  }

  InternalAPI internalAPI();

  /**
   * Returns a copy of this DAG that will use the given {@link DAGExecutor} that will be used to execute this DAG.
   *
   * @param executor the {@link DAGExecutor} to use
   * @return a copy of this instance that will use the provided executor
   */
  S withExecutor(DAGExecutor executor);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy