/usr/local/lib64/python3.6/site-packages/torch/autograd/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/autograd/__pycache__/functional.cpython-36.pyc (31543B)
3
Eg6 @ s d dl Z d dlmZmZ d dlmZ dd Zdd Zdd Zd
d Z dd
Z
dd Zd%ddZdd Z
d&ddZd'ddZee jdf eedf ee jdf dddZd(ddZd)dd Zd*d!d"Zd+d#d$ZdS ), N)TupleList)_vmapc C sx d}t | ts| f} d}xVt| D ]J\}}t |tjs"|rTtdj|||t|q"tdj|||t|q"W || fS )NTFzgThe {} given to {} must be either a Tensor or a tuple of Tensors but the value at index {} has type {}.z^The {} given to {} must be either a Tensor or a tuple of Tensors but the given {} has type {}.)
isinstancetuple enumeratetorchTensor TypeErrorformattype)inpZarg_namefn_nameZis_inp_tupleiel r E/usr/local/lib64/python3.6/site-packages/torch/autograd/functional.py _as_tuple s
r c C sV t |trFt|dkst|d s4tdd | D } |d sR| d } n|sR| d } | S )N c s s | ]}|d V qdS )r Nr ).0r r r r
# s z%_tuple_postprocess..r )r r lenAssertionError)resZ to_unpackr r r _tuple_postprocess s
r c C s` g }xR| D ]J}|r@|j r@|js0|j|j| qT|j|j q
|j|j j| q
W t|S )N)
requires_gradZ is_sparseappendZview_asclonedetachZrequires_grad_r )inputscreate_graph
need_graphr r
r r r _grad_preprocess+ s
r# c sF t | d tjr, s&tdd | D S | S nt fdd| D S d S )Nr c s s | ]}|j V qd S )N)r )r r
r r r r G s z$_grad_postprocess..c 3 s | ]}t | V qd S )N)_grad_postprocess)r r
)r! r r r K s )r r r r )r r! r )r! r r$ B s
r$ c C s t |t | kr6|r.tdjt |t | ntdxZtt| |D ]H\}\}}|j |j krFd}|rtdj|}tdj||j |j qFW d S )Nz8v is a tuple of invalid length: should be {} but got {}.z+The given v should contain a single Tensor. zEntry {} in z.{}v has invalid size: should be {} but got {}.)r RuntimeErrorr r zipsize)votherZis_other_tupleidxZel_vZel_otherprependr r r _validate_vM s
r- c C s |sd S |dkrt dxt| D ]z\}}|d kr@t dj||js"|dkr^t dj|q"|dkrvt dj|q"|dkrt d j|q"t d
j|q"W d S )Noutputsgrad_inputsjacobianhessianz*Invalid input_type to _check_requires_gradzhThe output of the user-provided function is independent of input {}. This is not allowed in strict mode.zThe hessian of the user-provided function with respect to input {} is independent of the input. This is not allowed in strict mode. You should ensure that your function is thrice differentiable and that the hessian depends on the inputs.aP While computing the hessian, found that the jacobian of the user-provided function with respect to input {} is independent of the input. This is not allowed in strict mode. You should ensure that your function is twice differentiable and that the jacobian depends on the inputs (this would be violated by a linear function for example).zThe gradient with respect to input {} is independent of the inputs of the user-provided function. This is not allowed in strict mode.zOutput {} of the user-provided function does not require gradients. The outputs must be computed in a differentiable manner from the input when running in strict mode.)r. r/ r0 r1 )r&