B
    +`3                 @   s   d Z ddl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	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ejeddddZedeeZdd ZejeddddZ edee Z!dd Z"dS )zPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
Original C++ source file: xla_ops_wrapper_py.cc
    N)
pywrap_tfe)context)core)execute)dtypes)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_exportxla_cluster_outputc             C   s  t j pt  }|j}|jryt|j|jd||j| }|S  t	j
k
rh } zt|| W dd}~X Y n t	jk
r|   Y nX yt| ||dS  t	jk
r   Y n@ ttfk
r   ttdt| |d}|tjjk	r|S  Y nX ytjd| |d\}}}}	W nD ttfk
rB   ttdt| |d}|tjjk	r<|S  Y nX |	dd }t r~d|df}
|j}td||
| |\}|S )zOperator that connects the output of an XLA computation to other consumer graph nodes.

  Args:
    input: A `Tensor`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  XlaClusterOutputN)namectx )inputr   T)_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_context_handledevice_nameop_callbacks_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackException!xla_cluster_output_eager_fallback_SymbolicException	TypeError
ValueError	_dispatchr   r   dictOpDispatcherNOT_SUPPORTED_op_def_library_apply_op_helper_executemust_record_gradientZ_get_attr_typeinputsrecord_gradient)r   r   _ctxtld_resulteresult__op_outputs_attrs_inputs_flatr   r   R/home/dcms/DCMS/lib/python3.7/site-packages/tensorflow/compiler/jit/ops/xla_ops.pyr      sP    

zraw_ops.XlaClusterOutputc             C   sZ   t | g|\}\} | g}d|f}t jdd||||d}t  rPt d||| |\}|S )Nr   s   XlaClusterOutput   )r,   attrsr   r   r   )r*   Zargs_to_matching_eagerr   r+   r-   )r   r   r   Z_attr_Tr7   r6   r0   r   r   r8   r    R   s    
r    
xla_launchc             C   s4  t j pt  }|j}|jry*t|j|jd||j| ||d|d|}|S  t	j
k
rv }	 zt|	| W dd}	~	X Y n t	jk
r   Y nX yt| ||||||dS  t	jk
r   Y nL ttfk
r   ttdt| |||||d}
|
tjjk	 r|
S  Y nX t|ttfs td| t|}t|ttfsDtd	| d
d |D }y$tjd| |||||d\}}}}W nL ttfk
r   ttdt| |||||d}
|
tjjk	r|
S  Y nX |dd }|s|S t r0d| dd| dd|!dd| dd| df
}|j"}t#d||| |S )a  XLA Launch Op. For use by the XLA JIT only.

  Args:
    constants: A list of `Tensor` objects.
    args: A list of `Tensor` objects.
    resources: A list of `Tensor` objects with type `resource`.
    Tresults: A list of `tf.DTypes`.
    function: A function decorated with @Defun.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tresults`.
  	XlaLaunchTresultsfunctionN)r=   r>   r   r   r   )	constantsargs	resourcesr=   r>   r   zBExpected list for 'resources' argument to 'xla_launch' Op, not %r.zAExpected list for 'Tresults' argument to 'xla_launch' Op, not %r.c             S   s   g | ]}t |d qS )r=   )r*   	make_type).0_tr   r   r8   
<listcomp>   s    zxla_launch.<locals>.<listcomp>
TconstantsTargs
Nresources)$r   r   r   r   r   r   r   r   r   r   r   r   r   r   xla_launch_eager_fallbackr!   r"   r#   r$   r   r;   r%   r&   r'   
isinstancelisttuplelenr(   r)   r*   r+   Zget_attrZ_get_attr_intr,   r-   )r?   r@   rA   r=   r>   r   r.   r/   r0   r1   r2   _attr_Nresourcesr3   r4   r5   r6   r7   r   r   r8   r;   _   sz    






zraw_ops.XlaLaunchc          
   C   s   t |ttfstd| t|}t |ttfs<td| dd |D }t| |\}} t||\}	}t|t	j
}t| t| t| }
d|d|	d|d|d	|f
}tjd
t||
|||d}t rtd|
|| |S )NzBExpected list for 'resources' argument to 'xla_launch' Op, not %r.zAExpected list for 'Tresults' argument to 'xla_launch' Op, not %r.c             S   s   g | ]}t |d qS )r=   )r*   rB   )rC   rD   r   r   r8   rE      s    z-xla_launch_eager_fallback.<locals>.<listcomp>rF   rG   rH   r=   r>   s	   XlaLaunch)r,   r:   r   r   r<   )rJ   rK   rL   r"   rM   r*   Zconvert_to_mixed_eager_tensorsr   Zconvert_n_to_tensor_dtypesresourcer   r+   r-   )r?   r@   rA   r=   r>   r   r   rN   Z_attr_TconstantsZ_attr_Targsr7   r6   r0   r   r   r8   rI      s,    rI   )N)N)#__doc__collectionsZtensorflow.pythonr   Ztensorflow.python.eagerr   r   r   r   r   r*   Ztensorflow.python.frameworkr   rO   r   Z_op_def_registryr   r   r	   r(   Z"tensorflow.python.util.deprecationr
   Ztensorflow.python.utilr   r$   Z tensorflow.python.util.tf_exportr   Zadd_dispatch_listr   Z	to_raw_opr   r    r;   r<   rI   r   r   r   r8   <module>   s,   6O