Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) Lutz Roeder
Copyright 2025 Arm Limited and/or its affiliates <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <[email protected]>

import * as child_process from 'child_process';
import * as crypto from 'crypto';
Expand Down Expand Up @@ -611,7 +612,8 @@ const update = async () => {
'sentencepiece', 'sklearn',
'tf',
'uff',
'xmodel'
'xmodel',
'tosa'
];
let commands = [
'sync',
Expand Down
2 changes: 2 additions & 0 deletions publish/electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{ "ext": "cmf", "name": "CNTK Model" },
{ "ext": "dlc", "name": "DLC Model" },
{ "ext": "dnn", "name": "CNTK Model" },
{ "ext": "tosa", "name": "TOSA Model" },
{ "ext": "gguf", "name": "GGUF Model" },
{ "ext": "h5", "name": "Keras Model" },
{ "ext": "hd5", "name": "Keras Model" },
Expand Down Expand Up @@ -62,6 +63,7 @@
{ "ext": "t7", "name": "Torch Model" },
{ "ext": "tfl", "name": "TensorFlow Lite Model" },
{ "ext": "tflite", "name": "TensorFlow Lite Model" },
{ "ext": "tosa", "name": "TOSA Model" },
{ "ext": "tmfile", "name": "Tengine Model" },
{ "ext": "tm", "name": "MegEngine Traced Model" },
{ "ext": "tnnproto", "name": "TNN Model" },
Expand Down
33 changes: 31 additions & 2 deletions source/base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <[email protected]>

const base = {};

Expand Down Expand Up @@ -240,6 +241,28 @@ DataView.prototype.getUintBits = DataView.prototype.getUintBits || function(offs
return value & ((1 << bits) - 1);
};

DataView.prototype.getInt48 = DataView.prototype.getInt48 || function(offset, littleEndian) {
const bits = 48n;
const shift = littleEndian ? 0n : 16n;
let value = 0n;
if (this.byteLength - offset < 8) {
const buffer = new ArrayBuffer(8);
const view = new DataView(buffer);
for (let i = 0; i < 6; i++) {
view.setUint8(i, this.getUint8(offset + i));
}
value = view.getBigUint64(0, littleEndian);
} else {
value = this.getBigUint64(offset, littleEndian);
}
value >>= shift;
value &= (1n << bits) - 1n;
if (value & (1n << (bits - 1n))) {
value -= 1n << bits;
}
return value;
};

DataView.prototype.getComplex64 = DataView.prototype.getComplex64 || function(byteOffset, littleEndian) {
const real = littleEndian ? this.getFloat32(byteOffset, littleEndian) : this.getFloat32(byteOffset + 4, littleEndian);
const imaginary = littleEndian ? this.getFloat32(byteOffset + 4, littleEndian) : this.getFloat32(byteOffset, littleEndian);
Expand Down Expand Up @@ -611,7 +634,7 @@ base.Tensor = class {
['qint8', 1], ['qint16', 2], ['qint32', 4],
['quint8', 1], ['quint16', 2], ['quint32', 4],
['xint8', 1],
['int8', 1], ['int16', 2], ['int32', 4], ['int64', 8],
['int8', 1], ['int16', 2], ['int32', 4], ['int48', 6], ['int64', 8],
['uint8', 1], ['uint16', 2], ['uint32', 4,], ['uint64', 8],
['float16', 2], ['float32', 4], ['float64', 8], ['bfloat16', 2],
['complex64', 8], ['complex128', 16],
Expand Down Expand Up @@ -871,6 +894,11 @@ base.Tensor = class {
results.push(view.getInt32(offset, this._littleEndian));
}
break;
case 'int48':
for (; offset < max; offset += stride) {
results.push(view.getInt48(offset, this._littleEndian));
}
break;
case 'int64':
for (; offset < max; offset += stride) {
results.push(view.getBigInt64(offset, this._littleEndian));
Expand Down Expand Up @@ -1274,7 +1302,8 @@ base.Metadata = class {
'ptl', 't7',
'dlc', 'uff', 'armnn', 'kann', 'kgraph',
'mnn', 'ms', 'ncnn', 'om', 'tm', 'mge', 'tmfile', 'tnnproto', 'xmodel', 'kmodel', 'rknn',
'tar', 'zip'
'tar', 'zip',
'tosa'
];
}
};
Expand Down
Loading
Loading