B
    )`k
                 @   s   d Z ddlmZ ddlmZ ddlmZ ddlZddl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dZdS )z,Utility ops shared across tf.contrib.signal.    )absolute_import)division)print_functionN)ops)tensor_util)	array_ops)control_flow_ops)math_opsc          	   C   s   t |d| |g t | } t |}| jd |jd | jjsVtd| j |jjsltd|j t	| }t	|}|dk	r|dk	rt
jjdk rtj}ntj}t |||S dd }d	d }tj||| |gd
d\} }| S Q R X dS )az  Returns the greatest common divisor via Euclid's algorithm.

  Args:
    a: The dividend. A scalar integer `Tensor`.
    b: The divisor. A scalar integer `Tensor`.
    name: An optional name for the operation.

  Returns:
    A scalar `Tensor` representing the greatest common divisor between `a` and
    `b`.

  Raises:
    ValueError: If `a` or `b` are not scalar integers.
  gcdr   z"a must be an integer type. Got: %sz"b must be an integer type. Got: %sN   c             S   s   t |t|S )N)r	   Zgreaterr   Z
zeros_like)_b r   T/home/dcms/DCMS/lib/python3.7/site-packages/tensorflow/python/ops/signal/util_ops.py<lambda>F       zgcd.<locals>.<lambda>c             S   s   |t | |gS )N)r	   mod)ar   r   r   r   r   G   r   F)Z	back_prop)r   Z
name_scopeZconvert_to_tensorshapeZassert_has_rankZdtype
is_integer
ValueErrorr   Zconstant_valuesysversion_infomajor	fractionsr
   mathr   Z
while_loop)r   r   nameZconst_aZconst_bZmath_gcdZcondbodyr   r   r   r
       s(    



r
   )N)__doc__
__future__r   r   r   r   r   r   Ztensorflow.python.frameworkr   r   Ztensorflow.python.opsr   r   r	   r
   r   r   r   r   <module>   s   