@@ -179,31 +179,27 @@ def wrapper(self, tensor_or_op):
179179 try :
180180 return func (self , tensor_or_op )
181181 except _UnexpectedPlaceholderError as e :
182- if e .func_graph_name :
183- raise ValueError (
184- 'The tensor_or_op {} depended on a placeholder ({}) that is part '
185- 'of a tf.function graph ({}), this is not supported. This may be a '
186- 'result of calling a tf.Transform analyzer in a tf.function'
187- '' .format (tensor_or_op , e .tensor , e .func_graph_name ))
188- else :
189- raise ValueError (
190- 'The tensor_or_op {} depended on a placeholder ({}) that was not '
191- 'in the input_signature. This may have be caused by manually '
192- 'adding a placeholder to the graph' .format (tensor_or_op , e .tensor ))
182+ context = (f' tf.function name: `{ e .func_graph_name } `'
183+ if e .func_graph_name else '' )
184+ raise ValueError (
185+ 'The tensor_or_op {} depended on a placeholder ({}) that was not '
186+ 'in the input_signature. This may have be caused by manually '
187+ 'adding a placeholder to the graph.{}' .format (tensor_or_op , e .tensor ,
188+ context )) from e
193189 except _UnexpectedTableError as e :
194190 if e .func_graph_name :
195191 raise ValueError (
196192 'The tensor_or_op {} depended on an initializable table ({}) that '
197193 'is part of a tf.function graph ({}), this is not supported. This'
198194 ' may be a result of initializing a table in a tf.function'
199- '' .format (tensor_or_op , e .op , e .func_graph_name ))
195+ '' .format (tensor_or_op , e .op , e .func_graph_name )) from e
200196 else :
201197 raise ValueError (
202198 'The tensor_or_op {} depended on an initializable table ({}) that '
203199 'was not tracked by the graph analysis. This may be caused by '
204200 'adding an initializable table without adding its initializer to '
205201 'the collection tf.GraphKeys.TABLE_INITIALIZERS' .format (
206- tensor_or_op , e .op ))
202+ tensor_or_op , e .op )) from e
207203
208204 return wrapper
209205
@@ -687,15 +683,15 @@ def _get_table_init_op_source_info(self, table_init_op, graph_analyzer,
687683 raise ValueError (
688684 'The table initializer {} depended on a placeholder ({}). Note '
689685 'placeholders will not be fed during table initialization' .format (
690- table_init_op , e .tensor ))
686+ table_init_op , e .tensor )) from e
691687 except _UnexpectedTableError as e :
692688 if e .func_graph_name :
693689 raise e
694690 raise ValueError (
695691 'The table initializer {} depended on an initializable table ({}). '
696692 'Note tables are initialized in one pass so a table initializer '
697693 'cannot depend on the output of an initializeable table' .format (
698- table_init_op , e .op ))
694+ table_init_op , e .op )) from e
699695 return _SourceInfo (ready , path )
700696
701697 @property
0 commit comments