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

npu_test #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Runtime由纯C语言开发,核心框架二进制大小只有50KB左右,包
接着执行下面命令完成编译。

```shell
cd compiler && mkdir build
cd compiler && mkdir build && cd build
cmake .. -DLITE_USE_ASCEND_NPU=ON && make
```

Expand All @@ -52,7 +52,7 @@ Runtime由纯C语言开发,核心框架二进制大小只有50KB左右,包

- 在目标硬件平台上编译

比如目标平台为X86 CPU + Ascend NPU,编译命令如下,
比如目标平台为X86 CPU + Ascend NPU(同样适用于华为昇腾910),编译命令如下,

```shell
cd runtime && mkdir build
Expand All @@ -69,19 +69,32 @@ Runtime由纯C语言开发,核心框架二进制大小只有50KB左右,包

1. 使用graph模式导出mlir模型

```python
class MyGraph(nn.Graph):
def __init__(self, model):
super().__init__()
self.model = model
```shell
pip install flowvision
```

def build(self, *input):
return self.model(*input)

model = Resnet50Module()
model.eval()
graph = MyGraph(model)
flow.save(graph, "./resnet50_model/")
```python
from flowvision.models import ModelCreator

model=ModelCreator.create_model("resnet50",pretrained=True)

class MyGraph(nn.Graph):
def __init__(self, model):
super().__init__()
self.model = model

def build(self, *input):
return self.model(*input)

if __name__ == "__main__":

model=ModelCreator.create_model("resnet50",pretrained=True)
model.eval()
graph = MyGraph(model)
input = flow.rand(1,3,224,224)
outs = graph(input)
flow.save(graph, "./esnet50_model/")
```

2. 使用`oneflow-lite-compile`工具将模型编译成`oneflow-lite`的模型文件格式(以华为Ascend NPU为例)

Expand Down
2 changes: 1 addition & 1 deletion runtime/oneflow-lite/core/device_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/
#include "oneflow-lite/core/device_context.h"

#include <threads.h>
#include <thread>

#include "oneflow-lite/base/memory.h"

Expand Down