Merge pull request #32000 from akarmi:toupstream/fix-tflite-interpreter-test
PiperOrigin-RevId: 286581374 Change-Id: I106bc049d73d1e25aa8a767e381ad68efe59743d
This commit is contained in:
commit
322028f2d2
tensorflow/lite/python
@ -120,7 +120,7 @@ class Delegate(object):
|
||||
raise ValueError(capture.message)
|
||||
|
||||
def __del__(self):
|
||||
# __del__ can be called multiple times, so if the delegate is destroyed.
|
||||
# __del__ can not be called multiple times, so if the delegate is destroyed.
|
||||
# don't try to destroy it twice.
|
||||
if self._library is not None:
|
||||
self._library.tflite_plugin_destroy_delegate.argtypes = [ctypes.c_void_p]
|
||||
|
@ -417,7 +417,10 @@ class InterpreterDelegateTest(test_util.TensorFlowTestCase):
|
||||
|
||||
def testFail(self):
|
||||
with self.assertRaisesRegexp(
|
||||
ValueError, 'Failed to load delegate from .*\nFail argument sent.'):
|
||||
# Due to exception chaining in PY3, we can't be more specific here and check that
|
||||
# the phrase 'Fail argument sent' is present.
|
||||
ValueError,
|
||||
r'Failed to load delegate from'):
|
||||
interpreter_wrapper.load_delegate(
|
||||
self._delegate_file, options={'fail': 'fail'})
|
||||
|
||||
|
@ -66,7 +66,12 @@ void set_destroy_callback(int (*callback)(const char* s)) {
|
||||
void tflite_plugin_destroy_delegate(TfLiteDelegate* delegate) {
|
||||
num_delegates_destroyed++;
|
||||
delete delegate;
|
||||
if (destruction_callback) destruction_callback("test_delegate");
|
||||
if (destruction_callback) {
|
||||
destruction_callback("test_delegate");
|
||||
// destruction_callback is a global variable,
|
||||
// so it should be set to nullptr here to avoid crashes
|
||||
destruction_callback = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void initialize_counters() {
|
||||
|
Loading…
Reference in New Issue
Block a user