B
    ٻd                 @   sP   d Z ddlmZ ddlmZ ddlmZ ddlmZ dejfddZdd	 Zd
S )zHelpers constructing Datasets.    )constant_op)dtypes)ops)tensor_shapec             C   s,   |d k	rt j||| dS tj||| dS d S )N)dtypename)r   convert_to_tensorr   Zconstant)argument_nameZargument_valueargument_defaultZargument_dtype r   U/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/data/util/convert.pyoptional_param_to_tensor   s
    r   c          	   C   s   y(t | } tjdd |  D tjdS  ttfk
r   tj| tjd}|j	j
dk	rzt|j	j
dkrztd| |j	|jtjkrtd| |jj|S X dS )	a/  Returns a `tf.Tensor` that represents the given shape.

  Args:
    shape_like: A value that can be converted to a `tf.TensorShape` or a
      `tf.Tensor`.

  Returns:
    A 1-D `tf.Tensor` of `tf.int64` elements representing the given shape, where
    `-1` is substituted for any unknown dimensions.
  c             S   s   g | ]}|d k	r|ndqS )Nr   ).0dimr   r   r   
<listcomp>3   s    z+partial_shape_to_tensor.<locals>.<listcomp>)r   )Zpreferred_dtypeN   zSThe given shape {} must be a 1-D tensor of `tf.int64` values, but the shape was {}.zZThe given shape {} must be a 1-D tensor of `tf.int64` values, but the element type was {}.)r   Zas_shaper   r   as_listr   int64	TypeError
ValueErrorshapeZdimslenformatr   r   )Z
shape_likeretr   r   r   partial_shape_to_tensor"   s    

r   N)	__doc__Ztensorflow.python.frameworkr   r   r   r   r   r   r   r   r   r   r   <module>   s   	