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

com.linkedin.dagli.dag.PositionPlaceholder 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.math.hashing.DoubleXorShift;
import com.linkedin.dagli.placeholder.Placeholder;


/**
 * Placeholder used to help determine whether two DAGs are functionally identical.
 *
 * Ordinarily, placeholders have handle-equality (approximately the same as reference equality); positional placeholders
 * are instead equal is their "positions" (i.e. the index of the input they correspond to in the encompassing DAG) are
 * equal.
 *
 * @param  the type of result produced by the placeholder
 */
class PositionPlaceholder extends Placeholder {
  private static final long serialVersionUID = 1L;

  private final int _position;

  PositionPlaceholder(int position) {
    _position = position;
  }

  @Override
  protected boolean computeEqualsUnsafe(Placeholder other) {
    return other instanceof PositionPlaceholder && _position == ((PositionPlaceholder) other)._position;
  }

  @Override
  protected int computeHashCode() {
    return (int) DoubleXorShift.hash(_position, PositionPlaceholder.class.hashCode());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy