From a9fc3c448c0903dd084a8f083493af7672f7e25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Mon, 26 Jul 2021 15:58:47 +0200 Subject: [PATCH] Improves documentation, show InferenceSession contructor attributes (#8494) * include constructor parameters in the python documentation * expose more classes into the documentation --- docs/python/inference/api_summary.rst | 39 +++++++++++++++++-- docs/python/inference/conf.py | 1 + docs/python/training/conf.py | 1 + .../onnxruntime_inference_collection.py | 8 ++-- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/docs/python/inference/api_summary.rst b/docs/python/inference/api_summary.rst index ce764dafce..97bc1fc030 100644 --- a/docs/python/inference/api_summary.rst +++ b/docs/python/inference/api_summary.rst @@ -158,14 +158,15 @@ Load and run a model The main class *InferenceSession* wraps these functionalities in a single place. -.. autoclass:: onnxruntime.ModelMetadata - :members: +Main class +---------- .. autoclass:: onnxruntime.InferenceSession :members: + :inherited-members: -.. autoclass:: onnxruntime.NodeArg - :members: +Options +------- .. autoclass:: onnxruntime.RunOptions :members: @@ -173,6 +174,36 @@ in a single place. .. autoclass:: onnxruntime.SessionOptions :members: +Data +---- + +.. autoclass:: onnxruntime.OrtValue + :members: + +.. autoclass:: onnxruntime.SparseTensor + :members: + +Devices +------- + +.. autoclass:: onnxruntime.IOBinding + :members: + +.. autoclass:: onnxruntime.OrtDevice + :members: + +Internal classes +---------------- + +These classes cannot be instantiated by users but they are returned +by methods or functions of this libary. + +.. autoclass:: onnxruntime.ModelMetadata + :members: + +.. autoclass:: onnxruntime.NodeArg + :members: + Backend ======= diff --git a/docs/python/inference/conf.py b/docs/python/inference/conf.py index 9588e2c706..18cbd532ef 100644 --- a/docs/python/inference/conf.py +++ b/docs/python/inference/conf.py @@ -46,6 +46,7 @@ master_doc = 'index' language = "en" exclude_patterns = [] pygments_style = 'default' +autoclass_content = 'both' # -- Options for HTML output ------------------------------------------------- diff --git a/docs/python/training/conf.py b/docs/python/training/conf.py index 9e4b34297c..2e3c084bb1 100644 --- a/docs/python/training/conf.py +++ b/docs/python/training/conf.py @@ -20,6 +20,7 @@ extensions = ['sphinx.ext.autodoc', ] templates_path = ['_templates'] exclude_patterns = [] +autoclass_content = 'both' # -- Options for HTML output ------------------------------------------------- diff --git a/onnxruntime/python/onnxruntime_inference_collection.py b/onnxruntime/python/onnxruntime_inference_collection.py index efd66619db..fd4ad9b4da 100644 --- a/onnxruntime/python/onnxruntime_inference_collection.py +++ b/onnxruntime/python/onnxruntime_inference_collection.py @@ -205,7 +205,7 @@ class Session: :param input_feed: dictionary ``{ input_name: input_ort_value }`` See ``OrtValue`` class how to create OrtValue from numpy array or SparseTensor :param run_options: See :class:`onnxruntime.RunOptions`. - :return an array of OrtValues + :return: an array of OrtValues :: sess.run([output_name], {input_name: x}) @@ -669,7 +669,7 @@ class SparseTensor: have a 1-D shape when it contains a linear index of non-zero values and its length must be equal to that of the values. It can also be of 2-D shape, in which has it contains pairs of coordinates for each of the nnz values and its length must be exactly twice of the values length. - :param ort_device - describes the backing memory owned by the supplied nummpy arrays. Only CPU memory is + :param ort_device: - describes the backing memory owned by the supplied nummpy arrays. Only CPU memory is suppored for non-numeric data types. For primitive types, the method will map values and coo_indices arrays into native memory and will use @@ -693,7 +693,7 @@ class SparseTensor: Its length must be equal to that of the values. :param outer_indices: contiguous 1-D numpy array(int64) that contains CSR outer indices for the tensor. Its length must be equal to the number of rows + 1. - :param ort_device - describes the backing memory owned by the supplied nummpy arrays. Only CPU memory is + :param ort_device: - describes the backing memory owned by the supplied nummpy arrays. Only CPU memory is suppored for non-numeric data types. For primitive types, the method will map values and indices arrays into native memory and will use them as @@ -747,7 +747,7 @@ class SparseTensor: def to_cuda(self, ort_device): ''' Returns a copy of this instance on the specified cuda device - :param ort_device with name 'cuda' and valid gpu device id + :param ort_device: with name 'cuda' and valid gpu device id The method will throw if: - this instance contains strings - this instance is already on GPU. Cross GPU copy is not supported