From 7a39b9aefb564d21c2695aba33629bd43cec330b Mon Sep 17 00:00:00 2001 From: Pedro Larroy Date: Tue, 12 Feb 2019 11:38:01 +0100 Subject: [PATCH] Refine runtime feature discovery python API and add documentation to Python API docs --- docs/api/python/index.md | 11 +++++ docs/api/python/libinfo/libinfo.md | 70 ++++++++++++++++++++++++++++++ python/mxnet/runtime.py | 12 ++++- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 docs/api/python/libinfo/libinfo.md diff --git a/docs/api/python/index.md b/docs/api/python/index.md index de86aedff691..f2fd99e0368d 100644 --- a/docs/api/python/index.md +++ b/docs/api/python/index.md @@ -157,6 +157,17 @@ Code examples are placed throughout the API documentation and these can be run a rtc/rtc.md ``` +## Run-Time Feature detection / Library Info + +```eval_rst +.. toctree:: + :maxdepth: 1 + + libinfo/libinfo.md +``` + + + ## Symbol API ```eval_rst diff --git a/docs/api/python/libinfo/libinfo.md b/docs/api/python/libinfo/libinfo.md new file mode 100644 index 000000000000..513a4aec7330 --- /dev/null +++ b/docs/api/python/libinfo/libinfo.md @@ -0,0 +1,70 @@ +# Run-Time Feature detection / Library info + +```eval_rst +.. currentmodule:: mxnet.runtime +``` + +## Overview + +The libinfo functionality allows to check for compile-time features supported by the library. + +### Example usage + +```python +In [1]: import mxnet as mx + +In [2]: import mxnet.runtime + +In [3]: mx.runtime.libinfo_features() +Out[3]: +[✔ 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] +``` + + +```eval_rst +.. autosummary:: + :nosignatures: + + LibFeature + libinfo_features +``` + +## API Reference + + + +```eval_rst +.. automodule:: mxnet.runtime + :members: +``` + + diff --git a/python/mxnet/runtime.py b/python/mxnet/runtime.py index afb393281420..e1933125d37a 100644 --- a/python/mxnet/runtime.py +++ b/python/mxnet/runtime.py @@ -28,11 +28,21 @@ class LibFeature(ctypes.Structure): Compile time feature description """ _fields_ = [ - ("name", ctypes.c_char_p), + ("_name", ctypes.c_char_p), ("index", ctypes.c_uint32), ("enabled", ctypes.c_bool) ] + @property + def name(self): + return self._name.decode() + + def __repr__(self): + if self.enabled: + return "✔ {}".format(self.name) + else: + return "✖ {}".format(self.name) + def libinfo_features(): """ Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc