Skip to content

Commit e111123

Browse files
tonybove-appleabove3
and
above3
authored
Docs - Sphinx Indent Errors in Rest of API Reference (#2069)
* Docs - Sphinx Indent Errors in Rest of API Reference * Fix Spaces in Docs - Sphinx Indent Errors in Rest of API Ref * Fix2 Spaces in Docs - Sphinx Indent Errors in Rest of API Ref --------- Co-authored-by: above3 <anthony_bove@apple.com>
1 parent 03cd23e commit e111123

File tree

12 files changed

+201
-200
lines changed

12 files changed

+201
-200
lines changed

coremltools/converters/mil/input_types.py

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,21 @@ def __init__(
3333
Parameters
3434
----------
3535
class_labels: str / list of int / list of str
36-
If a ``list`` is provided, the ``list`` maps the index of the output of a
37-
neural network to labels in a classifier.
38-
39-
If a ``str`` is provided, the ``str`` points to a file which maps the index
40-
to labels in a classifier.
36+
* If a ``list`` is provided, the ``list`` maps the index of the output of a
37+
neural network to labels in a classifier.
38+
* If a ``str`` is provided, the ``str`` points to a file which maps the index
39+
to labels in a classifier.
4140
4241
predicted_feature_name: str
4342
Name of the output feature for the class labels exposed in the
4443
Core ML neural network classifier. Default: ``'classLabel'``.
4544
4645
predicted_probabilities_output: str
47-
If provided, then this is the name of the neural network blob which
48-
generates the probabilities for each class label (typically the output
49-
of a softmax layer).
46+
* If provided, then this is the name of the neural network blob which
47+
generates the probabilities for each class label (typically the output
48+
of a softmax layer).
49+
* If not provided, then the last output layer is assumed.
5050
51-
If not provided, then the last output layer is assumed.
5251
"""
5352
self.class_labels = class_labels
5453
self.predicted_feature_name = predicted_feature_name
@@ -67,8 +66,8 @@ def __init__(self, name=None, shape=None, dtype=None):
6766
6867
shape: list, tuple, Shape object, EnumeratedShapes object, or None
6968
The shape(s) that are valid for this input.
70-
7169
If set to ``None``, the shape will be inferred from the model itself.
70+
7271
"""
7372

7473
self.name = name
@@ -172,15 +171,16 @@ def __init__(self, name=None, shape=None, dtype=None, default_value=None):
172171
The ``name`` is required except for a TensorFlow model in which there is
173172
exactly one input Placeholder.
174173
175-
shape: (1) list of positive int or RangeDim, or (2) EnumeratedShapes
176-
The shape of the input.
174+
shape: The shape of the input
175+
- List of positive int or :py:class:`RangeDim`, or
176+
- :py:class:`EnumeratedShapes`
177177
178178
For TensorFlow:
179-
* The ``shape`` is optional. If omitted, the shape is inferred from
180-
TensorFlow graph's Placeholder shape.
179+
* The ``shape`` is optional. If omitted, the shape is inferred from
180+
TensorFlow graph's Placeholder shape.
181181
182182
For PyTorch:
183-
* The ``shape`` is required.
183+
* The ``shape`` is required.
184184
185185
dtype: np.generic or mil.type type
186186
For example, ``np.int32`` or ``coremltools.converters.mil.mil.types.fp32``
@@ -194,7 +194,7 @@ def __init__(self, name=None, shape=None, dtype=None, default_value=None):
194194
elements are required to have the same value.
195195
196196
* The ``default_value`` may not be specified if ``shape`` is
197-
``EnumeratedShapes``.
197+
:py:class:`EnumeratedShapes`.
198198
199199
Examples
200200
--------
@@ -339,7 +339,7 @@ def __str__(self):
339339
class Shape:
340340
def __init__(self, shape, default=None):
341341
"""
342-
The basic shape class to be set in InputType.
342+
The basic shape class to be set in :py:class:`InputType`.
343343
344344
Parameters
345345
----------
@@ -350,7 +350,7 @@ def __init__(self, shape, default=None):
350350
The default shape that is used for initiating the model, and set in
351351
the metadata of the model file.
352352
353-
If None, then ``shape`` is used.
353+
If ``None``, then ``shape`` is used.
354354
"""
355355
from coremltools.converters.mil.mil import get_new_symbol
356356

@@ -430,35 +430,36 @@ def __init__(self, shapes, default=None):
430430
431431
Parameters
432432
----------
433-
shapes: list of Shape objects, or Shape-compatible lists.
434-
The valid shapes of the inputs.
433+
shapes: list of Shape objects, or Shape-compatible lists
434+
* The valid shapes of the inputs.
435+
* If input provided is not a :py:class:`Shape` object,
436+
but can be converted to a :py:class:`Shape`,
437+
the :py:class:`Shape` object would be stored in ``shapes`` instead.
435438
436-
If input provided is not a Shape object, but can be converted to a Shape,
437-
the Shape object would be stored in ``shapes`` instead.
438439
439440
default: tuple of int or None
440-
The default shape that is used for initiating the model, and set in
441-
the metadata of the model file.
441+
* The default shape that is used for initiating the model, and set in
442+
the metadata of the model file.
443+
* If ``None``, then the first element in ``shapes`` is used.
442444
443-
If None, then the first element in ``shapes`` is used.
444445
445446
Examples
446447
--------
447448
.. sourcecode:: python
448449
449-
sample_shape = ct.EnumeratedShapes(
450-
shapes=[
451-
(2, 4, 64, 64),
452-
(2, 4, 48, 48),
453-
(2, 4, 32, 32)
454-
],
455-
default=(2, 4, 64, 64)
456-
)
457-
458-
my_core_ml_model = ct.convert(
459-
my_model,
460-
inputs=[ct.TensorType(name="sample", shape=sample_shape)],
461-
)
450+
sample_shape = ct.EnumeratedShapes(
451+
shapes=[
452+
(2, 4, 64, 64),
453+
(2, 4, 48, 48),
454+
(2, 4, 32, 32)
455+
],
456+
default=(2, 4, 64, 64)
457+
)
458+
459+
my_core_ml_model = ct.convert(
460+
my_model,
461+
inputs=[ct.TensorType(name="sample", shape=sample_shape)],
462+
)
462463
"""
463464

464465
# lazy import to avoid circular import

coremltools/converters/mil/mil/ops/defs/iOS15/image_resizing.py

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,7 @@ class affine(Operation):
644644
the coordinates ``x’`` and ``y’`` with the following equation, and then computing the
645645
value at the coordinate ``(x’,y’)`` in the input image using either bilinear or
646646
nearest neighbor interpolation. If the ``(x’, y’)`` point falls outside the input
647-
image, then padding information is used to compute the value.
648-
649-
::
647+
image, then padding information is used to compute the value::
650648
651649
x’ = a0 * x + a1 * y + a2
652650
y’ = b0 * x + b1 * y + b2
@@ -655,45 +653,41 @@ class affine(Operation):
655653
Parameters
656654
----------
657655
x: tensor<[B, C, H1, W1], T>
658-
* Must be rank ``4``.
656+
* Must be rank ``4``.
659657
transform_matrix: tensor<[D, 6], T>
660-
* Must be rank ``2``.
661-
* ``D`` can be either ``B`` or 1.
662-
* If ``D == B``, there is a separate transform matrix for each batch.
663-
* If ``D == 1``, the same matrix is used for all input batches.
664-
* For each batch: ``[a0, a1, a2, b0, b1, b2]``.
658+
* Must be rank ``2``.
659+
* ``D`` can be either ``B`` or 1.
660+
* If ``D == B``, there is a separate transform matrix for each batch.
661+
* If ``D == 1``, the same matrix is used for all input batches.
662+
* For each batch: ``[a0, a1, a2, b0, b1, b2]``.
665663
output_height: const<i32>
666-
* Target output height
664+
* Target output height
667665
output_width: const<i32>
668-
* Target output width
666+
* Target output width
669667
sampling_mode: const<str>
670-
* Allowed values: ``"bilinear"``
668+
* Allowed values: ``"bilinear"``
671669
padding_mode: const<str>
672-
* Allowed values: ``"constant"``.
673-
* Note that the following example is 1D case for brevity.
674-
The op supports only 2D image input.
675-
* If ``padding_mode == "constant"``:
676-
* The input image is assumed to be padded with the padding_value.
677-
* For example, ``|1, 2, 3| -> |0, 0, 0, 1, 2, 3, 0, 0, 0|``.
670+
* Allowed values: ``"constant"``.
671+
* Note that the following example is 1D case for brevity. The op supports only 2D image input.
672+
* If ``padding_mode == "constant"``:
673+
* The input image is assumed to be padded with the padding_value.
674+
* For example, ``|1, 2, 3| -> |0, 0, 0, 1, 2, 3, 0, 0, 0|``.
678675
padding_value: const<T>
679-
* Currently non-zero values are not supported.
680-
* To be used only when ``padding_mode == "constant"``, ignored in other cases.
676+
* Currently non-zero values are not supported.
677+
* To be used only when ``padding_mode == "constant"``, ignored in other cases.
681678
coordinates_mode: const<str>
682-
* Allowed values: ``"normalized_minus_one_to_one"``
683-
* If ``coordinates_mode == "normalized_minus_one_to_one"``, in-image values are ``[-1, 1]``.
684-
* For example, if ``coordinates_mode == "normalized_minus_one_to_one"``,
685-
the in range values are ``[-1, 1]``. That is:
686-
* ``(-1, -1)``, i.e. ``(w=-1, h=-1)``, corresponds to the top-left pixel.
687-
* ``(1, -1)``, i.e. ``(w=1, h=-1)``, corresponds to the top-right pixel.
688-
* ``(-1, 1)``, i.e. ``(w=-1, h=1)``, corresponds to the bottom-left pixel.
689-
* ``(1, 1)``, i.e. ``(w=1, h=1)``, corresponds to the bottom-right pixel.
679+
* Allowed values: ``"normalized_minus_one_to_one"``.
680+
* If ``coordinates_mode == "normalized_minus_one_to_one"``, in-image values are ``[-1, 1]``.
681+
* For example, if ``coordinates_mode == "normalized_minus_one_to_one"``, the in-range values are ``[-1, 1]``. That is:
682+
* ``(-1, -1)``, i.e. ``(w=-1, h=-1)``, corresponds to the top-left pixel.
683+
* ``(1, -1)``, i.e. ``(w=1, h=-1)``, corresponds to the top-right pixel.
684+
* ``(-1, 1)``, i.e. ``(w=-1, h=1)``, corresponds to the bottom-left pixel.
685+
* ``(1, 1)``, i.e. ``(w=1, h=1)``, corresponds to the bottom-right pixel.
690686
align_corners: const<bool>
691-
* Currently ``align_corners=False`` is not supported.
692-
* To be used only when ``coordinates_mode != unnormalized``, ignored otherwise.
693-
* if ``align_corners == True``, the extrema coordinates correspond
694-
to the center of the first and last corner pixels.
695-
* if ``align_corners == False``, the extrema coordinates correspond
696-
to the edge of the first and last corner pixels.
687+
* Currently ``align_corners=False`` is not supported.
688+
* To be used only when ``coordinates_mode != unnormalized``, ignored otherwise.
689+
* If ``align_corners == True``, the extrema coordinates correspond to the center of the first and last corner pixels.
690+
* If ``align_corners == False``, the extrema coordinates correspond to the edge of the first and last corner pixels.
697691
698692
Returns
699693
-------
@@ -799,20 +793,20 @@ class resample(Operation):
799793
* Note that the following example is 1D case for brevity.
800794
The op supports only 2D image input.
801795
* If ``padding_mode == "constant"``:
802-
* The input image is assumed to be padded with the ``padding_value``.
803-
* For example: ``|1, 2, 3| -> |0, 0, 0, 1, 2, 3, 0, 0, 0|``
796+
* The input image is assumed to be padded with the ``padding_value``.
797+
* For example: ``|1, 2, 3| -> |0, 0, 0, 1, 2, 3, 0, 0, 0|``
804798
* if ``padding_mode == "border"``:
805-
* The input image is assumed to be padded with the values replicated
806-
from the values at the edge. This is also referred to as the
807-
"clamped" or "replication" mode, since the padded values are
808-
clamped to the border values.
809-
* For example: ``|1, 2, 3| -> |1, 1, 1, 1, 2, 3, 3, 3, 3|``
799+
* The input image is assumed to be padded with the values replicated
800+
from the values at the edge. This is also referred to as the
801+
"clamped" or "replication" mode, since the padded values are
802+
clamped to the border values.
803+
* For example: ``|1, 2, 3| -> |1, 1, 1, 1, 2, 3, 3, 3, 3|``
810804
* If ``padding_mode == "reflection"``:
811-
* The border values are reflected, *not* including the values at the edge/border.
812-
* For example: ``|1, 2, 3| -> |2, 3, 2, 1, 2, 3, 2, 1, 2|``
805+
* The border values are reflected, *not* including the values at the edge/border.
806+
* For example: ``|1, 2, 3| -> |2, 3, 2, 1, 2, 3, 2, 1, 2|``
813807
* If ``padding_mode == "symmetric"``:
814-
* Values are reflected, including the border/edge values.
815-
* For example: ``|1, 2, 3| -> |3, 2, 1 , 1, 2, 3, 3, 2, 1|``
808+
* Values are reflected, including the border/edge values.
809+
* For example: ``|1, 2, 3| -> |3, 2, 1 , 1, 2, 3, 3, 2, 1|``
816810
padding_value: const<T>
817811
* To be used only when ``padding_mode == "constant"``, ignored in other cases.
818812
coordinates_mode: const<str>
@@ -825,17 +819,14 @@ class resample(Operation):
825819
the in-image values are ``[-1, 1]``.
826820
* If ``coordinates_mode == "normalized_zero_to_one"``,
827821
in-image values are ``[0, 1]``.
828-
* For example, if ``coordinates_mode == "normalized_minus_one_to_one"``,
829-
the in range values are [-1, 1]. That is:
830-
* ``(-1, -1)``, i.e. ``(w=-1, h=-1)``, corresponds to the top-left pixel.
831-
* ``(1, -1)``, i.e. ``(w=1, h=-1)``, corresponds to the top-right pixel.
832-
* ``(-1, 1)``, i.e. ``(w=-1, h=1)``, corresponds to the bottom-left pixel.
833-
* ``(1, 1)``, i.e. ``(w=1, h=1)``, corresponds to the bottom-right pixel.
822+
* For example, if ``coordinates_mode == "normalized_minus_one_to_one"``, the in range values are [-1, 1]. That is:
823+
* ``(-1, -1)``, i.e. ``(w=-1, h=-1)``, corresponds to the top-left pixel.
824+
* ``(1, -1)``, i.e. ``(w=1, h=-1)``, corresponds to the top-right pixel.
825+
* ``(-1, 1)``, i.e. ``(w=-1, h=1)``, corresponds to the bottom-left pixel.
826+
* ``(1, 1)``, i.e. ``(w=1, h=1)``, corresponds to the bottom-right pixel.
834827
align_corners: const<bool>
835-
* If ``align_corners == True``, the extrema coordinates correspond
836-
to the center of the first and last corner pixels.
837-
* If ``align_corners == False``, the extrema coordinates correspond
838-
to the edge of the first and last corner pixels.
828+
* If ``align_corners == True``, the extrema coordinates correspond to the center of the first and last corner pixels.
829+
* If ``align_corners == False``, the extrema coordinates correspond to the edge of the first and last corner pixels.
839830
840831
Returns
841832
-------

coremltools/converters/mil/mil/ops/defs/iOS16/constexpr_ops.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ class constexpr_affine_dequantize(Operation):
2222
The quantized data is stored in the parameter ``quantized_data``.
2323
The other parameters -- ``scale``, ``zero_point``, and ``axis`` -- describe how
2424
unquantized values can be extracted from it, using the equation for affine/linear quantization:
25-
::
26-
unquantized_data = scale * (quantized_data - zero_point)
25+
26+
.. sourcecode:: python
27+
28+
unquantized_data = scale * (quantized_data - zero_point)
2729
2830
Although all of the parameters of this op are constants, this op is not constant folded
2931
to a single const op at the time of model serialization. The unquantized output will
@@ -38,15 +40,15 @@ class constexpr_affine_dequantize(Operation):
3840
* ``zero_point`` follows similar broadcasting rules and size constraints as ``scale``.
3941
4042
scale: const tensor<DstT, [0..1]> (Required)
41-
* ``scale`` can be either a scalar or a vector. If ``scale`` is a vector,
42-
for implementation it is broadcast to the following shape:
43-
* The rank of ``scale`` becomes the same as the rank of ``quantized_data``.
44-
* The constraint: ``size(scale-vector) == quantized_data.shape[axis]``.
45-
* For ``i == axis``, ``scale.shape[i] == quantized_data.shape[i]``.
46-
* For ``i != axis``, ``scale.shape == 1``.
47-
For example, assume ``quantized_data.shape = (2, 3, 4, 5)`` and ``axis = 1``.
48-
If ``scale`` is a vector, then ``scale.size`` needs to be equal to
49-
``quantized_data.shape[axis] i.e = 3``, which would be broadcast to ``(1, 3, 1, 1)``.
43+
* ``scale`` can be either a scalar or a vector.
44+
* If ``scale`` is a vector, for implementation it is broadcast to the following shape:
45+
* The rank of ``scale`` becomes the same as the rank of ``quantized_data``.
46+
* The constraint: ``size(scale-vector) == quantized_data.shape[axis]``.
47+
* For ``i == axis``, ``scale.shape[i] == quantized_data.shape[i]``.
48+
* For ``i != axis``, ``scale.shape == 1``.
49+
For example, assume ``quantized_data.shape = (2, 3, 4, 5)`` and ``axis = 1``.
50+
If ``scale`` is a vector, then ``scale.size`` needs to be equal to
51+
``quantized_data.shape[axis] i.e = 3``, which would be broadcast to ``(1, 3, 1, 1)``.
5052
5153
axis: const tensor<int32, []> (Required)
5254
@@ -136,8 +138,10 @@ def rank_promoted_to_same_as_quantized_data(param):
136138
class constexpr_cast(Operation):
137139
"""
138140
A compile-time operation that returns a constant output value upon casting its constant input.
139-
::
140-
Expression: output = constexpr_cast(source_val, output_dtype="fp32")
141+
142+
.. sourcecode:: python
143+
144+
Expression: output = constexpr_cast(source_val, output_dtype="fp32")
141145
142146
Parameters
143147
----------
@@ -205,7 +209,9 @@ class constexpr_lut_to_dense(Operation):
205209
bits of the same index are filled in the LSBs of the next byte.
206210
207211
For example:
208-
::
212+
213+
.. sourcecode:: python
214+
209215
if n_bits = 2, shape = (5,) => M = 2 bytes
210216
211217
MSB LSB
@@ -301,15 +307,18 @@ class constexpr_sparse_to_dense(Operation):
301307
moving up to the most significant bit.
302308
303309
For example:
304-
::
305-
shape = (5,) => M = 1 bytes
306310
311+
.. sourcecode:: python
312+
313+
shape = (5,) => M = 1 bytes
314+
307315
MSB LSB
308316
| |
309317
mask = |x x x 0 1 1 0 0 | <== packed elements
310318
|--|--|--|i4|i3|i2|i1|i0| <== tagged element ids
311319
| byte 0 | <== tagged bytes
312320
321+
313322
Returns
314323
-------
315324
const tensor<T, [...]>

coremltools/converters/mil/mil/ops/defs/iOS17/image_resizing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ class resize(Operation):
263263
* Available mode: ``LINEAR``, ``NEAREST_NEIGHBOR``.
264264
265265
sampling_mode: const<str> (Optional, default="DEFAULT")
266-
* Available mode: ``DEFAULT``, ``STRICT_ALIGN_CORNERS``, ``ALIGN_CORNERS``,
267-
``OFFSET_CORNERS``, ``UNALIGN_CORNERS``.
266+
* Available mode: ``DEFAULT``, ``STRICT_ALIGN_CORNERS``, ``ALIGN_CORNERS``, ``OFFSET_CORNERS``, ``UNALIGN_CORNERS``.
268267
* For details about different sampling modes, see iOS 15 :py:class:`~.iOS15.image_resizing.resize_bilinear`.
269268
270269
Returns

0 commit comments

Comments
 (0)