Node - Merge encodings

This commit is contained in:
Pierric Cistac
2020-03-26 13:25:28 -04:00
committed by Anthony MOI
parent 4341c79d85
commit 0408567f23
6 changed files with 107 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import { PaddingOptions, RawEncoding } from "../bindings/raw-encoding";
import { mergeEncodings } from "../bindings/utils";
export class Encoding {
private _attentionMask?: number[];
@ -13,6 +14,20 @@ export class Encoding {
constructor(private rawEncoding: RawEncoding) {}
/**
* Merge a list of Encoding into one final Encoding
* @param encodings The list of encodings to merge
* @param [growingOffsets=false] Whether the offsets should accumulate while merging
*/
static merge(encodings: Encoding[], growingOffsets?: boolean): Encoding {
const mergedRaw = mergeEncodings(
encodings.map(e => e.rawEncoding),
growingOffsets
);
return new Encoding(mergedRaw);
}
/**
* Attention mask
*/