Home | History | Annotate | Download | only in core
      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 #include <Python.h>
     33 
     34 #include "numpy/arrayobject.h"
     35 #include "numpy/ufuncobject.h"
     36 
     37 namespace tensorflow {
     38 
     39 // Import numpy.  This wrapper function exists so that the
     40 // PY_ARRAY_UNIQUE_SYMBOL can be safely defined in a .cc file to
     41 // avoid weird linking issues.  Should be called only from our
     42 // module initialization function.
     43 void ImportNumpy();
     44 
     45 }  // namespace tensorflow
     46 
     47 #endif  // TENSORFLOW_PYTHON_LIB_CORE_NUMPY_H_
     48