@@ -33,7 +33,7 @@ defmodule Emily.Conformance.DistilbertTest do
3333
3434 use ExUnit.Case , async: false
3535
36- import Emily.ConformanceHelper , only: [ assert_all_close: 2 , assert_all_close: 3 ]
36+ import Emily.ConformanceHelper , only: [ assert_all_close: 2 , assert_all_close: 3 , mode_test: 2 ]
3737
3838 alias Emily.Bumblebee.FastKernels
3939
@@ -52,7 +52,7 @@ defmodule Emily.Conformance.DistilbertTest do
5252 :ok
5353 end
5454
55- test ":base" do
55+ mode_test ":base" do
5656 assert { :ok , % { model: model , params: params , spec: spec } } =
5757 Bumblebee . load_model ( { :hf , "hf-internal-testing/tiny-random-DistilBertModel" } )
5858
@@ -63,7 +63,7 @@ defmodule Emily.Conformance.DistilbertTest do
6363 "attention_mask" => Nx . tensor ( [ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 ] ] )
6464 }
6565
66- outputs = Axon . predict ( model , params , inputs )
66+ outputs = Axon . predict ( model , params , inputs , predict_opts )
6767
6868 assert Nx . shape ( outputs . hidden_state ) == { 1 , 10 , 32 }
6969
@@ -75,7 +75,7 @@ defmodule Emily.Conformance.DistilbertTest do
7575 )
7676 end
7777
78- test ":for_masked_language_modeling" do
78+ mode_test ":for_masked_language_modeling" do
7979 assert { :ok , % { model: model , params: params , spec: spec } } =
8080 Bumblebee . load_model ( { :hf , "hf-internal-testing/tiny-random-DistilBertForMaskedLM" } )
8181
@@ -86,7 +86,7 @@ defmodule Emily.Conformance.DistilbertTest do
8686 "attention_mask" => Nx . tensor ( [ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 ] ] )
8787 }
8888
89- outputs = Axon . predict ( model , params , inputs )
89+ outputs = Axon . predict ( model , params , inputs , predict_opts )
9090
9191 assert Nx . shape ( outputs . logits ) == { 1 , 10 , 1124 }
9292
@@ -98,7 +98,7 @@ defmodule Emily.Conformance.DistilbertTest do
9898 )
9999 end
100100
101- test ":for_sequence_classification" do
101+ mode_test ":for_sequence_classification" do
102102 assert { :ok , % { model: model , params: params , spec: spec } } =
103103 Bumblebee . load_model (
104104 { :hf , "hf-internal-testing/tiny-random-DistilBertForSequenceClassification" }
@@ -111,14 +111,14 @@ defmodule Emily.Conformance.DistilbertTest do
111111 "attention_mask" => Nx . tensor ( [ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 ] ] )
112112 }
113113
114- outputs = Axon . predict ( model , params , inputs )
114+ outputs = Axon . predict ( model , params , inputs , predict_opts )
115115
116116 assert Nx . shape ( outputs . logits ) == { 1 , 2 }
117117
118118 assert_all_close ( outputs . logits , Nx . tensor ( [ [ - 0.0047 , - 0.0103 ] ] ) )
119119 end
120120
121- test ":for_token_classification" do
121+ mode_test ":for_token_classification" do
122122 assert { :ok , % { model: model , params: params , spec: spec } } =
123123 Bumblebee . load_model (
124124 { :hf , "hf-internal-testing/tiny-random-DistilBertForTokenClassification" }
@@ -131,7 +131,7 @@ defmodule Emily.Conformance.DistilbertTest do
131131 "attention_mask" => Nx . tensor ( [ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 ] ] )
132132 }
133133
134- outputs = Axon . predict ( model , params , inputs )
134+ outputs = Axon . predict ( model , params , inputs , predict_opts )
135135
136136 assert Nx . shape ( outputs . logits ) == { 1 , 10 , 2 }
137137
@@ -141,7 +141,7 @@ defmodule Emily.Conformance.DistilbertTest do
141141 )
142142 end
143143
144- test ":for_question_answering" do
144+ mode_test ":for_question_answering" do
145145 assert { :ok , % { model: model , params: params , spec: spec } } =
146146 Bumblebee . load_model (
147147 { :hf , "hf-internal-testing/tiny-random-DistilBertForQuestionAnswering" }
@@ -154,7 +154,7 @@ defmodule Emily.Conformance.DistilbertTest do
154154 "attention_mask" => Nx . tensor ( [ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 ] ] )
155155 }
156156
157- outputs = Axon . predict ( model , params , inputs )
157+ outputs = Axon . predict ( model , params , inputs , predict_opts )
158158
159159 assert Nx . shape ( outputs . start_logits ) == { 1 , 10 }
160160 assert Nx . shape ( outputs . end_logits ) == { 1 , 10 }
@@ -170,7 +170,7 @@ defmodule Emily.Conformance.DistilbertTest do
170170 )
171171 end
172172
173- test ":for_multiple_choice" do
173+ mode_test ":for_multiple_choice" do
174174 assert { :ok , % { model: model , params: params , spec: spec } } =
175175 Bumblebee . load_model (
176176 { :hf , "hf-internal-testing/tiny-random-DistilBertForMultipleChoice" }
@@ -183,7 +183,7 @@ defmodule Emily.Conformance.DistilbertTest do
183183 "attention_mask" => Nx . tensor ( [ [ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 ] ] ] )
184184 }
185185
186- outputs = Axon . predict ( model , params , inputs )
186+ outputs = Axon . predict ( model , params , inputs , predict_opts )
187187
188188 assert Nx . shape ( outputs . logits ) == { 1 , 1 }
189189
0 commit comments