o
    ?e^                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	 Z
e	d
ddd Ze	d
ddd Ze	d
ddd ZdddZe	d
ddd Ze	d
ddd Ze	d
ddd ZejZd
S )zInplace operations.
    )dtypes)ops)	array_ops)gen_array_ops)math_ops)deprecationc              
   C   s   t | } t || j}|du r*t|t| ddgdgt|ddgt| S t|tj	}|
 jdkrG|| t|dgt|dS || ||S )a0  Applies an inplace op on (x, i, v).

  op is one of gen_array_ops.alias_inplace_update,
  gen_array_ops.alias_inplace_add, or gen_array_ops.alias_inplace_sub.

  If i is None, x and v must be the same shape. Computes
    x op v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    x[i, :] op v;
  Otherwise, x and v must have the same rank. Computes
    x[i, :] op v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.
    op: alias_inplace_update, alias_inplace_add, or alias_inplace_sub.

  Returns:
    Returns x.

  N   r   )r   convert_to_tensordtyper   Zreshapeshaper   castr   Zint32	get_shapeZndimsZexpand_dims)xivop r   b/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/ops/inplace_ops.py_inplace_helper   s   
$r   NzoPrefer tf.tensor_scatter_nd_update, which offers the same functionality with well-defined read-write semantics.c                 C      t | ||tjS )a  Applies an inplace update on input x at index i with value v. Aliases x.

  If i is None, x and v must be the same shape. Computes
    x = v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    x[i, :] = v;
  Otherwise, x and v must have the same rank. Computes
    x[i, :] = v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.

  Returns:
    Returns x.

  )r   r   inplace_updater   r   r   r   r   r   alias_inplace_update?      r   zlPrefer tf.tensor_scatter_nd_add, which offers the same functionality with well-defined read-write semantics.c                 C   r   )a  Applies an inplace add on input x at index i with value v. Aliases x.

  If i is None, x and v must be the same shape. Computes
    x += v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    x[i, :] += v;
  Otherwise, x and v must have the same rank. Computes
    x[i, :] += v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.

  Returns:
    Returns x.

  )r   r   inplace_addr   r   r   r   alias_inplace_addY   r   r   zlPrefer tf.tensor_scatter_nd_sub, which offers the same functionality with well-defined read-write semantics.c                 C   r   )a  Applies an inplace sub on input x at index i with value v. Aliases x.

  If i is None, x and v must be the same shape. Computes
    x -= v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    x[i, :] -= v;
  Otherwise, x and v must have the same rank. Computes
    x[i, :] -= v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.

  Returns:
    Returns x.

  )r   r   inplace_subr   r   r   r   alias_inplace_subs   r   r   c                 C   s"   t | } tjt| | j|dS )a  Returns a non-initialized tensor with the same shape and dtype as x.

  Args:
    x: A Tensor.
    init: Initialize the returned tensor with the default value of
      x.dtype(), if True. Otherwise, do not initialize. Defaults to
      None.

  Returns:
    A tensor y, whose dtype and shape are the same as those of x.
    y is guaranteed not to be an alias of x. Upon return, y may contain
    arbitrary data.

  )init)r   r
   r   emptyr   r   r   )r   r   r   r   r   
empty_like   s   
r!   c                 C      t t| ||S )al  Applies an inplace update on input x at index i with value v.

  Note that this function is not actually inplace - it allocates
  a copy of x.  The utility is not avoiding memory copies but rather
  specifying a sparse update.

  If i is None, x and v must be the same shape. Computes
    y = x; y = v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    y = x; y[i, :] = v;
  Otherwise, x and v must have the same rank. Computes
    y = x; y[i, :] = v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.

  Returns:
    Returns y, which is guaranteed not to be an alias of x.

  )r   r   	deep_copyr   r   r   r   r         r   c                 C   r"   )al  Applies an inplace add on input x at index i with value v.

  Note that this function is not actually inplace - it allocates
  a copy of x.  The utility is not avoiding memory copies but rather
  specifying a sparse update.

  If i is None, x and v must be the same shape. Computes
    y = x; y += v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    y = x; y[i, :] += v;
  Otherwise, x and v must have the same rank. Computes
    y = x; y[i, :] += v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.

  Returns:
    Returns y, which is guaranteed not to be an alias of x.

  )r   r   r#   r   r   r   r   r      r$   r   c                 C   r"   )al  Applies an inplace sub on input x at index i with value v.

  Note that this function is not actually inplace - it allocates
  a copy of x.  The utility is not avoiding memory copies but rather
  specifying a sparse update.

  If i is None, x and v must be the same shape. Computes
    y = x; y -= v;
  If i is a scalar, x has a rank 1 higher than v's. Computes
    y = x; y[i, :] -= v;
  Otherwise, x and v must have the same rank. Computes
    y = x; y[i, :] -= v;

  Args:
    x: A Tensor.
    i: None, a scalar or a vector.
    v: A Tensor.

  Returns:
    Returns y, which is guaranteed not to be an alias of x.

  )r   r   r#   r   r   r   r   r      r$   r   )N)__doc__Ztensorflow.python.frameworkr   r   Ztensorflow.python.opsr   r   r   Ztensorflow.python.utilr   r   
deprecatedr   r   r   r!   r   r   r   r    r   r   r   r   <module>   sP   %







