Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mindspore.nn.Cell.get_inputs() 返回值为 null #306

Open
Hsiayukoo opened this issue Sep 30, 2024 · 0 comments
Open

mindspore.nn.Cell.get_inputs() 返回值为 null #306

Hsiayukoo opened this issue Sep 30, 2024 · 0 comments

Comments

@Hsiayukoo
Copy link

Environment

Hardware Environment(Ascend/GPU/CPU):

/device ascend

Software Environment:

  • MindSpore version (source or binary):2.3.1
  • Python version (e.g., Python 3.7.5):3.9
  • OS platform and distribution (e.g., Linux Ubuntu 16.04):euler
  • GCC/Compiler version (if compiled from source):

Describe the current behavior

相同的 mindir 文件,mindspore_lite 和 mindspore 比较,mindspore 无法获取正确信息。

Describe the expected behavior

首先是 mindspore 框架读取 mindir 数据

import mindspore as ms
from mindspore import nn
graph = ms.load("output.mindir")
net = nn.GraphCell(graph)
print(net.get_inputs())
>>> None

其次是 mindspore_lite 读取 mindir 数据

import numpy as np
import mindspore_lite as mslite

context = mslite.Context()
context.target = ["cpu"]
context.cpu.thread_num = 1
context.cpu.thread_affinity_mode = 2

model = mslite.Model()
model.build_from_file("output.mindir", mslite.ModelType.MINDIR, context)

print(model.get_inputs()[0])
>>> name: x
>>> ...
>>> shape: [1, 3, 720, 1280]

相比之下,mindspore_lite 成功读取了输入的 shape,而 mindspore 读取为 None。从源码来看,似乎 mindspore.nn.Cell.get_inputs() 只有在 set_inputs() 之后才能读取,通过 net = nn.GraphCell(graph) 并不会读取 mindir 中的 input_shape 进行初始化 Cell 的 _dynamic_shape_inputs 属性。不知道这是设计本身就这样,还是一个 bug。

Related log / screenshot

mindir 文件对应的地址为 https://github.com/mindspore-lab/mindocr/blob/main/configs/det/east/README_CN.md 中的 https://download.mindspore.cn/toolkits/mindocr/east/east_resnet50_ic15-7262e359-5f05cd42.mindir

Special notes for this issue

@Hsiayukoo Hsiayukoo changed the title mindspore.nn.Cell.getInputs 返回值为 null mindspore.nn.Cell.get_inputs() 返回值为 null Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant