
    AVh^                        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 Z
 e	j                  d	d
      d        Z e	j                  d	d      d        Z e	j                  d	d      d        ZddZ e	j                  d	d
      d        Z e	j                  d	d      d        Z e	j                  d	d      d        Zej&                  Zy	)zInplace operations.
    )dtypes)ops)	array_ops)gen_array_ops)math_ops)deprecationc                 (   t        j                  |       } t        j                  || j                        }|^t        j                   |t        j                  | ddg      dgt        j                  |ddg            t        j
                  |             S t        j                  |t        j                        }|j                         j                  dk(  r3 || t        j                  |dg      t        j                  |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.

     r   )r   convert_to_tensordtyper   reshapeshaper   castr   int32	get_shapendimsexpand_dims)xivops       Q/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/inplace_ops.py_inplace_helperr      s    . 
A!	Aqww'!Y
9QB(1#y/@/@QG/LM  mmAv||$![[]Aa""1qc*I,A,A!Q,GHH	Aq!    NzoPrefer tf.tensor_scatter_nd_update, which offers the same functionality with well-defined read-write semantics.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   s      r   alias_inplace_updater   ?   s    . 
Aq-">">	??r   zlPrefer tf.tensor_scatter_nd_add, which offers the same functionality with well-defined read-write semantics.c                 :    t        | ||t        j                        S )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   s      r   alias_inplace_addr"   Y       . 
Aq-";";	<<r   zlPrefer tf.tensor_scatter_nd_sub, which offers the same functionality with well-defined read-write semantics.c                 :    t        | ||t        j                        S )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   s      r   alias_inplace_subr&   s   r#   r   c                     t        j                  |       } t        j                  t	        j
                  |       | j                  |      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(   s     r   
empty_liker*      s6     
A!			Y__Q/t	DDr   c                 B    t        t        j                  |       ||      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   s      r   r   r      s    6 
m55a8!Q	??r   c                 B    t        t        j                  |       ||      S )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   s      r   r!   r!          6 
=2215q!	<<r   c                 B    t        t        j                  |       ||      S )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   s      r   r%   r%      r.   r   )N)__doc__tensorflow.python.frameworkr   r   tensorflow.python.opsr   r   r   tensorflow.python.utilr   r   
deprecatedr   r"   r&   r*   r   r!   r%   r)    r   r   <module>r6      s/    . + + / * ."J /1@	1@, /1=	1=, /1=	1=,E& /1@	1@4 /1=	1=4 /1=	1=2 	r   