update: 适配昇腾
Some checks failed
Ultralytics CI / HUB (ubuntu-latest, 3.11) (push) Has been cancelled
Ultralytics CI / Benchmarks (yolo11n, macos-15, 3.11) (push) Has been cancelled
Ultralytics CI / Benchmarks (yolo11n, ubuntu-latest, 3.11) (push) Has been cancelled
Ultralytics CI / Tests (macos-15, 3.11, latest) (push) Has been cancelled
Ultralytics CI / Tests (ubuntu-latest, 3.11, latest) (push) Has been cancelled
Ultralytics CI / Tests (ubuntu-latest, 3.8, 1.8.0) (push) Has been cancelled
Ultralytics CI / Tests (windows-latest, 3.11, latest) (push) Has been cancelled
Ultralytics CI / GPU (push) Has been cancelled
Ultralytics CI / RaspberryPi (push) Has been cancelled
Ultralytics CI / Conda (ubuntu-latest, 3.11) (push) Has been cancelled
Ultralytics CI / Summary (push) Has been cancelled
Publish Docker Images / Push (push) Has been cancelled
Publish Docker Images / Push-1 (push) Has been cancelled
Publish Docker Images / Push-2 (push) Has been cancelled
Publish Docker Images / Push-3 (push) Has been cancelled
Publish Docker Images / Push-4 (push) Has been cancelled
Publish Docker Images / Push-5 (push) Has been cancelled
Publish Docker Images / Push-6 (push) Has been cancelled
Publish Docker Images / trigger-actions (push) Has been cancelled
Publish Docker Images / notify (push) Has been cancelled
Publish Docs / Docs (push) Has been cancelled
Publish to PyPI / check (push) Has been cancelled
Publish to PyPI / build (push) Has been cancelled
Publish to PyPI / publish (push) Has been cancelled
Publish to PyPI / notify (push) Has been cancelled
Some checks failed
Ultralytics CI / HUB (ubuntu-latest, 3.11) (push) Has been cancelled
Ultralytics CI / Benchmarks (yolo11n, macos-15, 3.11) (push) Has been cancelled
Ultralytics CI / Benchmarks (yolo11n, ubuntu-latest, 3.11) (push) Has been cancelled
Ultralytics CI / Tests (macos-15, 3.11, latest) (push) Has been cancelled
Ultralytics CI / Tests (ubuntu-latest, 3.11, latest) (push) Has been cancelled
Ultralytics CI / Tests (ubuntu-latest, 3.8, 1.8.0) (push) Has been cancelled
Ultralytics CI / Tests (windows-latest, 3.11, latest) (push) Has been cancelled
Ultralytics CI / GPU (push) Has been cancelled
Ultralytics CI / RaspberryPi (push) Has been cancelled
Ultralytics CI / Conda (ubuntu-latest, 3.11) (push) Has been cancelled
Ultralytics CI / Summary (push) Has been cancelled
Publish Docker Images / Push (push) Has been cancelled
Publish Docker Images / Push-1 (push) Has been cancelled
Publish Docker Images / Push-2 (push) Has been cancelled
Publish Docker Images / Push-3 (push) Has been cancelled
Publish Docker Images / Push-4 (push) Has been cancelled
Publish Docker Images / Push-5 (push) Has been cancelled
Publish Docker Images / Push-6 (push) Has been cancelled
Publish Docker Images / trigger-actions (push) Has been cancelled
Publish Docker Images / notify (push) Has been cancelled
Publish Docs / Docs (push) Has been cancelled
Publish to PyPI / check (push) Has been cancelled
Publish to PyPI / build (push) Has been cancelled
Publish to PyPI / publish (push) Has been cancelled
Publish to PyPI / notify (push) Has been cancelled
This commit is contained in:
parent
e74b035c02
commit
696c1b0793
5 changed files with 34 additions and 11 deletions
|
|
@ -12,6 +12,10 @@ import numpy as np
|
|||
import torch
|
||||
import torch.nn as nn
|
||||
from PIL import Image
|
||||
import torch_npu
|
||||
from torch_npu.contrib import transfer_to_npu
|
||||
import torchair as tng
|
||||
from torchair.configs.compiler_config import CompilerConfig
|
||||
|
||||
from ultralytics.utils import ARM64, IS_JETSON, IS_RASPBERRYPI, LINUX, LOGGER, PYTHON_VERSION, ROOT, yaml_load
|
||||
from ultralytics.utils.checks import check_requirements, check_suffix, check_version, check_yaml, is_rockchip
|
||||
|
|
@ -156,6 +160,12 @@ class AutoBackend(nn.Module):
|
|||
names = model.module.names if hasattr(model, "module") else model.names # get class names
|
||||
model.half() if fp16 else model.float()
|
||||
self.model = model # explicitly assign for to(), cpu(), cuda(), half()
|
||||
# 添加torchair适配代码
|
||||
config = CompilerConfig()
|
||||
config.experimental_config.frozen_parameter = True
|
||||
npu_backbend = tng.get_npu_backend(compiler_config=config)
|
||||
model = torch.compile(model, dynamic=True, fullgraph=True, backend=npu_backbend)
|
||||
tng.use_internal_format_weight(model.model)
|
||||
pt = True
|
||||
|
||||
# PyTorch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue