File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @paddlejs/paddlejs-core" ,
3
- "version" : " 2.1.19 " ,
3
+ "version" : " 2.1.28 " ,
4
4
"description" : " " ,
5
5
"main" : " lib/index" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -63,9 +63,13 @@ export interface FeedShape {
63
63
fh : number ;
64
64
} ;
65
65
66
+
67
+ export interface ParamObject {
68
+ [ key : string ] : number ;
69
+ }
66
70
interface ModelObj {
67
71
model : Model ;
68
- params : Float32Array
72
+ params : Float32Array | ParamObject
69
73
}
70
74
export interface RunnerConfig {
71
75
modelPath ?: string ;
Original file line number Diff line number Diff line change 3
3
*/
4
4
5
5
import env from './env' ;
6
- import { Model } from './commons/interface' ;
6
+ import { Model , ParamObject } from './commons/interface' ;
7
7
import { traverseVars } from './commons/utils' ;
8
8
9
9
interface UrlConf {
@@ -126,14 +126,15 @@ export default class ModelLoader {
126
126
} ) ;
127
127
}
128
128
129
- static allocateParamsVar ( vars , allChunksData : Float32Array ) {
129
+ static allocateParamsVar ( vars , allChunksData : Float32Array | ParamObject ) {
130
130
let marker = 0 ; // 读到哪个位置了
131
131
let len ; // 当前op长度
132
+ const chunkData : number [ ] = Array . isArray ( allChunksData ) ? allChunksData : Object . values ( allChunksData ) ;
132
133
traverseVars ( vars , item => {
133
134
len = item . shape . reduce ( ( a , b ) => a * b ) ; // 长度为shape的乘积
134
135
// 为了减少模型体积,模型转换工具不会导出非persistable的数据,这里只需要读取persistable的数据
135
136
if ( item . persistable ) {
136
- item . data = allChunksData . slice ( marker , marker + len ) ;
137
+ item . data = chunkData . slice ( marker , marker + len ) ;
137
138
marker += len ;
138
139
}
139
140
} ) ;
You can’t perform that action at this time.
0 commit comments