Add pybind for sanitizer constant to know if any of the sanitizers is enabled in python tests. PiperOrigin-RevId: 334649266 Change-Id: I4aa55310519dc2d9b121d4e6c4f33216c782092e
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
==============================================================================*/
|
|
|
|
#include "pybind11/pybind11.h"
|
|
#include "tensorflow/python/lib/core/pybind11_lib.h"
|
|
|
|
PYBIND11_MODULE(_pywrap_tensorflow_lite_sanitizers, m) {
|
|
m.def("TSan_Enabled", []() -> bool {
|
|
#ifdef THREAD_SANITIZER
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
});
|
|
m.def("MSan_Enabled", []() -> bool {
|
|
#ifdef MEMORY_SANITIZER
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
});
|
|
m.def("ASan_Enabled", []() -> bool {
|
|
#ifdef ADDRESS_SANITIZER
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
});
|
|
}
|