You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2019/03/05 00:57:38 UTC
[incubator-mxnet] branch master updated: [DOC] Refine documentation
of runtime feature detection (#14238)
This is an automated email from the ASF dual-hosted git repository.
zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 434726e [DOC] Refine documentation of runtime feature detection (#14238)
434726e is described below
commit 434726eafac93373c713016bdef6e5ce87a00f67
Author: Pedro Larroy <pe...@gmail.com>
AuthorDate: Tue Mar 5 01:57:12 2019 +0100
[DOC] Refine documentation of runtime feature detection (#14238)
* minor: Refine documentation
* Update python/mxnet/runtime.py
Co-Authored-By: larroy <pe...@gmail.com>
* Update python/mxnet/runtime.py
Co-Authored-By: larroy <pe...@gmail.com>
* Address CR comment
* retrigger CI
---
docs/api/python/libinfo/libinfo.md | 77 +++++++++++++++++++++++++++++---------
python/mxnet/runtime.py | 23 +++++++++---
2 files changed, 77 insertions(+), 23 deletions(-)
diff --git a/docs/api/python/libinfo/libinfo.md b/docs/api/python/libinfo/libinfo.md
index 531e1ce..3b8d499 100644
--- a/docs/api/python/libinfo/libinfo.md
+++ b/docs/api/python/libinfo/libinfo.md
@@ -28,33 +28,74 @@ The libinfo functionality allows to check for compile-time features supported by
### Example usage
```
-In [1]: import mxnet as mx
+In []: import mxnet as mx
...: import mxnet.runtime
...: fs = mx.runtime.Features()
-In [2]: fs
-Out[2]: [✖ CUDA, ✖ CUDNN, ✖ NCCL, ✖ CUDA_RTC, ✖ TENSORRT, ✔ CPU_SSE, ✔ CPU_SSE2, ✔ CPU_SSE3, ✔ CPU_SSE4_1, ✔ CPU_SSE4_2, ✖ CPU_SSE4A, ✔ CPU_AVX, ✖ CPU_AVX2, ✖ OPENMP, ✖ SSE, ✔ F16C, ✖ JEMALLOC, ✔ BLAS_OPEN, ✖ BLAS_ATLAS, ✖ BLAS_MKL, ✖ BLAS_APPLE, ✔ LAPACK, ✖ MKLDNN, ✔ OPENCV, ✖ CAFFE, ✖ PROFILER, ✖ DIST_KVSTORE, ✖ CXX14, ✔ SIGNAL_HANDLER, ✔ DEBUG]
-
-In [3]: fs['CUDA'].enabled
-Out[3]: False
-
-In [4]: fs.is_enabled('CPU_SSE')
-Out[4]: True
-
-In [5]: fs.is_enabled('CUDA')
-Out[5]: False
-
-In [6]:
+In []: fs
+Out[]: [✖ CUDA, ✖ CUDNN, ✖ NCCL, ✖ CUDA_RTC, ✖ TENSORRT, ✔ CPU_SSE, ✔ CPU_SSE2, ✔ CPU_SSE3, ✔ CPU_SSE4_1, ✔ CPU_SSE4_2, ✖ CPU_SSE4A, ✔ CPU_AVX, ✖ CPU_AVX2, ✖ OPENMP, ✖ SSE, ✔ F16C, ✖ JEMALLOC, ✔ BLAS_OPEN, ✖ BLAS_ATLAS, ✖ BLAS_MKL, ✖ BLAS_APPLE, ✔ LAPACK, ✖ MKLDNN, ✔ OPENCV, ✖ CAFFE, ✖ PROFILER, ✖ DIST_KVSTORE, ✖ CXX14, ✔ SIGNAL_HANDLER, ✔ DEBUG]
+
+In []: fs.keys()
+Out[]: odict_keys(['CUDA', 'CUDNN', 'NCCL', 'CUDA_RTC', 'TENSORRT', 'CPU_SSE', 'CPU_SSE2', 'CPU_SSE3', 'CPU_SSE4_1', 'CPU_SSE4_2', 'CPU_SSE4A', 'CPU_AVX', 'CPU_AVX2', 'OPENMP', 'SSE', 'F16C', 'JEMALLOC', 'BLAS_OPEN', 'BLAS_ATLAS', 'BLAS_MKL', 'BLAS_APPLE', 'LAPACK', 'MKLDNN', 'OPENCV', 'CAFFE', 'PROFILER', 'DIST_KVSTORE', 'CXX14', 'SIGNAL_HANDLER', 'DEBUG'])
+
+In []: type(fs['CUDA'])
+Out[]: mxnet.runtime.Feature
+
+In []: fs['CUDA'].enabled
+Out[]: False
+
+In []: fs.is_enabled('CPU_SSE')
+Out[]: True
+
+In []: fs.is_enabled('CUDA')
+Out[]: False
+
+In []: features = mx.runtime.feature_list()
+
+In []: features
+Out[]:
+[✖ CUDA,
+ ✖ CUDNN,
+ ✖ NCCL,
+ ✖ CUDA_RTC,
+ ✖ TENSORRT,
+ ✔ CPU_SSE,
+ ✔ CPU_SSE2,
+ ✔ CPU_SSE3,
+ ✔ CPU_SSE4_1,
+ ✔ CPU_SSE4_2,
+ ✖ CPU_SSE4A,
+ ✔ CPU_AVX,
+ ✖ CPU_AVX2,
+ ✖ OPENMP,
+ ✖ SSE,
+ ✔ F16C,
+ ✖ JEMALLOC,
+ ✔ BLAS_OPEN,
+ ✖ BLAS_ATLAS,
+ ✖ BLAS_MKL,
+ ✖ BLAS_APPLE,
+ ✔ LAPACK,
+ ✖ MKLDNN,
+ ✔ OPENCV,
+ ✖ CAFFE,
+ ✖ PROFILER,
+ ✖ DIST_KVSTORE,
+ ✖ CXX14,
+ ✔ SIGNAL_HANDLER,
+ ✔ DEBUG]
+
+In []: type(features)
+Out[]: list
+
+In []: type(features[0])
+Out[]: mxnet.runtime.Feature
```
-
```eval_rst
.. autosummary::
:nosignatures:
- Features
- Feature
- feature_list
```
## API Reference
diff --git a/python/mxnet/runtime.py b/python/mxnet/runtime.py
index 7ef5e19..e47cca9 100644
--- a/python/mxnet/runtime.py
+++ b/python/mxnet/runtime.py
@@ -27,17 +27,27 @@ from .base import _LIB, check_call
class Feature(ctypes.Structure):
"""
- Compile time feature description
+ Compile time feature description, member fields: `name` and `enabled`.
"""
_fields_ = [
("_name", ctypes.c_char_p),
- ("enabled", ctypes.c_bool)
+ ("_enabled", ctypes.c_bool)
]
@property
def name(self):
+ """
+ Feature name.
+ """
return self._name.decode()
+ @property
+ def enabled(self):
+ """
+ True if MXNet was compiled with the given compile-time feature.
+ """
+ return self._enabled
+
def __repr__(self):
if self.enabled:
return "✔ {}".format(self.name)
@@ -50,7 +60,8 @@ def feature_list():
Returns
-------
- :return: list of class LibFeature indicating which features are available and enabled
+ list
+ List of :class:`.Feature` objects
"""
lib_features_c_array = ctypes.POINTER(Feature)()
lib_features_size = ctypes.c_size_t()
@@ -74,11 +85,13 @@ class Features(collections.OrderedDict):
Parameters
----------
- :param x: str The name of a valid feature as string for example 'CUDA'
+ feature_name: str
+ The name of a valid feature as string for example 'CUDA'
Returns
-------
- :return: bool True if it's enabled, False if it's disabled, RuntimeError if the feature is not known
+ Boolean
+ True if it's enabled, False if it's disabled, RuntimeError if the feature is not known
"""
feature_name = feature_name.upper()
if feature_name not in self: