File tree 3 files changed +9
-5
lines changed
3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 28
28
)
29
29
print ('loaded processor and ckpt ' )
30
30
question = 'describe this image'
31
- image = "/home/HwHiAiUser/janus-pro-mindspore /inpain_model_cat.png"
31
+ image = ". /inpain_model_cat.png"
32
32
conversation = [
33
33
{
34
34
"role" : "<|User|>" ,
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ def argwhere(input):
21
21
# cat
22
22
has_cat = hasattr (mindspore .mint , 'cat' )
23
23
def cat (tensors , dim = 0 ):
24
- if use_pyboost () and has_cat :
25
- return mindspore .mint .cat (tensors , dim )
24
+ # if use_pyboost() and has_cat:
25
+ # return mindspore.mint.cat(tensors, dim)
26
26
return ops .cat (tensors , dim )
27
27
28
28
# concat
Original file line number Diff line number Diff line change @@ -364,7 +364,10 @@ def update(
364
364
# Update the number of seen tokens
365
365
if layer_idx == 0 :
366
366
self ._seen_tokens += key_states .shape [- 2 ]
367
-
367
+ if key_states .dtype != mindspore .float16 :
368
+ key_states = key_states .astype (mindspore .float16 )
369
+ if key_states .dtype != mindspore .float16 :
370
+ value_states = value_states .astype (mindspore .float16 )
368
371
# Update the cache
369
372
if len (self .key_cache ) <= layer_idx :
370
373
self .key_cache .append (key_states )
@@ -375,7 +378,8 @@ def update(
375
378
self .key_cache [layer_idx ] = key_states
376
379
self .value_cache [layer_idx ] = value_states
377
380
else :
378
- self .key_cache [layer_idx ] = ops .cat ([self .key_cache [layer_idx ], key_states ], dim = - 2 )
381
+ self .key_cache [layer_idx ] = ops .cat (
382
+ [self .key_cache [layer_idx ].astype (mindspore .float16 ), key_states .astype (mindspore .float16 )], dim = - 2 )
379
383
self .value_cache [layer_idx ] = ops .cat ([self .value_cache [layer_idx ], value_states ], dim = - 2 )
380
384
381
385
return self .key_cache [layer_idx ], self .value_cache [layer_idx ]
You can’t perform that action at this time.
0 commit comments