1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_PYTHON_LIB_CORE_NUMPY_H_ 17 #define TENSORFLOW_PYTHON_LIB_CORE_NUMPY_H_ 18 19 #ifdef PyArray_Type 20 #error "Numpy cannot be included before numpy.h." 21 #endif 22 23 // Disallow Numpy 1.7 deprecated symbols. 24 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 25 26 // We import_array in the tensorflow init function only. 27 #define PY_ARRAY_UNIQUE_SYMBOL _tensorflow_numpy_api 28 #ifndef TF_IMPORT_NUMPY 29 #define NO_IMPORT_ARRAY 30 #endif 31 32 // Place `<locale>` before <Python.h> to avoid build failure in macOS. 33 #include <locale> 34 35 #include <Python.h> 36 37 #include "numpy/arrayobject.h" 38 #include "numpy/ufuncobject.h" 39 40 namespace tensorflow { 41 42 // Import numpy. This wrapper function exists so that the 43 // PY_ARRAY_UNIQUE_SYMBOL can be safely defined in a .cc file to 44 // avoid weird linking issues. Should be called only from our 45 // module initialization function. 46 void ImportNumpy(); 47 48 } // namespace tensorflow 49 50 #endif // TENSORFLOW_PYTHON_LIB_CORE_NUMPY_H_ 51