File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 12
12
from distutils .version import LooseVersion
13
13
14
14
import tensorflow as tf
15
+ import numpy as np
15
16
from tensorflow .python .ops import lookup_ops
16
17
17
18
from tf2onnx import utils
@@ -311,6 +312,12 @@ def _remove_non_variable_resources_from_captures(concrete_func):
311
312
for i in reversed (range (len (concrete_func ._captured_inputs ))):
312
313
if concrete_func ._captured_inputs [i ] is val_tensor :
313
314
concrete_func ._captured_inputs .pop (i )
315
+ elif val_tensor .dtype != tf .resource :
316
+ npval = val_tensor .numpy ()
317
+ if not hasattr (npval , 'dtype' ):
318
+ # Hack around a TF bug until PR is merged: https://github.com/tensorflow/tensorflow/pull/45610
319
+ arr = np .array (npval )
320
+ val_tensor .numpy = lambda arr = arr : arr
314
321
else :
315
322
logger .warning (
316
323
"Could not search for non-variable resources. Concrete function internal representation may have changed." )
You can’t perform that action at this time.
0 commit comments