[pycharm] PY-73352 Add import error handling + fix error displaying

GitOrigin-RevId: 8ec269d167132e7b5b2401df78eac82f282078bb
This commit is contained in:
ekaterina.itsenko
2024-06-18 01:25:36 +02:00
committed by intellij-monorepo-bot
parent b648d99bec
commit 2c178f739f
3 changed files with 12 additions and 4 deletions

View File

@@ -413,8 +413,11 @@ def tensor_to_thrift_struct(tensor, name, roffset, coffset, rows, cols, format):
def sparse_tensor_to_thrift_struct(tensor, name, roffset, coffset, rows, cols, format):
import tensorflow as tf
return tensor_to_thrift_struct(tf.sparse.to_dense(tf.sparse.reorder(tensor)), name, roffset, coffset, rows, cols, format)
try:
import tensorflow as tf
return tensor_to_thrift_struct(tf.sparse.to_dense(tf.sparse.reorder(tensor)), name, roffset, coffset, rows, cols, format)
except ImportError:
pass
def array_to_meta_thrift_struct(array, name, format):

View File

@@ -587,8 +587,11 @@ def tensor_to_xml(tensor, name, roffset, coffset, rows, cols, format):
def sparse_tensor_to_xml(tensor, name, roffset, coffset, rows, cols, format):
import tensorflow as tf
return tensor_to_xml(tf.sparse.to_dense(tf.sparse.reorder(tensor)), name, roffset, coffset, rows, cols, format)
try:
import tensorflow as tf
return tensor_to_xml(tf.sparse.to_dense(tf.sparse.reorder(tensor)), name, roffset, coffset, rows, cols, format)
except ImportError:
pass
class ExceedingArrayDimensionsException(Exception):

View File

@@ -224,6 +224,8 @@ def _create_table(command, start_index=None, end_index=None):
import tensorflow as tf
if isinstance(command, tf.SparseTensor):
command = tf.sparse.to_dense(tf.sparse.reorder(command))
except ImportError:
pass
finally:
np_array = command