face-api/src/common/disposeUnusedWeightTensors.ts

10 lines
290 B
TypeScript
Raw Normal View History

2020-08-18 13:54:53 +02:00
import { ParamMapping } from './types';
export function disposeUnusedWeightTensors(weightMap: any, paramMappings: ParamMapping[]) {
2020-12-23 17:26:55 +01:00
Object.keys(weightMap).forEach((path) => {
if (!paramMappings.some((pm) => pm.originalPath === path)) {
weightMap[path].dispose();
2020-08-18 13:54:53 +02:00
}
2020-12-23 17:26:55 +01:00
});
2020-08-18 13:54:53 +02:00
}