Wrapper around tf.py_func that adds static shape information to the output. Args: func: Python function to call. inputs: List of input tensors. types: List of output tensor types. shapes: List of output tensor shapes. stateful: Whether or not the python function is stateful.
(func, inputs, types, shapes, stateful=True, name=None)
| 140 | |
| 141 | |
| 142 | def shaped_py_func(func, inputs, types, shapes, stateful=True, name=None): |
| 143 | """Wrapper around tf.py_func that adds static shape information to the output. |
| 144 | |
| 145 | Args: |
| 146 | func: Python function to call. |
| 147 | inputs: List of input tensors. |
| 148 | types: List of output tensor types. |
| 149 | shapes: List of output tensor shapes. |
| 150 | stateful: Whether or not the python function is stateful. |
| 151 | name: Name of the op. |
| 152 | |
| 153 | Returns: |
| 154 | output_tensors: List of output tensors. |
| 155 | """ |
| 156 | output_tensors = tf.py_func( |
| 157 | func=func, inp=inputs, Tout=types, stateful=stateful, name=name) |
| 158 | for t, s in zip(output_tensors, shapes): |
| 159 | t.set_shape(s) |
| 160 | return output_tensors |
| 161 | |
| 162 | |
| 163 | def flatten(t): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…