From 1d71166ed9a7f86890c8316312dd43fa28cf6930 Mon Sep 17 00:00:00 2001 From: huangbingjian Date: Wed, 21 Aug 2024 10:18:59 +0800 Subject: [PATCH] Add dtype faq --- docs/mindspore/source_en/faq/operators_compile.md | 6 ++++++ .../source_zh_cn/faq/operators_compile.md | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/docs/mindspore/source_en/faq/operators_compile.md b/docs/mindspore/source_en/faq/operators_compile.md index b7c594c546..3bc7cb8d38 100644 --- a/docs/mindspore/source_en/faq/operators_compile.md +++ b/docs/mindspore/source_en/faq/operators_compile.md @@ -115,3 +115,9 @@ A: The `Ascend` backend operators can be divided into AI CORE operators and AI C 2. If the `AI CPU` candidate operator information is not empty, or the candidate operator information of `AI CORE` and `AI CPU` are both not empty, it may be that the given input data type was not in the candidate list and was filtered out in the selection stage. Try to modify the input data type of the operator according to the candidate list. You can select a proper mode and writing method to complete the training by referring to the [official website tutorial](https://www.mindspore.cn/tutorials/en/master/beginner/accelerate_with_static_graph.html). + +
+ +## Q: What are the type conversion rules for the inputs of MindSpore's operator? If there is a zero-dimensional Tensor in the inputs, does this rule follow? + +A: For the type conversion rules for the inputs of MindSpore's operator, please refer to [Type Conversion Rules](https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#datatype). Different from PyTorch, MindSpore also follows this rule when there is a zero-dimensional Tensor in the inputs. diff --git a/docs/mindspore/source_zh_cn/faq/operators_compile.md b/docs/mindspore/source_zh_cn/faq/operators_compile.md index 0d5cff3fef..cde7fec415 100644 --- a/docs/mindspore/source_zh_cn/faq/operators_compile.md +++ b/docs/mindspore/source_zh_cn/faq/operators_compile.md @@ -116,3 +116,18 @@ A: Ascend后端,算子有AI CORE算子和AI CPU算子之分,部分算子AI C 2. 如果`AI CPU`候选算子信息不为空,或者`AI CORE`和`AI CPU`候选算子信息都不为空,则可能是用户给到该算子的输入数据类型不在候选列表中,在选择阶段被过滤掉导致,可以根据候选列表尝试修改该算子的输入data type。 用户可以参考[官网教程](https://www.mindspore.cn/tutorials/zh-CN/master/beginner/accelerate_with_static_graph.html)选择合适、统一的模式和写法来完成训练。 + +
+ +## Q: MindSpore的算子输入的类型转换规则是什么?如果输入中存在零维Tensor,是否遵循这个规则? + +A: MindSpore的算子输入的类型转换,可以参考[类型转换规则](https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html)。与PyTorch不同的是,算子输入中存在零维Tensor时,MindSpore同样遵循这一规则。示例代码如下: + +```python +import torch +import mindspore as ms +out_ms = ms.Tensor([1], dtype=ms.int32) + ms.Tensor(1, dtype=ms.int64) +out_torch = torch.tensor([1], dtype=torch.int32) + torch.tensor(1, dtype=torch.int64) +print(out_ms.dtype) # 输出是:Int64 +print(out_torch.dtype) # 输出是:torch.int32 +``` -- Gitee