-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into head64
- Loading branch information
Showing
32 changed files
with
560 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from typing import Optional | ||
|
||
import torch | ||
|
||
from lmdeploy.pytorch.kernels.dlinfer import linear | ||
|
||
from ..linear import LinearBuilder, LinearImpl | ||
|
||
|
||
class DlinferLinearImpl(LinearImpl): | ||
"""Dlinfer linear implementation api.""" | ||
|
||
def forward(self, | ||
x, | ||
weight: torch.Tensor, | ||
bias: Optional[torch.Tensor] = None, | ||
all_reduce: bool = False): | ||
"""forward.""" | ||
return linear(x, weight, bias, all_reduce) | ||
|
||
|
||
class DlinferLinearBuilder(LinearBuilder): | ||
"""Dlinfer linear implementation builder.""" | ||
|
||
@staticmethod | ||
def build(in_features: int, | ||
out_features: int, | ||
bias: bool = True, | ||
dtype: torch.dtype = None): | ||
"""build.""" | ||
return DlinferLinearImpl() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from typing import Optional | ||
|
||
import dlinfer.ops as ext_ops | ||
from torch import Tensor | ||
|
||
|
||
def linear(x: Tensor, | ||
weight: Tensor, | ||
bias: Optional[Tensor] = None, | ||
all_reduce: bool = False): | ||
return ext_ops.linear(x, weight, bias=bias, all_reduce=all_reduce) |
Oops, something went wrong.