mirror of
https://github.com/RustyRaptor/incubator-mxnet.git
synced 2026-12-04 08:15:21 -07:00
* Prototype for runtime feature detection * Includes from diamond to quotes * Add CPU feature and BLAS flavour flags * Add BLAS flavour and CPU SSE and AVX flags * MXNET_USE_LAPACK * Fix C++ linting errors * Expose runtime feature detection in the public C API and in the Python API * Refactor Storage -> FeatureSet * Refine documentation * Add failure case * Fix pylint * Address CR comments * Address CR comments * Address CR * Address CR * Address CR * Address CR * remove old files * Fix unit test * Port CMake blas change from #13957 * Fix lint * mxruntime -> libinfo * Fix comments * restore libinfo.py * Rework API for feature detection / libinfo * Refine documentation * Fix lint * Fix lint * Define make_unique only for C++ std < 14 * Add memory include * remove old tests * make_unique fiasco * Fix lint
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you 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.
|
|
|
|
# coding: utf-8
|
|
# pylint: disable=not-an-iterable
|
|
|
|
"""runtime querying of compile time features in the native library"""
|
|
|
|
import ctypes
|
|
from .base import _LIB, check_call
|
|
|
|
class LibFeature(ctypes.Structure):
|
|
"""
|
|
Compile time feature description
|
|
"""
|
|
_fields_ = [
|
|
("name", ctypes.c_char_p),
|
|
("index", ctypes.c_uint32),
|
|
("enabled", ctypes.c_bool)
|
|
]
|
|
|
|
def libinfo_features():
|
|
"""
|
|
Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc
|
|
|
|
Returns
|
|
-------
|
|
A list of class LibFeature indicating which features are available and enabled
|
|
"""
|
|
lib_features = ctypes.POINTER(LibFeature)()
|
|
lib_features_size = ctypes.c_size_t()
|
|
check_call(_LIB.MXLibInfoFeatures(ctypes.byref(lib_features), ctypes.byref(lib_features_size)))
|
|
feature_list = [lib_features[i] for i in range(lib_features_size.value)]
|
|
return feature_list
|