Skip to content

Commit

Permalink
[Web] Use tensor_dtype_to_np_dtype instead of deprecated function (on…
Browse files Browse the repository at this point in the history
…nx#5593)

### Description
<!-- - Describe your changes. -->
Use tensor_dtype_to_np_dtype instead of deprecated
TENSOR_TYPE_TO_NP_TYPE in https://onnx.ai/onnx/intro/python.html. This
is the only place I found which mentions deprecated functions from
mapping.py.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve? -->
<!-- - If it fixes an open issue, please link to the issue here. -->
Fixes onnx#5392.

---------

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
  • Loading branch information
jcwchen and justinchuby committed Sep 14, 2023
1 parent b82bd2d commit 821d156
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/docsgen/source/intro/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,17 @@ of each object of the graph.
node.name, node.op_type, node.input, node.output))
```

The tensor type is an integer (= 1). The following array gives the
equivalent type with numpy.
The tensor type is an integer (= 1). The helper function {func}`onnx.helper.tensor_dtype_to_np_dtype` gives the
corresponding type with numpy.

```{eval-rst}
.. exec_code::
import pprint
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
from onnx import TensorProto
from onnx.helper import tensor_dtype_to_np_dtype, tensor_dtype_to_string
pprint.pprint(TENSOR_TYPE_TO_NP_TYPE)
np_dtype = tensor_dtype_to_np_dtype(TensorProto.FLOAT)
print(f"The converted numpy dtype for {tensor_dtype_to_string(TensorProto.FLOAT)} is {np_dtype}.")
```

## Serialization
Expand Down

0 comments on commit 821d156

Please sign in to comment.