@@ -4,7 +4,7 @@ import { Model, ModelConfig, InputFeed, ModelVar, GraphType } from './commons/in
44import OpData from './opFactory/opDataBuilder' ;
55import Tensor from './opFactory/tensor' ;
66import { GLOBALS } from './globals' ;
7- import { getGlobalInterface } from './commons/utils' ;
7+ import { getGlobalInterface , findVarByKey , AddItemToVars } from './commons/utils' ;
88import MediaProcessor from './mediaProcessor' ;
99import env from './env' ;
1010
@@ -174,7 +174,7 @@ export default class Runner {
174174 if ( feedOpInputs . length > 1 ) {
175175 // 多输入
176176 preheatFeedData = feedOpInputs . map ( inputName => {
177- const feedInfo = vars . find ( item => item . name === inputName ) ;
177+ const feedInfo = findVarByKey ( vars , inputName ) ;
178178 const shape = feedInfo . shape ;
179179 const [ w , h , c = 3 , n = 1 ] = shape . reverse ( ) ;
180180
@@ -184,7 +184,7 @@ export default class Runner {
184184 }
185185 }
186186 else {
187- preheatFeedData = vars . find ( item => item . name === 'image' ) ;
187+ preheatFeedData = findVarByKey ( vars , 'image' ) ;
188188 if ( preheatFeedData ) {
189189 preheatFeedData . data = new Float32Array ( fc * fh * fw ) . fill ( 1.0 ) ;
190190 return ;
@@ -197,7 +197,7 @@ export default class Runner {
197197 } ;
198198 }
199199
200- vars . push ( preheatFeedData ) ;
200+ AddItemToVars ( vars , preheatFeedData ) ;
201201 }
202202
203203 updateFeedData ( feed ) {
@@ -266,9 +266,7 @@ export default class Runner {
266266
267267 async read ( ) {
268268 const fetchOp = this . graphGenerator . getFetchExecutor ( ) ;
269- const fetchVar = this . model . vars . find (
270- item => item . name === fetchOp . inputs . X [ 0 ]
271- ) as ModelVar ;
269+ const fetchVar = findVarByKey ( this . model . vars , fetchOp . inputs . X [ 0 ] ) as ModelVar ;
272270 const fetchInfo = {
273271 name : fetchVar . name ,
274272 shape : fetchOp . attrs [ 'origin_shape' ] || fetchVar . shape
0 commit comments