optimum-rbln 0.1.9__py3-none-any.whl → 0.1.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- optimum/rbln/__init__.py +37 -2
- optimum/rbln/__version__.py +1 -1
- optimum/rbln/diffusers/models/autoencoder_kl.py +36 -29
- optimum/rbln/diffusers/models/controlnet.py +56 -40
- optimum/rbln/diffusers/models/unet_2d_condition.py +40 -28
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py +22 -15
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +22 -15
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +23 -17
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +24 -18
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +22 -11
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +22 -11
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +24 -14
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +24 -14
- optimum/rbln/modeling_alias.py +3 -3
- optimum/rbln/modeling_base.py +471 -231
- optimum/rbln/modeling_config.py +152 -77
- optimum/rbln/modeling_seq2seq.py +166 -77
- optimum/rbln/transformers/__init__.py +35 -1
- optimum/rbln/transformers/models/__init__.py +20 -1
- optimum/rbln/transformers/models/auto/__init__.py +14 -0
- optimum/rbln/transformers/models/auto/auto_factory.py +84 -0
- optimum/rbln/transformers/models/auto/modeling_auto.py +94 -0
- optimum/rbln/transformers/models/bart/__init__.py +1 -0
- optimum/rbln/transformers/models/bart/bart_architecture.py +189 -50
- optimum/rbln/transformers/models/bart/modeling_bart.py +106 -0
- optimum/rbln/transformers/models/bert/__init__.py +24 -0
- optimum/rbln/transformers/models/bert/modeling_bert.py +102 -0
- optimum/rbln/transformers/models/clip/__init__.py +1 -1
- optimum/rbln/transformers/models/clip/modeling_clip.py +127 -25
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +28 -4
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +302 -115
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +21 -7
- optimum/rbln/transformers/models/gemma/modeling_gemma.py +1 -1
- optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +4 -1
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +1 -1
- optimum/rbln/transformers/models/llama/modeling_llama.py +1 -1
- optimum/rbln/transformers/models/llava_next/__init__.py +24 -0
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +666 -0
- optimum/rbln/transformers/models/midm/midm_architecture.py +5 -1
- optimum/rbln/transformers/models/midm/modeling_midm.py +1 -1
- optimum/rbln/transformers/models/mistral/modeling_mistral.py +1 -1
- optimum/rbln/transformers/models/phi/__init__.py +24 -0
- optimum/rbln/transformers/models/phi/modeling_phi.py +69 -0
- optimum/rbln/transformers/models/phi/phi_architecture.py +406 -0
- optimum/rbln/transformers/models/t5/t5_architecture.py +92 -31
- optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +17 -11
- optimum/rbln/transformers/models/whisper/generation_whisper.py +68 -0
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +141 -105
- optimum/rbln/transformers/models/whisper/whisper_architecture.py +44 -17
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +17 -14
- optimum/rbln/transformers/utils/rbln_quantization.py +48 -60
- optimum/rbln/utils/import_utils.py +36 -1
- optimum/rbln/utils/logging.py +82 -0
- optimum/rbln/utils/runtime_utils.py +33 -0
- optimum/rbln/utils/timer_utils.py +19 -0
- {optimum_rbln-0.1.9.dist-info → optimum_rbln-0.1.11.dist-info}/METADATA +8 -7
- optimum_rbln-0.1.11.dist-info/RECORD +93 -0
- {optimum_rbln-0.1.9.dist-info → optimum_rbln-0.1.11.dist-info}/WHEEL +1 -1
- optimum_rbln-0.1.11.dist-info/entry_points.txt +4 -0
- optimum_rbln-0.1.9.dist-info/RECORD +0 -78
- {optimum_rbln-0.1.9.dist-info → optimum_rbln-0.1.11.dist-info}/licenses/LICENSE +0 -0
@@ -22,13 +22,13 @@
|
|
22
22
|
# from Rebellions Inc.
|
23
23
|
|
24
24
|
import logging
|
25
|
-
from typing import TYPE_CHECKING, Iterable, Optional, Union
|
25
|
+
from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Union
|
26
26
|
|
27
27
|
from transformers import AutoModelForDepthEstimation
|
28
28
|
from transformers.modeling_outputs import DepthEstimatorOutput
|
29
29
|
|
30
30
|
from ....modeling_base import RBLNModel
|
31
|
-
from ....modeling_config import
|
31
|
+
from ....modeling_config import RBLNCompileConfig, RBLNConfig
|
32
32
|
|
33
33
|
|
34
34
|
logger = logging.getLogger(__name__)
|
@@ -47,9 +47,11 @@ class RBLNDPTForDepthEstimation(RBLNModel):
|
|
47
47
|
cls,
|
48
48
|
preprocessors: Optional[Union["AutoFeatureExtractor", "AutoProcessor", "AutoTokenizer"]],
|
49
49
|
model_config: Optional["PretrainedConfig"] = None,
|
50
|
-
|
51
|
-
rbln_batch_size: Optional[int] = None,
|
50
|
+
rbln_kwargs: Dict[str, Any] = {},
|
52
51
|
) -> RBLNConfig:
|
52
|
+
rbln_image_size = rbln_kwargs.get("image_size", None)
|
53
|
+
rbln_batch_size = rbln_kwargs.get("batch_size", None)
|
54
|
+
|
53
55
|
if rbln_batch_size is None:
|
54
56
|
rbln_batch_size = 1
|
55
57
|
|
@@ -79,10 +81,22 @@ class RBLNDPTForDepthEstimation(RBLNModel):
|
|
79
81
|
|
80
82
|
input_info = [("pixel_values", [rbln_batch_size, 3, rbln_image_size[0], rbln_image_size[1]], "float32")]
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
+
rbln_compile_config = RBLNCompileConfig(input_info=input_info)
|
85
|
+
|
86
|
+
rbln_config = RBLNConfig(
|
87
|
+
rbln_cls=cls.__name__,
|
88
|
+
compile_cfgs=[rbln_compile_config],
|
89
|
+
rbln_kwargs=rbln_kwargs,
|
90
|
+
)
|
91
|
+
|
92
|
+
rbln_config.model_cfg.update(
|
93
|
+
{
|
94
|
+
"image_size": rbln_image_size,
|
95
|
+
"batch_size": rbln_batch_size,
|
96
|
+
}
|
97
|
+
)
|
84
98
|
|
85
|
-
return
|
99
|
+
return rbln_config
|
86
100
|
|
87
101
|
def forward(self, *args, **kwargs):
|
88
102
|
predicted_depth = super().forward(*args, **kwargs)
|
@@ -52,7 +52,7 @@ class RBLNGemmaForCausalLM(RBLNDecoderOnlyModelForCausalLM):
|
|
52
52
|
|
53
53
|
@classmethod
|
54
54
|
def wrap_model_if_needed(self, model: "PreTrainedModel", rbln_config: "RBLNConfig"):
|
55
|
-
rbln_max_seq_len = rbln_config.
|
55
|
+
rbln_max_seq_len = rbln_config.model_cfg["max_seq_len"]
|
56
56
|
return GemmaWrapper(model, rbln_max_seq_len).eval()
|
57
57
|
|
58
58
|
def __getattr__(self, __name: str) -> Any:
|
@@ -53,6 +53,7 @@ class GPT2LMHeadModelWrapper(torch.nn.Module):
|
|
53
53
|
attention_mask,
|
54
54
|
cache_position,
|
55
55
|
batch_position,
|
56
|
+
query_idx,
|
56
57
|
*past_key_values,
|
57
58
|
):
|
58
59
|
if input_ids.shape[1] == 1:
|
@@ -79,11 +80,13 @@ class GPT2LMHeadModelWrapper(torch.nn.Module):
|
|
79
80
|
)
|
80
81
|
|
81
82
|
hidden_states = outputs[0]
|
83
|
+
if batch_position >= 0:
|
84
|
+
hidden_states = hidden_states[:, query_idx].unsqueeze(1)
|
82
85
|
logits = self.lm_head(hidden_states)
|
83
86
|
|
84
87
|
output = (logits,) + outputs[1:]
|
85
88
|
|
86
|
-
return output, batch_position
|
89
|
+
return output, batch_position + query_idx
|
87
90
|
|
88
91
|
|
89
92
|
class _GPT2Model:
|
@@ -53,7 +53,7 @@ class RBLNGPT2LMHeadModel(RBLNDecoderOnlyModelForCausalLM):
|
|
53
53
|
|
54
54
|
@classmethod
|
55
55
|
def wrap_model_if_needed(self, model: "PreTrainedModel", rbln_config: "RBLNConfig"):
|
56
|
-
rbln_max_seq_len = rbln_config.
|
56
|
+
rbln_max_seq_len = rbln_config.model_cfg["max_seq_len"]
|
57
57
|
return GPT2LMHeadModelWrapper(model, rbln_max_seq_len).eval()
|
58
58
|
|
59
59
|
def __getattr__(self, __name: str) -> Any:
|
@@ -52,7 +52,7 @@ class RBLNLlamaForCausalLM(RBLNDecoderOnlyModelForCausalLM):
|
|
52
52
|
|
53
53
|
@classmethod
|
54
54
|
def wrap_model_if_needed(self, model: "PreTrainedModel", rbln_config: "RBLNConfig"):
|
55
|
-
rbln_max_seq_len = rbln_config.
|
55
|
+
rbln_max_seq_len = rbln_config.model_cfg["max_seq_len"]
|
56
56
|
return LlamaWrapper(model, rbln_max_seq_len).eval()
|
57
57
|
|
58
58
|
def __getattr__(self, __name: str) -> Any:
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2024 Rebellions Inc.
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at:
|
6
|
+
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# Portions of this software are licensed under the Apache License,
|
16
|
+
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
+
# additional information regarding copyright ownership.
|
18
|
+
|
19
|
+
# All other portions of this software, including proprietary code,
|
20
|
+
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
+
# copied, modified, or distributed without prior written permission
|
22
|
+
# from Rebellions Inc.
|
23
|
+
|
24
|
+
from .modeling_llava_next import RBLNLlavaNextForConditionalGeneration
|