@@ -174,9 +174,9 @@ def forward(
174
174
175
175
np_inputs = isinstance (input_ids , np .ndarray )
176
176
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
180
180
181
181
inputs = {
182
182
"input_ids" : input_ids ,
@@ -239,9 +239,9 @@ def forward(
239
239
240
240
np_inputs = isinstance (input_ids , np .ndarray )
241
241
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
245
245
246
246
inputs = {
247
247
"input_ids" : input_ids ,
@@ -308,9 +308,9 @@ def forward(
308
308
309
309
np_inputs = isinstance (input_ids , np .ndarray )
310
310
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
314
314
315
315
inputs = {
316
316
"input_ids" : input_ids ,
@@ -379,9 +379,9 @@ def forward(
379
379
380
380
np_inputs = isinstance (input_ids , np .ndarray )
381
381
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
385
385
386
386
inputs = {
387
387
"input_ids" : input_ids ,
@@ -448,9 +448,9 @@ def forward(
448
448
449
449
np_inputs = isinstance (input_ids , np .ndarray )
450
450
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
454
454
455
455
inputs = {
456
456
"input_ids" : input_ids ,
@@ -581,7 +581,7 @@ def forward(
581
581
582
582
np_inputs = isinstance (pixel_values , np .ndarray )
583
583
if not np_inputs :
584
- pixel_values = np . array ( pixel_values )
584
+ pixel_values = pixel_values . cpu (). numpy ( )
585
585
586
586
inputs = {
587
587
"pixel_values" : pixel_values ,
@@ -640,8 +640,8 @@ def forward(
640
640
641
641
np_inputs = isinstance (input_values , np .ndarray )
642
642
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
645
645
646
646
inputs = {
647
647
"input_values" : input_values ,
@@ -711,8 +711,8 @@ def forward(
711
711
):
712
712
np_inputs = isinstance (input_values , np .ndarray )
713
713
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
716
716
717
717
inputs = {
718
718
"input_values" : input_values ,
@@ -791,8 +791,8 @@ def forward(
791
791
):
792
792
np_inputs = isinstance (input_values , np .ndarray )
793
793
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
796
796
797
797
inputs = {
798
798
"input_values" : input_values ,
@@ -867,8 +867,8 @@ def forward(
867
867
):
868
868
np_inputs = isinstance (input_values , np .ndarray )
869
869
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
872
872
873
873
inputs = {
874
874
"input_values" : input_values ,
@@ -929,7 +929,7 @@ def forward(self, **kwargs):
929
929
np_inputs = isinstance (next (iter (kwargs .values ())), np .ndarray )
930
930
inputs = {}
931
931
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 )
933
933
934
934
outputs = self ._inference (inputs )
935
935
model_outputs = {}
0 commit comments