Skip to content

Commit 12fe1d7

Browse files
committed
Fix deprecated use of Tuple.append/2
1 parent 02e0a48 commit 12fe1d7

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

lib/bumblebee/diffusion/layers/unet.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ defmodule Bumblebee.Diffusion.Layers.UNet do
123123
hidden_state
124124
end
125125

126-
{hidden_state, Tuple.append(output_states, {hidden_state, out_channels})}
126+
{hidden_state,
127+
Tuple.insert_at(output_states, tuple_size(output_states), {hidden_state, out_channels})}
127128
end
128129

129130
if add_downsample do
@@ -133,7 +134,8 @@ defmodule Bumblebee.Diffusion.Layers.UNet do
133134
name: join(name, "downsamples.0")
134135
)
135136

136-
{hidden_state, Tuple.append(output_states, {hidden_state, out_channels})}
137+
{hidden_state,
138+
Tuple.insert_at(output_states, tuple_size(output_states), {hidden_state, out_channels})}
137139
else
138140
{hidden_state, output_states}
139141
end

lib/bumblebee/layers.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,13 @@ defmodule Bumblebee.Layers do
923923
Appends tuple element to the node result.
924924
"""
925925
def append(%Axon{} = tuple, %Axon{} = x) do
926-
Axon.layer(fn tuple, x, _ -> Tuple.append(tuple, x) end, [tuple, x], op_name: :append)
926+
Axon.layer(
927+
fn tuple, x, _ ->
928+
Tuple.insert_at(tuple, tuple_size(tuple), x)
929+
end,
930+
[tuple, x],
931+
op_name: :append
932+
)
927933
end
928934

929935
@doc """

lib/bumblebee/multimodal/layout_lm.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ defmodule Bumblebee.Multimodal.LayoutLm do
272272
shape = Keyword.get(opts, :shape, {nil, nil})
273273

274274
attention_head_mask_shape = {spec.num_blocks, spec.num_attention_heads}
275-
bounding_box_shape = Tuple.append(shape, 4)
275+
bounding_box_shape = Tuple.insert_at(shape, tuple_size(shape), 4)
276276

277277
Bumblebee.Utils.Model.inputs_to_map([
278278
Axon.input("input_ids", shape: shape),

lib/bumblebee/text/bert.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ defmodule Bumblebee.Text.Bert do
398398
shape = Keyword.get(opts, :shape, {nil, nil})
399399
decoder? = Keyword.get(opts, :decoder?, false)
400400

401-
hidden_shape = Tuple.append(shape, spec.hidden_size)
401+
hidden_shape = Tuple.insert_at(shape, tuple_size(shape), spec.hidden_size)
402402
attention_head_mask_shape = {spec.num_blocks, spec.num_attention_heads}
403403

404404
inputs =

lib/bumblebee/text/roberta.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ defmodule Bumblebee.Text.Roberta do
354354
shape = Keyword.get(opts, :shape, {nil, nil})
355355
decoder? = Keyword.get(opts, :decoder?, false)
356356

357-
hidden_shape = Tuple.append(shape, spec.hidden_size)
357+
hidden_shape = Tuple.insert_at(shape, tuple_size(shape), spec.hidden_size)
358358
attention_head_mask_shape = {spec.num_blocks, spec.num_attention_heads}
359359

360360
inputs =

0 commit comments

Comments
 (0)