tensorflow/compiler/mlir/xla/transforms/legalize_tf_communication.cc
// Creates a new token if necessary, acting as a sink to previous tokens. If
// there is only one token in `tokens`, the only token is returned. If `tokens`
// is empty, `original_token` is returned instead.
Creates a new token if necessary, acting as a sink to previous tokens. If
there is only one token in `tokens`, the only token is returned. If `tokens`
is empty, `original_token` is returned instead.
Creates a new token if necessary acting as a sink to previous tokens . If there is only one token in ` tokens ` the only token is returned . If ` tokens ` is empty ` original_token ` is returned instead .
Value CreateSinkToken(OpBuilder& builder, Location loc, ArrayRef<Value> tokens,
                      Value original_token) {
  if (tokens.empty()) {
    return original_token;
  } else if (llvm::hasSingleElement(tokens)) {
    return tokens[0];
  } else {
    return builder.create<AfterAllOp>(loc, original_token.getType(), tokens)
        .getResult();
  }
}
Value CreateSinkToken ( OpBuilder & builder , Location loc , ArrayRef < Value > tokens , Value original_token ) { if ( tokens . empty ( ) ) { return original_token ; } else if ( llvm :: hasSingleElement ( tokens ) ) { return tokens [ 0 ] ; } else { return builder . create < AfterAllOp > ( loc , original_token . getType ( ) , tokens ) . getResult ( ) ; } }
Creates a new token if necessary, acting as a sink to previous tokens.
Creates a new token if necessary acting as a sink to previous tokens .