Register a specialization of a `Function` into the graph. This won't actually call the function with the inputs, and only put the function definition into graph. Register function with different input param will result into multiple version of functions registered in graph. Args: func:
(func, *args, **kwargs)
| 2150 | |
| 2151 | |
| 2152 | def register(func, *args, **kwargs): |
| 2153 | """Register a specialization of a `Function` into the graph. |
| 2154 | |
| 2155 | This won't actually call the function with the inputs, and only put the |
| 2156 | function definition into graph. Register function with different input param |
| 2157 | will result into multiple version of functions registered in graph. |
| 2158 | |
| 2159 | Args: |
| 2160 | func: the `Function` instance that generated by a @defun |
| 2161 | *args: input arguments for the Python function. |
| 2162 | **kwargs: input keyword arguments for the Python function. |
| 2163 | |
| 2164 | Returns: |
| 2165 | a `ConcreteFunction` object specialized to inputs and execution context. |
| 2166 | |
| 2167 | Raises: |
| 2168 | ValueError: When the input function is not a defun wrapped python function. |
| 2169 | """ |
| 2170 | if not isinstance(func, Function): |
| 2171 | raise ValueError("Only defun function is allowed to be registered. " |
| 2172 | "Got type: %s" % type(func)) |
| 2173 | concrete_func = func.get_concrete_function(*args, **kwargs) |
| 2174 | concrete_func.add_to_graph() |
| 2175 | concrete_func.add_gradient_functions_to_graph() |
| 2176 | return concrete_func |
| 2177 | |
| 2178 | |
| 2179 | def validate_signature(signature): |
nothing calls this directly
no test coverage detected