MCPcopy Create free account
hub / github.com/google-research/language / shaped_py_func

Function shaped_py_func

language/common/utils/tensor_utils.py:142–160  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

140
141
142def 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
163def flatten(t):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…