@@ -174,9 +174,9 @@ def forward(
174174
175175 np_inputs = isinstance (input_ids , np .ndarray )
176176 if not np_inputs :
177- input_ids = np . array ( input_ids )
178- attention_mask = np . array ( attention_mask )
179- token_type_ids = np . array ( token_type_ids ) if token_type_ids is not None else token_type_ids
177+ input_ids = input_ids . cpu (). numpy ( )
178+ attention_mask = attention_mask . cpu (). numpy ( )
179+ token_type_ids = token_type_ids . cpu (). numpy ( ) if token_type_ids is not None else token_type_ids
180180
181181 inputs = {
182182 "input_ids" : input_ids ,
@@ -239,9 +239,9 @@ def forward(
239239
240240 np_inputs = isinstance (input_ids , np .ndarray )
241241 if not np_inputs :
242- input_ids = np . array ( input_ids )
243- attention_mask = np . array ( attention_mask )
244- token_type_ids = np . array ( token_type_ids ) if token_type_ids is not None else token_type_ids
242+ input_ids = input_ids . cpu (). numpy ( )
243+ attention_mask = attention_mask . cpu (). numpy ( )
244+ token_type_ids = token_type_ids . cpu (). numpy ( ) if token_type_ids is not None else token_type_ids
245245
246246 inputs = {
247247 "input_ids" : input_ids ,
@@ -308,9 +308,9 @@ def forward(
308308
309309 np_inputs = isinstance (input_ids , np .ndarray )
310310 if not np_inputs :
311- input_ids = np . array ( input_ids )
312- attention_mask = np . array ( attention_mask )
313- token_type_ids = np . array ( token_type_ids ) if token_type_ids is not None else token_type_ids
311+ input_ids = input_ids . cpu (). numpy ( )
312+ attention_mask = attention_mask . cpu (). numpy ( )
313+ token_type_ids = token_type_ids . cpu (). numpy ( ) if token_type_ids is not None else token_type_ids
314314
315315 inputs = {
316316 "input_ids" : input_ids ,
@@ -379,9 +379,9 @@ def forward(
379379
380380 np_inputs = isinstance (input_ids , np .ndarray )
381381 if not np_inputs :
382- input_ids = np . array ( input_ids )
383- attention_mask = np . array ( attention_mask )
384- token_type_ids = np . array ( token_type_ids ) if token_type_ids is not None else token_type_ids
382+ input_ids = input_ids . cpu (). numpy ( )
383+ attention_mask = attention_mask . cpu (). numpy ( )
384+ token_type_ids = token_type_ids . cpu (). numpy ( ) if token_type_ids is not None else token_type_ids
385385
386386 inputs = {
387387 "input_ids" : input_ids ,
@@ -448,9 +448,9 @@ def forward(
448448
449449 np_inputs = isinstance (input_ids , np .ndarray )
450450 if not np_inputs :
451- input_ids = np . array ( input_ids )
452- attention_mask = np . array ( attention_mask )
453- token_type_ids = np . array ( token_type_ids ) if token_type_ids is not None else token_type_ids
451+ input_ids = input_ids . cpu (). numpy ( )
452+ attention_mask = attention_mask . cpu (). numpy ( )
453+ token_type_ids = token_type_ids . cpu (). numpy ( ) if token_type_ids is not None else token_type_ids
454454
455455 inputs = {
456456 "input_ids" : input_ids ,
@@ -581,7 +581,7 @@ def forward(
581581
582582 np_inputs = isinstance (pixel_values , np .ndarray )
583583 if not np_inputs :
584- pixel_values = np . array ( pixel_values )
584+ pixel_values = pixel_values . cpu (). numpy ( )
585585
586586 inputs = {
587587 "pixel_values" : pixel_values ,
@@ -640,8 +640,8 @@ def forward(
640640
641641 np_inputs = isinstance (input_values , np .ndarray )
642642 if not np_inputs :
643- input_values = np . array ( input_values )
644- attention_mask = np . array ( attention_mask ) if attention_mask is not None else attention_mask
643+ input_values = input_values . cpu (). numpy ( )
644+ attention_mask = attention_mask . cpu (). numpy ( ) if attention_mask is not None else attention_mask
645645
646646 inputs = {
647647 "input_values" : input_values ,
@@ -711,8 +711,8 @@ def forward(
711711 ):
712712 np_inputs = isinstance (input_values , np .ndarray )
713713 if not np_inputs :
714- input_values = np . array ( input_values )
715- attention_mask = np . array ( attention_mask ) if attention_mask is not None else attention_mask
714+ input_values = input_values . cpu (). numpy ( )
715+ attention_mask = attention_mask . cpu (). numpy ( ) if attention_mask is not None else attention_mask
716716
717717 inputs = {
718718 "input_values" : input_values ,
@@ -791,8 +791,8 @@ def forward(
791791 ):
792792 np_inputs = isinstance (input_values , np .ndarray )
793793 if not np_inputs :
794- input_values = np . array ( input_values )
795- attention_mask = np . array ( attention_mask ) if attention_mask is not None else attention_mask
794+ input_values = input_values . cpu (). numpy ( )
795+ attention_mask = attention_mask . cpu (). numpy ( ) if attention_mask is not None else attention_mask
796796
797797 inputs = {
798798 "input_values" : input_values ,
@@ -867,8 +867,8 @@ def forward(
867867 ):
868868 np_inputs = isinstance (input_values , np .ndarray )
869869 if not np_inputs :
870- input_values = np . array ( input_values )
871- attention_mask = np . array ( attention_mask ) if attention_mask is not None else attention_mask
870+ input_values = input_values . cpu (). numpy ( )
871+ attention_mask = attention_mask . cpu (). numpy ( ) if attention_mask is not None else attention_mask
872872
873873 inputs = {
874874 "input_values" : input_values ,
@@ -929,7 +929,7 @@ def forward(self, **kwargs):
929929 np_inputs = isinstance (next (iter (kwargs .values ())), np .ndarray )
930930 inputs = {}
931931 for input_name in self .input_names :
932- inputs [input_name ] = np . array ( kwargs .pop (input_name )) if not np_inputs else kwargs .pop (input_name )
932+ inputs [input_name ] = kwargs .pop (input_name ). cpu (). numpy ( ) if not np_inputs else kwargs .pop (input_name )
933933
934934 outputs = self ._inference (inputs )
935935 model_outputs = {}
0 commit comments