Bläddra i källkod

Update Int64 prototype

Lutz Roeder 5 år sedan
förälder
incheckning
46153e7747
26 ändrade filer med 650 tillägg och 362 borttagningar
  1. 0 1
      package.json
  2. 1 2
      setup.py
  3. 388 21
      src/base.js
  4. 2 2
      src/bigdl-proto.js
  5. 4 7
      src/bigdl.js
  6. 0 1
      src/bson.js
  7. 1 1
      src/caffe-proto.js
  8. 1 7
      src/caffe.js
  9. 10 10
      src/caffe2-proto.js
  10. 3 3
      src/cntk-proto.js
  11. 2 13
      src/cntk.js
  12. 98 98
      src/coreml-proto.js
  13. 2 8
      src/coreml.js
  14. 0 1
      src/index.html
  15. 0 1
      src/mxnet.js
  16. 0 1
      src/npz.js
  17. 10 10
      src/onnx-proto.js
  18. 2 2
      src/paddle-proto.js
  19. 49 101
      src/protobuf.js
  20. 18 8
      src/pytorch.js
  21. 0 1
      src/sklearn.js
  22. 40 40
      src/tf-proto.js
  23. 4 4
      src/tf.js
  24. 3 3
      src/uff-proto.js
  25. 3 6
      src/view-sidebar.js
  26. 9 10
      tools/protoc.js

+ 0 - 1
package.json

@@ -20,7 +20,6 @@
         "d3": "5.16.0",
         "dagre": "0.8.5",
         "electron-updater": "4.3.4",
-        "long": "4.0.0",
         "marked": "1.1.1",
         "pako": "1.0.11",
         "universal-analytics": "0.4.23"

+ 1 - 2
setup.py

@@ -13,8 +13,7 @@ node_dependencies = [
         'node_modules/d3/dist/d3.min.js',
         'node_modules/dagre/dist/dagre.min.js',
         'node_modules/marked/marked.min.js',
-        'node_modules/pako/dist/pako.min.js',
-        'node_modules/long/dist/long.js' ] )
+        'node_modules/pako/dist/pako.min.js' ] )
 ]
 
 class build(distutils.command.build.build):

+ 388 - 21
src/base.js

@@ -1,13 +1,89 @@
 /* jshint esversion: 6 */
 
 var base = base || {};
-var long = (typeof window !== 'undefined' && typeof window.Long != 'undefined') ? { Long: window.Long } : { Long: require('long') };
 
 base.Int64 = class Int64 {
 
     constructor(low, high) {
-        this.low = low;
-        this.high = high;
+        this.low = low | 0;
+        this.high = high | 0;
+    }
+
+    static create(value) {
+        if (isNaN(value)) {
+            return base.Int64.zero;
+        }
+        if (value <= -9223372036854776000) {
+            return base.Int64.min;
+        }
+        if (value + 1 >= 9223372036854776000) {
+            return base.Int64.max;
+        }
+        if (value < 0) {
+            return base.Int64.create(-value).negate();
+        }
+        return new base.Int64((value % 4294967296) | 0, (value / 4294967296));
+    }
+
+    get isZero() {
+        return this.low === 0 && this.high === 0;
+    }
+
+    get isNegative() {
+        return this.high < 0;
+    }
+
+    negate() {
+        if (this.equals(base.Int64.min)) {
+            return base.Int64.min;
+        }
+        return this.not().add(base.Int64.one);
+    }
+
+    not() {
+        return new Int64(~this.low, ~this.high);
+    }
+
+    equals(other) {
+        if (!(other instanceof base.Int64) && (this.high >>> 31) === 1 && (other.high >>> 31) === 1) {
+            return false;
+        }
+        return this.high === other.high && this.low === other.low;
+    }
+
+    compare(other) {
+        if (this.equals(other)) {
+            return 0;
+        }
+        const thisNeg = this.isNegative;
+        const otherNeg = other.isNegative;
+        if (thisNeg && !otherNeg) {
+            return -1;
+        }
+        if (!thisNeg && otherNeg) {
+            return 1;
+        }
+        return this.subtract(other).isNegative ? -1 : 1;
+    }
+
+    add(other) {
+        return base.Utility.add(this, other, false);
+    }
+
+    subtract(other) {
+        return base.Utility.subtract(this, other, false);
+    }
+
+    multiply(other) {
+        return base.Utility.multiply(this, other, false);
+    }
+
+    divide(other) {
+        return base.Utility.divide(this, other, false);
+    }
+
+    toInteger() {
+        return this.low;
     }
 
     toNumber() {
@@ -16,24 +92,110 @@ base.Int64 = class Int64 {
 
     toString(radix) {
         radix = radix || 10;
-        if (radix < 2 || 36 < radix) {
+        if (radix < 2 || radix > 16) {
             throw RangeError('radix');
         }
-        if (this.high === 0 && this.low === 0) {
+        if (this.isZero) {
             return '0';
         }
         if (this.high < 0) {
-            throw new Error('Not implemented.');
+            if (this.equals(base.Int64.min)) {
+                const r = new Int64(radix, 0);
+                const div = this.divide(r);
+                const remainder = div.multiply(r).subtract(this);
+                return div.toString(radix) + (remainder.low >>> 0).toString(radix);
+            }
+            return '-' + this.negate().toString(radix);
         }
-        throw new Error('Not implemented.');
+        return base.Utility.text(this, false, radix);
     }
 };
 
+base.Int64.min = new base.Int64(0, -2147483648);
+base.Int64.zero = new base.Int64(0, 0);
+base.Int64.one = new base.Int64(1, 0);
+base.Int64.power24 = new base.Int64(1 << 24, 0);
+base.Int64.max = new base.Int64(0, 2147483647);
+
 base.Uint64 = class Uint64 {
 
     constructor(low, high) {
-        this.low = low;
-        this.high = high;
+        this.low = low | 0;
+        this.high = high | 0;
+    }
+
+    static create(value) {
+        if (isNaN(value)) {
+            return base.Uint64.zero;
+        }
+        if (value < 0) {
+            return base.Uint64.zero;
+        }
+        if (value >= 18446744073709552000) {
+            return base.Uint64.max;
+        }
+        if (value < 0) {
+            return base.Uint64.create(-value).negate();
+        }
+        return new base.Uint64((value % 4294967296) | 0, (value / 4294967296));
+    }
+
+    get isZero() {
+        return this.low === 0 && this.high === 0;
+    }
+
+    get isNegative() {
+        return false;
+    }
+
+    negate() {
+        return this.not().add(base.Int64.one);
+    }
+
+    not() {
+        return new base.Uint64(~this.low, ~this.high);
+    }
+
+    equals(other) {
+        if (!(other instanceof base.Uint64) && (this.high >>> 31) === 1 && (other.high >>> 31) === 1) {
+            return false;
+        }
+        return this.high === other.high && this.low === other.low;
+    }
+
+    compare(other) {
+        if (this.equals(other)) {
+            return 0;
+        }
+        const thisNeg = this.isNegative;
+        const otherNeg = other.isNegative;
+        if (thisNeg && !otherNeg) {
+            return -1;
+        }
+        if (!thisNeg && otherNeg) {
+            return 1;
+        }
+        return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
+    }
+
+    add(other) {
+        return base.Utility.add(this, other, true);
+    }
+
+    subtract(other) {
+        return base.Utility.subtract(this, other, true);
+    }
+
+    multiply(other) {
+        return base.Utility.multiply(this, other, true);
+    }
+
+    divide(other) {
+        return base.Utility.divide(this, other, true);
+    }
+
+    toInteger() {
+        return this.low >>> 0;
     }
 
     toNumber() {
@@ -41,16 +203,227 @@ base.Uint64 = class Uint64 {
     }
 
     toString(radix) {
+        radix = radix || 10;
         if (radix < 2 || 36 < radix) {
             throw RangeError('radix');
         }
-        if (this.high === 0 && this.low === 0) {
+        if (this.isZero) {
             return '0';
         }
-        throw new Error('Not implemented.');
+        return base.Utility.text(this, true, radix);
+    }
+};
+
+base.Utility = class {
+
+    static add(a, b, unsigned) {
+        const a48 = a.high >>> 16;
+        const a32 = a.high & 0xFFFF;
+        const a16 = a.low >>> 16;
+        const a00 = a.low & 0xFFFF;
+        const b48 = b.high >>> 16;
+        const b32 = b.high & 0xFFFF;
+        const b16 = b.low >>> 16;
+        const b00 = b.low & 0xFFFF;
+        let c48 = 0;
+        let c32 = 0;
+        let c16 = 0;
+        let c00 = 0;
+        c00 += a00 + b00;
+        c16 += c00 >>> 16;
+        c00 &= 0xFFFF;
+        c16 += a16 + b16;
+        c32 += c16 >>> 16;
+        c16 &= 0xFFFF;
+        c32 += a32 + b32;
+        c48 += c32 >>> 16;
+        c32 &= 0xFFFF;
+        c48 += a48 + b48;
+        c48 &= 0xFFFF;
+        return base.Utility._create((c16 << 16) | c00, (c48 << 16) | c32, unsigned);
+    }
+
+    static subtract(a, b, unsigned) {
+        return base.Utility.add(a, b.negate(), unsigned);
+    }
+
+    static multiply(a, b, unsigned) {
+        if (a.isZero) {
+            return base.Int64.zero;
+        }
+        if (b.isZero) {
+            return base.Int64.zero;
+        }
+        if (a.equals(base.Int64.min)) {
+            return b.isOdd() ? base.Int64.min : base.Int64.zero;
+        }
+        if (b.equals(base.Int64.min)) {
+            return b.isOdd() ? base.Int64.min : base.Int64.zero;
+        }
+        if (a.isNegative) {
+            if (b.isNegative) {
+                return this.negate().multiply(b.negate());
+            }
+            else {
+                return this.negate().multiply(b).negate();
+            }
+        }
+        else if (b.isNegative) {
+            return this.multiply(b.negate()).negate();
+        }
+        if (a.compare(base.Int64.power24) < 0 && b.compare(base.Int64.power24) < 0) {
+            return unsigned ? base.Uint64.create(a.toNumber() * b.toNumber()) : base.Int64.create(a.toNumber() * b.toNumber());
+        }
+        const a48 = a.high >>> 16;
+        const a32 = a.high & 0xFFFF;
+        const a16 = a.low >>> 16;
+        const a00 = a.low & 0xFFFF;
+        const b48 = b.high >>> 16;
+        const b32 = b.high & 0xFFFF;
+        const b16 = b.low >>> 16;
+        const b00 = b.low & 0xFFFF;
+        let c48 = 0;
+        let c32 = 0;
+        let c16 = 0;
+        let c00 = 0;
+        c00 += a00 * b00;
+        c16 += c00 >>> 16;
+        c00 &= 0xFFFF;
+        c16 += a16 * b00;
+        c32 += c16 >>> 16;
+        c16 &= 0xFFFF;
+        c16 += a00 * b16;
+        c32 += c16 >>> 16;
+        c16 &= 0xFFFF;
+        c32 += a32 * b00;
+        c48 += c32 >>> 16;
+        c32 &= 0xFFFF;
+        c32 += a16 * b16;
+        c48 += c32 >>> 16;
+        c32 &= 0xFFFF;
+        c32 += a00 * b32;
+        c48 += c32 >>> 16;
+        c32 &= 0xFFFF;
+        c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
+        c48 &= 0xFFFF;
+        return base.Utility._create((c16 << 16) | c00, (c48 << 16) | c32, unsigned);
+    }
+
+    static divide(a, b, unsigned) {
+        if (b.isZero) {
+            throw Error('Division by zero.');
+        }
+        if (a.isZero) {
+            return unsigned ? base.Uint64.zero : base.Int64.zero;
+        }
+        let approx;
+        let remainder;
+        let result;
+        if (!unsigned) {
+            if (a.equals(base.Int64.min)) {
+                if (b.equals(base.Int64.one) || b.equals(base.Int64.negativeOne)) {
+                    return base.Int64.min;
+                }
+                else if (b.equals(base.Int64.min)) {
+                    return base.Int64.one;
+                }
+                else {
+                    const half = base.Utility._shiftRight(a, unsigned, 1);
+                    const halfDivide = half.divide(b);
+                    approx = base.Utility._shiftLeft(halfDivide, halfDivide instanceof base.Uint64, 1);
+                    if (approx.eq(base.Int64.zero)) {
+                        return b.isNegative ? base.Int64.one : base.Int64.negativeOne;
+                    }
+                    else {
+                        remainder = a.subtract(b.multiply(approx));
+                        result = approx.add(remainder.divide(b));
+                        return result;
+                    }
+                }
+            }
+            else if (b.equals(base.Int64.min)) {
+                return unsigned ? base.Uint64.zero : base.Int64.zero;
+            }
+            if (a.isNegative) {
+                if (b.isNegative) {
+                    return this.negate().divide(b.negate());
+                }
+                return a.negate().divide(b).negate();
+            }
+            else if (b.isNegative) {
+                return a.divide(b.negate()).negate();
+            }
+            result = base.Int64.zero;
+        }
+        else {
+            if (!(b instanceof base.Uint64)) {
+                b = new base.Uint64(b.low, b.high);
+            }
+            if (b.compare(a) > 0) {
+                return base.Int64.zero;
+            }
+            if (b.compare(base.Utility._shiftRight(a, unsigned, 1)) > 0) {
+                return base.Uint64.one;
+            }
+            result = base.Uint64.zero;
+        }
+        remainder = a;
+        while (remainder.compare(b) >= 0) {
+            let approx = Math.max(1, Math.floor(remainder.toNumber() / b.toNumber()));
+            const log2 = Math.ceil(Math.log(approx) / Math.LN2);
+            const delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);
+            let approxResult = base.Int64.create(approx);
+            let approxRemainder = approxResult.multiply(b);
+            while (approxRemainder.isNegative || approxRemainder.compare(remainder) > 0) {
+                approx -= delta;
+                approxResult = unsigned ? base.Uint64.create(approx) : base.Int64.create(approx);
+                approxRemainder = approxResult.multiply(b);
+            }
+            if (approxResult.isZero) {
+                approxResult = base.Int64.one;
+            }
+            result = result.add(approxResult);
+            remainder = remainder.subtract(approxRemainder);
+        }
+        return result;
+    }
+
+    static text(value, unsigned, radix) {
+        const power = unsigned ? base.Uint64.create(Math.pow(radix, 6)) : base.Int64.create(Math.pow(radix, 6));
+        let remainder = value;
+        let result = '';
+        for (;;) {
+            const remainderDiv = remainder.divide(power);
+            const intval = remainder.subtract(remainderDiv.multiply(power)).toInteger() >>> 0;
+            let digits = intval.toString(radix);
+            remainder = remainderDiv;
+            if (remainder.low === 0 && remainder.high === 0) {
+                return digits + result;
+            }
+            while (digits.length < 6) {
+                digits = '0' + digits;
+            }
+            result = '' + digits + result;
+        }
+    }
+
+    static _shiftLeft(value, unsigned, shift) {
+        return base.Utility._create(value.low << shift, (value.high << shift) | (value.low >>> (32 - shift)), unsigned);
+    }
+
+    static _shiftRight(value, unsigned, shift) {
+        return base.Utility._create((value.low >>> shift) | (value.high << (32 - shift)), value.high >> shift, unsigned);
+    }
+
+    static _create(low, high, unsigned) {
+        return unsigned ? new base.Uint64(low, high) : new base.Int64(low, high);
     }
 };
 
+base.Uint64.zero = new base.Uint64(0, 0);
+base.Uint64.one = new base.Uint64(1, 0);
+base.Uint64.max = new base.Uint64(-1, -1);
+
 if (!DataView.prototype.getFloat16) {
     DataView.prototype.getFloat16 = function(byteOffset, littleEndian) {
         const value = this.getUint16(byteOffset, littleEndian);
@@ -116,11 +489,8 @@ if (!DataView.prototype.setFloat16) {
 
 DataView.prototype.getInt64 = DataView.prototype.getInt64 || function(byteOffset, littleEndian) {
     return littleEndian ?
-        new long.Long(this.getUint32(byteOffset, true), this.getUint32(byteOffset + 4, true), false) :
-        new long.Long(this.getUint32(byteOffset + 4, true), this.getUint32(byteOffset, true), false);
-    // return littleEndian ?
-    //     new base.Int64(this.getUint32(byteOffset, true), this.getUint32(byteOffset + 4, true)) :
-    //     new base.Int64(this.getUint32(byteOffset + 4, true), this.getUint32(byteOffset, true));
+        new base.Int64(this.getUint32(byteOffset, true), this.getUint32(byteOffset + 4, true)) :
+        new base.Int64(this.getUint32(byteOffset + 4, true), this.getUint32(byteOffset, true));
 };
 
 DataView.prototype.setInt64 = DataView.prototype.setInt64 || function(byteOffset, value, littleEndian) {
@@ -136,11 +506,8 @@ DataView.prototype.setInt64 = DataView.prototype.setInt64 || function(byteOffset
 
 DataView.prototype.getUint64 = DataView.prototype.getUint64 || function(byteOffset, littleEndian) {
     return littleEndian ?
-        new long.Long(this.getUint32(byteOffset, true), this.getUint32(byteOffset + 4, true), true) :
-        new long.Long(this.getUint32(byteOffset + 4, true), this.getUint32(byteOffset, true), true);
-    // return littleEndian ?
-    //     new base.Uint64(this.getUint32(byteOffset, true), this.getUint32(byteOffset + 4, true)) :
-    //     new base.Uint64(this.getUint32(byteOffset + 4, true), this.getUint32(byteOffset, true));
+        new base.Uint64(this.getUint32(byteOffset, true), this.getUint32(byteOffset + 4, true)) :
+        new base.Uint64(this.getUint32(byteOffset + 4, true), this.getUint32(byteOffset, true));
 };
 
 DataView.prototype.setUint64 = DataView.prototype.setUint64 || function(byteOffset, value, littleEndian) {

+ 2 - 2
src/bigdl-proto.js

@@ -51,7 +51,7 @@ $root.com.intel.analytics.bigdl.serialization.BigDLModule = class BigDLModule {
                     message.moduleType = reader.string();
                     break;
                 case 8:
-                    reader.pair(message.attr, () => reader.string(), () => $root.com.intel.analytics.bigdl.serialization.AttrValue.decode(reader, reader.uint32()));
+                    reader.entry(message.attr, () => reader.string(), () => $root.com.intel.analytics.bigdl.serialization.AttrValue.decode(reader, reader.uint32()));
                     break;
                 case 9:
                     message.version = reader.string();
@@ -549,7 +549,7 @@ $root.com.intel.analytics.bigdl.serialization.NameAttrList = class NameAttrList
                     message.name = reader.string();
                     break;
                 case 2:
-                    reader.pair(message.attr, () => reader.string(), () => $root.com.intel.analytics.bigdl.serialization.AttrValue.decode(reader, reader.uint32()));
+                    reader.entry(message.attr, () => reader.string(), () => $root.com.intel.analytics.bigdl.serialization.AttrValue.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);

+ 4 - 7
src/bigdl.js

@@ -3,7 +3,6 @@
 // Experimental
 
 var bigdl = bigdl || {};
-var long = long || { Long: require('long') };
 var protobuf = protobuf || require('./protobuf');
 
 bigdl.ModelFactory = class {
@@ -411,12 +410,10 @@ bigdl.TensorType = class {
 bigdl.TensorShape = class {
 
     constructor(dimensions) {
-        this._dimensions = dimensions.map((dimension) => {
-            if (dimension && long.Long.isLong(dimension)) {
-                return dimension.toNumber();
-            }
-            return dimension;
-        });
+        this._dimensions = dimensions;
+        if (!dimensions.every((dimension) => Number.isInteger(dimension))) {
+            throw new bigdl.Error("Invalid tensor shape '" + JSON.stringify(dimensions) + "'.");
+        }
     }
 
     get dimensions() {

+ 0 - 1
src/bson.js

@@ -3,7 +3,6 @@
 // Experimental BSON JavaScript reader
 
 var bson = {};
-var long = long || { Long: require('long') };
 
 // http://bsonspec.org/spec.html
 bson.Reader = class {

+ 1 - 1
src/caffe-proto.js

@@ -780,7 +780,7 @@ $root.caffe.SolverParameter.prototype.snapshot_diff = false;
 $root.caffe.SolverParameter.prototype.snapshot_format = 1;
 $root.caffe.SolverParameter.prototype.solver_mode = 1;
 $root.caffe.SolverParameter.prototype.device_id = 0;
-$root.caffe.SolverParameter.prototype.random_seed = protobuf.Long ? protobuf.Long.fromBits(-1, -1, false) : -1;
+$root.caffe.SolverParameter.prototype.random_seed = protobuf.Int64.create(-1);
 $root.caffe.SolverParameter.prototype.type = "SGD";
 $root.caffe.SolverParameter.prototype.delta = 1e-8;
 $root.caffe.SolverParameter.prototype.momentum2 = 0.999;

+ 1 - 7
src/caffe.js

@@ -1,7 +1,6 @@
 /* jshint esversion: 6 */
 
 var caffe = caffe || {};
-var long = long || { Long: require('long') };
 var protobuf = protobuf || require('./protobuf');
 
 caffe.ModelFactory = class {
@@ -741,12 +740,7 @@ caffe.TensorType = class {
 caffe.TensorShape = class {
 
     constructor(dimensions) {
-        this._dimensions = dimensions.map((dimension) => {
-            if (dimension && long.Long.isLong(dimension)) {
-                return dimension.toNumber();
-            }
-            return dimension;
-        });
+        this._dimensions = dimensions.map((dimension) => Number.isInteger(dimension) ? dimension : dimension.toNumber());
     }
 
     get dimensions() {

+ 10 - 10
src/caffe2-proto.js

@@ -69,8 +69,8 @@ $root.caffe2.ExternalDataProto = class ExternalDataProto {
 
 $root.caffe2.ExternalDataProto.prototype.source_type = 0;
 $root.caffe2.ExternalDataProto.prototype.record_id = "";
-$root.caffe2.ExternalDataProto.prototype.record_size = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.caffe2.ExternalDataProto.prototype.offset = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.ExternalDataProto.prototype.record_size = protobuf.Uint64.create(0);
+$root.caffe2.ExternalDataProto.prototype.offset = protobuf.Int64.create(0);
 
 $root.caffe2.ExternalDataProto.SourceType = {
     "INLINE_CONTAINER": 0,
@@ -290,8 +290,8 @@ $root.caffe2.TensorProto.Segment = class Segment {
     }
 };
 
-$root.caffe2.TensorProto.Segment.prototype.begin = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.caffe2.TensorProto.Segment.prototype.end = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.TensorProto.Segment.prototype.begin = protobuf.Int64.create(0);
+$root.caffe2.TensorProto.Segment.prototype.end = protobuf.Int64.create(0);
 
 $root.caffe2.QTensorProto = class QTensorProto {
 
@@ -703,8 +703,8 @@ $root.caffe2.TensorBoundShapes = class TensorBoundShapes {
     }
 };
 
-$root.caffe2.TensorBoundShapes.prototype.max_batch_size = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.caffe2.TensorBoundShapes.prototype.max_feature_len = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.TensorBoundShapes.prototype.max_batch_size = protobuf.Int64.create(0);
+$root.caffe2.TensorBoundShapes.prototype.max_feature_len = protobuf.Int64.create(0);
 
 $root.caffe2.Argument = class Argument {
 
@@ -820,7 +820,7 @@ $root.caffe2.Argument = class Argument {
 
 $root.caffe2.Argument.prototype.name = "";
 $root.caffe2.Argument.prototype.f = 0;
-$root.caffe2.Argument.prototype.i = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.Argument.prototype.i = protobuf.Int64.create(0);
 $root.caffe2.Argument.prototype.s = new Uint8Array([]);
 $root.caffe2.Argument.prototype.t = null;
 $root.caffe2.Argument.prototype.n = null;
@@ -1034,7 +1034,7 @@ $root.caffe2.OperatorDef.prototype.engine = "";
 $root.caffe2.OperatorDef.prototype.is_gradient_op = false;
 $root.caffe2.OperatorDef.prototype.debug_info = "";
 $root.caffe2.OperatorDef.prototype.domain = "";
-$root.caffe2.OperatorDef.prototype.op_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.OperatorDef.prototype.op_version = protobuf.Int64.create(0);
 
 $root.caffe2.MapFieldEntry = class MapFieldEntry {
 
@@ -1430,11 +1430,11 @@ $root.caffe2.ExecutionStep = class ExecutionStep {
 };
 
 $root.caffe2.ExecutionStep.prototype.name = "";
-$root.caffe2.ExecutionStep.prototype.num_iter = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.ExecutionStep.prototype.num_iter = protobuf.Int64.create(0);
 $root.caffe2.ExecutionStep.prototype.criteria_network = "";
 $root.caffe2.ExecutionStep.prototype.report_net = "";
 $root.caffe2.ExecutionStep.prototype.report_interval = 0;
-$root.caffe2.ExecutionStep.prototype.run_every_ms = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.caffe2.ExecutionStep.prototype.run_every_ms = protobuf.Int64.create(0);
 $root.caffe2.ExecutionStep.prototype.concurrent_substeps = false;
 $root.caffe2.ExecutionStep.prototype.should_stop_blob = "";
 $root.caffe2.ExecutionStep.prototype.only_once = false;

+ 3 - 3
src/cntk-proto.js

@@ -263,7 +263,7 @@ $root.CNTK.proto.Dictionary = class Dictionary {
                     message.version = reader.uint64();
                     break;
                 case 2:
-                    reader.pair(message.data, () => reader.string(), () => $root.CNTK.proto.DictionaryValue.decode(reader, reader.uint32()));
+                    reader.entry(message.data, () => reader.string(), () => $root.CNTK.proto.DictionaryValue.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -274,7 +274,7 @@ $root.CNTK.proto.Dictionary = class Dictionary {
     }
 };
 
-$root.CNTK.proto.Dictionary.prototype.version = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CNTK.proto.Dictionary.prototype.version = protobuf.Uint64.create(0);
 
 $root.CNTK.proto.DictionaryValue = class DictionaryValue {
 
@@ -340,7 +340,7 @@ $root.CNTK.proto.DictionaryValue = class DictionaryValue {
     }
 };
 
-$root.CNTK.proto.DictionaryValue.prototype.version = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CNTK.proto.DictionaryValue.prototype.version = protobuf.Uint64.create(0);
 $root.CNTK.proto.DictionaryValue.prototype.value_type = 0;
 
 $root.CNTK.proto.DictionaryValue.Type = {

+ 2 - 13
src/cntk.js

@@ -1,7 +1,6 @@
 /* jshint esversion: 6 */
 
 var cntk = cntk || {};
-var long = long || { Long: require('long') };
 var protobuf = protobuf || require('./protobuf');
 
 var cntk_v1 = {};
@@ -720,9 +719,7 @@ cntk.TensorType = class {
                 this._shape = new cntk.TensorShape(version, shape);
                 break;
             case 2:
-                if (long.Long.isLong(dataType)) {
-                    dataType = dataType.toNumber();
-                }
+                dataType = dataType.toNumber();
                 switch (dataType) {
                     case 1: this._dataType = 'float32'; break;
                 }
@@ -752,15 +749,7 @@ cntk.TensorShape = class {
                 this._dimensions = shape.dims;
                 break;
             case 2:
-                this._dimensions = shape.shape_dim.map((dimension) => {
-                    if (dimension.low == -1 && dimension.high == -1 && dimension.unsigned == true) {
-                        return -1;
-                    }
-                    if (dimension && long.Long.isLong(dimension)) {
-                        return dimension.toNumber();
-                    }
-                    return dimension;
-                });
+                this._dimensions = shape.shape_dim.map((dimension) => dimension.toNumber());
                 break;
         }
     }

+ 98 - 98
src/coreml-proto.js

@@ -140,7 +140,7 @@ $root.CoreML.Specification.Metadata = class Metadata {
                     message.license = reader.string();
                     break;
                 case 100:
-                    reader.pair(message.userDefined, () => reader.string(), () => reader.string());
+                    reader.entry(message.userDefined, () => reader.string(), () => reader.string());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -700,7 +700,7 @@ $root.CoreML.Specification.StringToInt64Map = class StringToInt64Map {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.map, () => reader.string(), () => reader.int64());
+                    reader.entry(message.map, () => reader.string(), () => reader.int64());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -724,7 +724,7 @@ $root.CoreML.Specification.Int64ToStringMap = class Int64ToStringMap {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.map, () => reader.int64(), () => reader.string());
+                    reader.entry(message.map, () => reader.int64(), () => reader.string());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -748,7 +748,7 @@ $root.CoreML.Specification.StringToDoubleMap = class StringToDoubleMap {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.map, () => reader.string(), () => reader.double());
+                    reader.entry(message.map, () => reader.string(), () => reader.double());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -772,7 +772,7 @@ $root.CoreML.Specification.Int64ToDoubleMap = class Int64ToDoubleMap {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.map, () => reader.int64(), () => reader.double());
+                    reader.entry(message.map, () => reader.int64(), () => reader.double());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -905,8 +905,8 @@ $root.CoreML.Specification.Int64Range = class Int64Range {
     }
 };
 
-$root.CoreML.Specification.Int64Range.prototype.minValue = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.Int64Range.prototype.maxValue = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.Int64Range.prototype.minValue = protobuf.Int64.create(0);
+$root.CoreML.Specification.Int64Range.prototype.maxValue = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.Int64Set = class Int64Set {
 
@@ -1047,8 +1047,8 @@ $root.CoreML.Specification.SizeRange = class SizeRange {
     }
 };
 
-$root.CoreML.Specification.SizeRange.prototype.lowerBound = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.SizeRange.prototype.upperBound = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.SizeRange.prototype.lowerBound = protobuf.Uint64.create(0);
+$root.CoreML.Specification.SizeRange.prototype.upperBound = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.ImageFeatureType = class ImageFeatureType {
 
@@ -1090,8 +1090,8 @@ $root.CoreML.Specification.ImageFeatureType = class ImageFeatureType {
     }
 };
 
-$root.CoreML.Specification.ImageFeatureType.prototype.width = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.ImageFeatureType.prototype.height = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ImageFeatureType.prototype.width = protobuf.Int64.create(0);
+$root.CoreML.Specification.ImageFeatureType.prototype.height = protobuf.Int64.create(0);
 $root.CoreML.Specification.ImageFeatureType.prototype.colorSpace = 0;
 
 $root.CoreML.Specification.ImageFeatureType.ColorSpace = {
@@ -1127,8 +1127,8 @@ $root.CoreML.Specification.ImageFeatureType.ImageSize = class ImageSize {
     }
 };
 
-$root.CoreML.Specification.ImageFeatureType.ImageSize.prototype.width = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.ImageFeatureType.ImageSize.prototype.height = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.ImageFeatureType.ImageSize.prototype.width = protobuf.Uint64.create(0);
+$root.CoreML.Specification.ImageFeatureType.ImageSize.prototype.height = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.ImageFeatureType.EnumeratedImageSizes = class EnumeratedImageSizes {
 
@@ -1668,7 +1668,7 @@ $root.CoreML.Specification.CustomModel = class CustomModel {
                     message.className = reader.string();
                     break;
                 case 30:
-                    reader.pair(message.parameters, () => reader.string(), () => $root.CoreML.Specification.CustomModel.CustomModelParamValue.decode(reader, reader.uint32()));
+                    reader.entry(message.parameters, () => reader.string(), () => $root.CoreML.Specification.CustomModel.CustomModelParamValue.decode(reader, reader.uint32()));
                     break;
                 case 40:
                     message.description = reader.string();
@@ -1810,7 +1810,7 @@ $root.CoreML.Specification.FeatureVectorizer.InputColumn = class InputColumn {
 };
 
 $root.CoreML.Specification.FeatureVectorizer.InputColumn.prototype.inputColumn = "";
-$root.CoreML.Specification.FeatureVectorizer.InputColumn.prototype.inputDimensions = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.FeatureVectorizer.InputColumn.prototype.inputDimensions = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.GLMRegressor = class GLMRegressor {
 
@@ -2206,7 +2206,7 @@ $root.CoreML.Specification.Int64Parameter = class Int64Parameter {
     }
 };
 
-$root.CoreML.Specification.Int64Parameter.prototype.defaultValue = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.Int64Parameter.prototype.defaultValue = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.DoubleParameter = class DoubleParameter {
 
@@ -3517,7 +3517,7 @@ $root.CoreML.Specification.LoopLayerParams = class LoopLayerParams {
     }
 };
 
-$root.CoreML.Specification.LoopLayerParams.prototype.maxLoopIterations = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.LoopLayerParams.prototype.maxLoopIterations = protobuf.Uint64.create(0);
 $root.CoreML.Specification.LoopLayerParams.prototype.conditionVar = "";
 $root.CoreML.Specification.LoopLayerParams.prototype.conditionNetwork = null;
 $root.CoreML.Specification.LoopLayerParams.prototype.bodyNetwork = null;
@@ -3862,8 +3862,8 @@ $root.CoreML.Specification.BorderAmounts.EdgeSizes = class EdgeSizes {
     }
 };
 
-$root.CoreML.Specification.BorderAmounts.EdgeSizes.prototype.startEdgeSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.BorderAmounts.EdgeSizes.prototype.endEdgeSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.BorderAmounts.EdgeSizes.prototype.startEdgeSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.BorderAmounts.EdgeSizes.prototype.endEdgeSize = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.ValidPadding = class ValidPadding {
 
@@ -4063,7 +4063,7 @@ $root.CoreML.Specification.QuantizationParams = class QuantizationParams {
     }
 };
 
-$root.CoreML.Specification.QuantizationParams.prototype.numberOfBits = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.QuantizationParams.prototype.numberOfBits = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.LinearQuantizationParams = class LinearQuantizationParams {
 
@@ -4185,9 +4185,9 @@ $root.CoreML.Specification.ConvolutionLayerParams = class ConvolutionLayerParams
     }
 };
 
-$root.CoreML.Specification.ConvolutionLayerParams.prototype.outputChannels = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.ConvolutionLayerParams.prototype.kernelChannels = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.ConvolutionLayerParams.prototype.nGroups = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.ConvolutionLayerParams.prototype.outputChannels = protobuf.Uint64.create(0);
+$root.CoreML.Specification.ConvolutionLayerParams.prototype.kernelChannels = protobuf.Uint64.create(0);
+$root.CoreML.Specification.ConvolutionLayerParams.prototype.nGroups = protobuf.Uint64.create(0);
 $root.CoreML.Specification.ConvolutionLayerParams.prototype.isDeconvolution = false;
 $root.CoreML.Specification.ConvolutionLayerParams.prototype.hasBias = false;
 $root.CoreML.Specification.ConvolutionLayerParams.prototype.weights = null;
@@ -4354,8 +4354,8 @@ $root.CoreML.Specification.InnerProductLayerParams = class InnerProductLayerPara
     }
 };
 
-$root.CoreML.Specification.InnerProductLayerParams.prototype.inputChannels = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.InnerProductLayerParams.prototype.outputChannels = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.InnerProductLayerParams.prototype.inputChannels = protobuf.Uint64.create(0);
+$root.CoreML.Specification.InnerProductLayerParams.prototype.outputChannels = protobuf.Uint64.create(0);
 $root.CoreML.Specification.InnerProductLayerParams.prototype.hasBias = false;
 $root.CoreML.Specification.InnerProductLayerParams.prototype.weights = null;
 $root.CoreML.Specification.InnerProductLayerParams.prototype.bias = null;
@@ -4396,8 +4396,8 @@ $root.CoreML.Specification.EmbeddingLayerParams = class EmbeddingLayerParams {
     }
 };
 
-$root.CoreML.Specification.EmbeddingLayerParams.prototype.inputDim = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.EmbeddingLayerParams.prototype.outputChannels = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.EmbeddingLayerParams.prototype.inputDim = protobuf.Uint64.create(0);
+$root.CoreML.Specification.EmbeddingLayerParams.prototype.outputChannels = protobuf.Uint64.create(0);
 $root.CoreML.Specification.EmbeddingLayerParams.prototype.hasBias = false;
 $root.CoreML.Specification.EmbeddingLayerParams.prototype.weights = null;
 $root.CoreML.Specification.EmbeddingLayerParams.prototype.bias = null;
@@ -4437,8 +4437,8 @@ $root.CoreML.Specification.EmbeddingNDLayerParams = class EmbeddingNDLayerParams
     }
 };
 
-$root.CoreML.Specification.EmbeddingNDLayerParams.prototype.vocabSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.EmbeddingNDLayerParams.prototype.embeddingSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.EmbeddingNDLayerParams.prototype.vocabSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.EmbeddingNDLayerParams.prototype.embeddingSize = protobuf.Uint64.create(0);
 $root.CoreML.Specification.EmbeddingNDLayerParams.prototype.hasBias = false;
 $root.CoreML.Specification.EmbeddingNDLayerParams.prototype.weights = null;
 $root.CoreML.Specification.EmbeddingNDLayerParams.prototype.bias = null;
@@ -4487,7 +4487,7 @@ $root.CoreML.Specification.BatchnormLayerParams = class BatchnormLayerParams {
     }
 };
 
-$root.CoreML.Specification.BatchnormLayerParams.prototype.channels = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.BatchnormLayerParams.prototype.channels = protobuf.Uint64.create(0);
 $root.CoreML.Specification.BatchnormLayerParams.prototype.computeMeanVar = false;
 $root.CoreML.Specification.BatchnormLayerParams.prototype.instanceNormalization = false;
 $root.CoreML.Specification.BatchnormLayerParams.prototype.epsilon = 0;
@@ -4866,7 +4866,7 @@ $root.CoreML.Specification.LRNLayerParams = class LRNLayerParams {
 
 $root.CoreML.Specification.LRNLayerParams.prototype.alpha = 0;
 $root.CoreML.Specification.LRNLayerParams.prototype.beta = 0;
-$root.CoreML.Specification.LRNLayerParams.prototype.localSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.LRNLayerParams.prototype.localSize = protobuf.Uint64.create(0);
 $root.CoreML.Specification.LRNLayerParams.prototype.k = 0;
 
 $root.CoreML.Specification.SoftmaxLayerParams = class SoftmaxLayerParams {
@@ -4912,7 +4912,7 @@ $root.CoreML.Specification.SplitLayerParams = class SplitLayerParams {
     }
 };
 
-$root.CoreML.Specification.SplitLayerParams.prototype.nOutputs = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.SplitLayerParams.prototype.nOutputs = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.AddLayerParams = class AddLayerParams {
 
@@ -5373,7 +5373,7 @@ $root.CoreML.Specification.ReorganizeDataLayerParams = class ReorganizeDataLayer
 };
 
 $root.CoreML.Specification.ReorganizeDataLayerParams.prototype.mode = 0;
-$root.CoreML.Specification.ReorganizeDataLayerParams.prototype.blockSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.ReorganizeDataLayerParams.prototype.blockSize = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.ReorganizeDataLayerParams.ReorganizationType = {
     "SPACE_TO_DEPTH": 0,
@@ -5413,9 +5413,9 @@ $root.CoreML.Specification.SliceLayerParams = class SliceLayerParams {
     }
 };
 
-$root.CoreML.Specification.SliceLayerParams.prototype.startIndex = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.SliceLayerParams.prototype.endIndex = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.SliceLayerParams.prototype.stride = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.SliceLayerParams.prototype.startIndex = protobuf.Int64.create(0);
+$root.CoreML.Specification.SliceLayerParams.prototype.endIndex = protobuf.Int64.create(0);
+$root.CoreML.Specification.SliceLayerParams.prototype.stride = protobuf.Uint64.create(0);
 $root.CoreML.Specification.SliceLayerParams.prototype.axis = 0;
 
 $root.CoreML.Specification.SliceLayerParams.SliceAxis = {
@@ -5648,7 +5648,7 @@ $root.CoreML.Specification.SequenceRepeatLayerParams = class SequenceRepeatLayer
     }
 };
 
-$root.CoreML.Specification.SequenceRepeatLayerParams.prototype.nRepetitions = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.SequenceRepeatLayerParams.prototype.nRepetitions = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.SimpleRecurrentLayerParams = class SimpleRecurrentLayerParams {
 
@@ -5697,8 +5697,8 @@ $root.CoreML.Specification.SimpleRecurrentLayerParams = class SimpleRecurrentLay
     }
 };
 
-$root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.inputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.outputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.inputVectorSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.outputVectorSize = protobuf.Uint64.create(0);
 $root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.activation = null;
 $root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.sequenceOutput = false;
 $root.CoreML.Specification.SimpleRecurrentLayerParams.prototype.hasBiasVector = false;
@@ -5773,8 +5773,8 @@ $root.CoreML.Specification.GRULayerParams = class GRULayerParams {
     }
 };
 
-$root.CoreML.Specification.GRULayerParams.prototype.inputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.GRULayerParams.prototype.outputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.GRULayerParams.prototype.inputVectorSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.GRULayerParams.prototype.outputVectorSize = protobuf.Uint64.create(0);
 $root.CoreML.Specification.GRULayerParams.prototype.sequenceOutput = false;
 $root.CoreML.Specification.GRULayerParams.prototype.hasBiasVectors = false;
 $root.CoreML.Specification.GRULayerParams.prototype.updateGateWeightMatrix = null;
@@ -5953,8 +5953,8 @@ $root.CoreML.Specification.UniDirectionalLSTMLayerParams = class UniDirectionalL
     }
 };
 
-$root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.inputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.outputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.inputVectorSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.outputVectorSize = protobuf.Uint64.create(0);
 $root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.params = null;
 $root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.weightParams = null;
 $root.CoreML.Specification.UniDirectionalLSTMLayerParams.prototype.reverseInput = false;
@@ -6000,8 +6000,8 @@ $root.CoreML.Specification.BiDirectionalLSTMLayerParams = class BiDirectionalLST
     }
 };
 
-$root.CoreML.Specification.BiDirectionalLSTMLayerParams.prototype.inputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.BiDirectionalLSTMLayerParams.prototype.outputVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.BiDirectionalLSTMLayerParams.prototype.inputVectorSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.BiDirectionalLSTMLayerParams.prototype.outputVectorSize = protobuf.Uint64.create(0);
 $root.CoreML.Specification.BiDirectionalLSTMLayerParams.prototype.params = null;
 
 $root.CoreML.Specification.CustomLayerParams = class CustomLayerParams {
@@ -6024,7 +6024,7 @@ $root.CoreML.Specification.CustomLayerParams = class CustomLayerParams {
                     message.weights.push($root.CoreML.Specification.WeightParams.decode(reader, reader.uint32()));
                     break;
                 case 30:
-                    reader.pair(message.parameters, () => reader.string(), () => $root.CoreML.Specification.CustomLayerParams.CustomLayerParamValue.decode(reader, reader.uint32()));
+                    reader.entry(message.parameters, () => reader.string(), () => $root.CoreML.Specification.CustomLayerParams.CustomLayerParamValue.decode(reader, reader.uint32()));
                     break;
                 case 40:
                     message.description = reader.string();
@@ -6151,8 +6151,8 @@ $root.CoreML.Specification.BatchedMatMulLayerParams = class BatchedMatMulLayerPa
 
 $root.CoreML.Specification.BatchedMatMulLayerParams.prototype.transposeA = false;
 $root.CoreML.Specification.BatchedMatMulLayerParams.prototype.transposeB = false;
-$root.CoreML.Specification.BatchedMatMulLayerParams.prototype.weightMatrixFirstDimension = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.BatchedMatMulLayerParams.prototype.weightMatrixSecondDimension = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.BatchedMatMulLayerParams.prototype.weightMatrixFirstDimension = protobuf.Uint64.create(0);
+$root.CoreML.Specification.BatchedMatMulLayerParams.prototype.weightMatrixSecondDimension = protobuf.Uint64.create(0);
 $root.CoreML.Specification.BatchedMatMulLayerParams.prototype.hasBias = false;
 $root.CoreML.Specification.BatchedMatMulLayerParams.prototype.weights = null;
 $root.CoreML.Specification.BatchedMatMulLayerParams.prototype.bias = null;
@@ -6181,7 +6181,7 @@ $root.CoreML.Specification.ConcatNDLayerParams = class ConcatNDLayerParams {
     }
 };
 
-$root.CoreML.Specification.ConcatNDLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ConcatNDLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.SoftmaxNDLayerParams = class SoftmaxNDLayerParams {
 
@@ -6206,7 +6206,7 @@ $root.CoreML.Specification.SoftmaxNDLayerParams = class SoftmaxNDLayerParams {
     }
 };
 
-$root.CoreML.Specification.SoftmaxNDLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.SoftmaxNDLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.ReverseLayerParams = class ReverseLayerParams {
 
@@ -6258,8 +6258,8 @@ $root.CoreML.Specification.ReverseSeqLayerParams = class ReverseSeqLayerParams {
     }
 };
 
-$root.CoreML.Specification.ReverseSeqLayerParams.prototype.batchAxis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.ReverseSeqLayerParams.prototype.sequenceAxis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ReverseSeqLayerParams.prototype.batchAxis = protobuf.Int64.create(0);
+$root.CoreML.Specification.ReverseSeqLayerParams.prototype.sequenceAxis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.LoadConstantNDLayerParams = class LoadConstantNDLayerParams {
 
@@ -6715,8 +6715,8 @@ $root.CoreML.Specification.MatrixBandPartLayerParams = class MatrixBandPartLayer
     }
 };
 
-$root.CoreML.Specification.MatrixBandPartLayerParams.prototype.numLower = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.MatrixBandPartLayerParams.prototype.numUpper = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.MatrixBandPartLayerParams.prototype.numLower = protobuf.Int64.create(0);
+$root.CoreML.Specification.MatrixBandPartLayerParams.prototype.numUpper = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.UpperTriangularLayerParams = class UpperTriangularLayerParams {
 
@@ -6741,7 +6741,7 @@ $root.CoreML.Specification.UpperTriangularLayerParams = class UpperTriangularLay
     }
 };
 
-$root.CoreML.Specification.UpperTriangularLayerParams.prototype.k = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.UpperTriangularLayerParams.prototype.k = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.LowerTriangularLayerParams = class LowerTriangularLayerParams {
 
@@ -6766,7 +6766,7 @@ $root.CoreML.Specification.LowerTriangularLayerParams = class LowerTriangularLay
     }
 };
 
-$root.CoreML.Specification.LowerTriangularLayerParams.prototype.k = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.LowerTriangularLayerParams.prototype.k = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.BroadcastToLikeLayerParams = class BroadcastToLikeLayerParams {
 
@@ -7015,7 +7015,7 @@ $root.CoreML.Specification.GatherLayerParams = class GatherLayerParams {
     }
 };
 
-$root.CoreML.Specification.GatherLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.GatherLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.ScatterMode = {
     "SCATTER_UPDATE": 0,
@@ -7053,7 +7053,7 @@ $root.CoreML.Specification.ScatterLayerParams = class ScatterLayerParams {
     }
 };
 
-$root.CoreML.Specification.ScatterLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ScatterLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.ScatterLayerParams.prototype.mode = 0;
 
 $root.CoreML.Specification.GatherNDLayerParams = class GatherNDLayerParams {
@@ -7124,7 +7124,7 @@ $root.CoreML.Specification.GatherAlongAxisLayerParams = class GatherAlongAxisLay
     }
 };
 
-$root.CoreML.Specification.GatherAlongAxisLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.GatherAlongAxisLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.ScatterAlongAxisLayerParams = class ScatterAlongAxisLayerParams {
 
@@ -7152,7 +7152,7 @@ $root.CoreML.Specification.ScatterAlongAxisLayerParams = class ScatterAlongAxisL
     }
 };
 
-$root.CoreML.Specification.ScatterAlongAxisLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ScatterAlongAxisLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.ScatterAlongAxisLayerParams.prototype.mode = 0;
 
 $root.CoreML.Specification.StackLayerParams = class StackLayerParams {
@@ -7178,7 +7178,7 @@ $root.CoreML.Specification.StackLayerParams = class StackLayerParams {
     }
 };
 
-$root.CoreML.Specification.StackLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.StackLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.RankPreservingReshapeLayerParams = class RankPreservingReshapeLayerParams {
 
@@ -7266,7 +7266,7 @@ $root.CoreML.Specification.RandomNormalLikeLayerParams = class RandomNormalLikeL
     }
 };
 
-$root.CoreML.Specification.RandomNormalLikeLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomNormalLikeLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomNormalLikeLayerParams.prototype.mean = 0;
 $root.CoreML.Specification.RandomNormalLikeLayerParams.prototype.stdDev = 0;
 
@@ -7303,7 +7303,7 @@ $root.CoreML.Specification.RandomNormalStaticLayerParams = class RandomNormalSta
     }
 };
 
-$root.CoreML.Specification.RandomNormalStaticLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomNormalStaticLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomNormalStaticLayerParams.prototype.mean = 0;
 $root.CoreML.Specification.RandomNormalStaticLayerParams.prototype.stdDev = 0;
 
@@ -7336,7 +7336,7 @@ $root.CoreML.Specification.RandomNormalDynamicLayerParams = class RandomNormalDy
     }
 };
 
-$root.CoreML.Specification.RandomNormalDynamicLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomNormalDynamicLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomNormalDynamicLayerParams.prototype.mean = 0;
 $root.CoreML.Specification.RandomNormalDynamicLayerParams.prototype.stdDev = 0;
 
@@ -7369,7 +7369,7 @@ $root.CoreML.Specification.RandomUniformLikeLayerParams = class RandomUniformLik
     }
 };
 
-$root.CoreML.Specification.RandomUniformLikeLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomUniformLikeLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomUniformLikeLayerParams.prototype.minVal = 0;
 $root.CoreML.Specification.RandomUniformLikeLayerParams.prototype.maxVal = 0;
 
@@ -7406,7 +7406,7 @@ $root.CoreML.Specification.RandomUniformStaticLayerParams = class RandomUniformS
     }
 };
 
-$root.CoreML.Specification.RandomUniformStaticLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomUniformStaticLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomUniformStaticLayerParams.prototype.minVal = 0;
 $root.CoreML.Specification.RandomUniformStaticLayerParams.prototype.maxVal = 0;
 
@@ -7439,7 +7439,7 @@ $root.CoreML.Specification.RandomUniformDynamicLayerParams = class RandomUniform
     }
 };
 
-$root.CoreML.Specification.RandomUniformDynamicLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomUniformDynamicLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomUniformDynamicLayerParams.prototype.minVal = 0;
 $root.CoreML.Specification.RandomUniformDynamicLayerParams.prototype.maxVal = 0;
 
@@ -7469,7 +7469,7 @@ $root.CoreML.Specification.RandomBernoulliLikeLayerParams = class RandomBernoull
     }
 };
 
-$root.CoreML.Specification.RandomBernoulliLikeLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomBernoulliLikeLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomBernoulliLikeLayerParams.prototype.prob = 0;
 
 $root.CoreML.Specification.RandomBernoulliStaticLayerParams = class RandomBernoulliStaticLayerParams {
@@ -7502,7 +7502,7 @@ $root.CoreML.Specification.RandomBernoulliStaticLayerParams = class RandomBernou
     }
 };
 
-$root.CoreML.Specification.RandomBernoulliStaticLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomBernoulliStaticLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomBernoulliStaticLayerParams.prototype.prob = 0;
 
 $root.CoreML.Specification.RandomBernoulliDynamicLayerParams = class RandomBernoulliDynamicLayerParams {
@@ -7531,7 +7531,7 @@ $root.CoreML.Specification.RandomBernoulliDynamicLayerParams = class RandomBerno
     }
 };
 
-$root.CoreML.Specification.RandomBernoulliDynamicLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.RandomBernoulliDynamicLayerParams.prototype.seed = protobuf.Int64.create(0);
 $root.CoreML.Specification.RandomBernoulliDynamicLayerParams.prototype.prob = 0;
 
 $root.CoreML.Specification.CategoricalDistributionLayerParams = class CategoricalDistributionLayerParams {
@@ -7569,8 +7569,8 @@ $root.CoreML.Specification.CategoricalDistributionLayerParams = class Categorica
     }
 };
 
-$root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.seed = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.numSamples = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.seed = protobuf.Int64.create(0);
+$root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.numSamples = protobuf.Int64.create(0);
 $root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.isLogits = false;
 $root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.eps = 0;
 $root.CoreML.Specification.CategoricalDistributionLayerParams.prototype.temperature = 0;
@@ -7952,7 +7952,7 @@ $root.CoreML.Specification.FlattenTo2DLayerParams = class FlattenTo2DLayerParams
     }
 };
 
-$root.CoreML.Specification.FlattenTo2DLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.FlattenTo2DLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.ReshapeStaticLayerParams = class ReshapeStaticLayerParams {
 
@@ -8076,8 +8076,8 @@ $root.CoreML.Specification.TopKLayerParams = class TopKLayerParams {
     }
 };
 
-$root.CoreML.Specification.TopKLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.TopKLayerParams.prototype.K = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.TopKLayerParams.prototype.axis = protobuf.Int64.create(0);
+$root.CoreML.Specification.TopKLayerParams.prototype.K = protobuf.Uint64.create(0);
 $root.CoreML.Specification.TopKLayerParams.prototype.useBottomK = false;
 
 $root.CoreML.Specification.ArgMaxLayerParams = class ArgMaxLayerParams {
@@ -8106,7 +8106,7 @@ $root.CoreML.Specification.ArgMaxLayerParams = class ArgMaxLayerParams {
     }
 };
 
-$root.CoreML.Specification.ArgMaxLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ArgMaxLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.ArgMaxLayerParams.prototype.removeDim = false;
 
 $root.CoreML.Specification.ArgMinLayerParams = class ArgMinLayerParams {
@@ -8135,7 +8135,7 @@ $root.CoreML.Specification.ArgMinLayerParams = class ArgMinLayerParams {
     }
 };
 
-$root.CoreML.Specification.ArgMinLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ArgMinLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.ArgMinLayerParams.prototype.removeDim = false;
 
 $root.CoreML.Specification.SplitNDLayerParams = class SplitNDLayerParams {
@@ -8168,8 +8168,8 @@ $root.CoreML.Specification.SplitNDLayerParams = class SplitNDLayerParams {
     }
 };
 
-$root.CoreML.Specification.SplitNDLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.SplitNDLayerParams.prototype.numSplits = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.SplitNDLayerParams.prototype.axis = protobuf.Int64.create(0);
+$root.CoreML.Specification.SplitNDLayerParams.prototype.numSplits = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.CeilLayerParams = class CeilLayerParams {
 
@@ -8550,9 +8550,9 @@ $root.CoreML.Specification.SlidingWindowsLayerParams = class SlidingWindowsLayer
     }
 };
 
-$root.CoreML.Specification.SlidingWindowsLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.SlidingWindowsLayerParams.prototype.windowSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.SlidingWindowsLayerParams.prototype.step = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.SlidingWindowsLayerParams.prototype.axis = protobuf.Int64.create(0);
+$root.CoreML.Specification.SlidingWindowsLayerParams.prototype.windowSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.SlidingWindowsLayerParams.prototype.step = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.LayerNormalizationLayerParams = class LayerNormalizationLayerParams {
 
@@ -8625,7 +8625,7 @@ $root.CoreML.Specification.NonMaximumSuppressionLayerParams = class NonMaximumSu
 
 $root.CoreML.Specification.NonMaximumSuppressionLayerParams.prototype.iouThreshold = 0;
 $root.CoreML.Specification.NonMaximumSuppressionLayerParams.prototype.scoreThreshold = 0;
-$root.CoreML.Specification.NonMaximumSuppressionLayerParams.prototype.maxBoxes = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.NonMaximumSuppressionLayerParams.prototype.maxBoxes = protobuf.Uint64.create(0);
 $root.CoreML.Specification.NonMaximumSuppressionLayerParams.prototype.perClassSuppression = false;
 
 $root.CoreML.Specification.ClampedReLULayerParams = class ClampedReLULayerParams {
@@ -8683,7 +8683,7 @@ $root.CoreML.Specification.ArgSortLayerParams = class ArgSortLayerParams {
     }
 };
 
-$root.CoreML.Specification.ArgSortLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.ArgSortLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.ArgSortLayerParams.prototype.descending = false;
 
 $root.CoreML.Specification.SliceBySizeLayerParams = class SliceBySizeLayerParams {
@@ -8712,8 +8712,8 @@ $root.CoreML.Specification.SliceBySizeLayerParams = class SliceBySizeLayerParams
     }
 };
 
-$root.CoreML.Specification.SliceBySizeLayerParams.prototype.size = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.CoreML.Specification.SliceBySizeLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.SliceBySizeLayerParams.prototype.size = protobuf.Int64.create(0);
+$root.CoreML.Specification.SliceBySizeLayerParams.prototype.axis = protobuf.Int64.create(0);
 
 $root.CoreML.Specification.NeuralNetworkClassifier = class NeuralNetworkClassifier {
 
@@ -8803,8 +8803,8 @@ $root.CoreML.Specification.OneHotLayerParams = class OneHotLayerParams {
     }
 };
 
-$root.CoreML.Specification.OneHotLayerParams.prototype.oneHotVectorSize = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.OneHotLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.OneHotLayerParams.prototype.oneHotVectorSize = protobuf.Uint64.create(0);
+$root.CoreML.Specification.OneHotLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.OneHotLayerParams.prototype.onValue = 0;
 $root.CoreML.Specification.OneHotLayerParams.prototype.offValue = 0;
 
@@ -8837,7 +8837,7 @@ $root.CoreML.Specification.CumSumLayerParams = class CumSumLayerParams {
     }
 };
 
-$root.CoreML.Specification.CumSumLayerParams.prototype.axis = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.CoreML.Specification.CumSumLayerParams.prototype.axis = protobuf.Int64.create(0);
 $root.CoreML.Specification.CumSumLayerParams.prototype.excludeFinalSum = false;
 $root.CoreML.Specification.CumSumLayerParams.prototype.reverse = false;
 
@@ -9765,7 +9765,7 @@ $root.CoreML.Specification.TreeEnsembleParameters = class TreeEnsembleParameters
     }
 };
 
-$root.CoreML.Specification.TreeEnsembleParameters.prototype.numPredictionDimensions = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.TreeEnsembleParameters.prototype.numPredictionDimensions = protobuf.Uint64.create(0);
 
 $root.CoreML.Specification.TreeEnsembleParameters.TreeNode = class TreeNode {
 
@@ -9818,13 +9818,13 @@ $root.CoreML.Specification.TreeEnsembleParameters.TreeNode = class TreeNode {
     }
 };
 
-$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.treeId = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.nodeId = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.treeId = protobuf.Uint64.create(0);
+$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.nodeId = protobuf.Uint64.create(0);
 $root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.nodeBehavior = 0;
-$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.branchFeatureIndex = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.branchFeatureIndex = protobuf.Uint64.create(0);
 $root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.branchFeatureValue = 0;
-$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.trueChildNodeId = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
-$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.falseChildNodeId = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.trueChildNodeId = protobuf.Uint64.create(0);
+$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.falseChildNodeId = protobuf.Uint64.create(0);
 $root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.missingValueTracksTrueChild = false;
 $root.CoreML.Specification.TreeEnsembleParameters.TreeNode.prototype.relativeHitRate = 0;
 
@@ -9864,7 +9864,7 @@ $root.CoreML.Specification.TreeEnsembleParameters.TreeNode.EvaluationInfo = clas
     }
 };
 
-$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.EvaluationInfo.prototype.evaluationIndex = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.TreeEnsembleParameters.TreeNode.EvaluationInfo.prototype.evaluationIndex = protobuf.Uint64.create(0);
 $root.CoreML.Specification.TreeEnsembleParameters.TreeNode.EvaluationInfo.prototype.evaluationValue = 0;
 
 $root.CoreML.Specification.TreeEnsembleClassifier = class TreeEnsembleClassifier {
@@ -10019,7 +10019,7 @@ $root.CoreML.Specification.ItemSimilarityRecommender.ConnectedItem = class Conne
     }
 };
 
-$root.CoreML.Specification.ItemSimilarityRecommender.ConnectedItem.prototype.itemId = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.ItemSimilarityRecommender.ConnectedItem.prototype.itemId = protobuf.Uint64.create(0);
 $root.CoreML.Specification.ItemSimilarityRecommender.ConnectedItem.prototype.similarityScore = 0;
 
 $root.CoreML.Specification.ItemSimilarityRecommender.SimilarItems = class SimilarItems {
@@ -10052,7 +10052,7 @@ $root.CoreML.Specification.ItemSimilarityRecommender.SimilarItems = class Simila
     }
 };
 
-$root.CoreML.Specification.ItemSimilarityRecommender.SimilarItems.prototype.itemId = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.CoreML.Specification.ItemSimilarityRecommender.SimilarItems.prototype.itemId = protobuf.Uint64.create(0);
 $root.CoreML.Specification.ItemSimilarityRecommender.SimilarItems.prototype.itemScoreAdjustment = 0;
 
 $root.CoreML.Specification.LinkedModel = class LinkedModel {

+ 2 - 8
src/coreml.js

@@ -1,7 +1,6 @@
 /* jshint esversion: 6 */
 
 var coreml = coreml || {};
-var long = long || { Long: require('long') };
 var protobuf = protobuf || require('./protobuf');
 
 coreml.ModelFactory = class {
@@ -825,12 +824,7 @@ coreml.Attribute = class {
             }
             else if (Object.prototype.hasOwnProperty.call(schema, 'default')) {
                 if (Array.isArray(value)) {
-                    value = value.map((item) => {
-                        if (item && long.Long.isLong(item)) {
-                            return item.toNumber();
-                        }
-                        return item;
-                    });
+                    value = value.map((item) => item.toNumber());
                 }
                 if (JSON.stringify(schema.default) == JSON.stringify(value)) {
                     this._visible = false;
@@ -960,7 +954,7 @@ coreml.Tensor = class {
             default:
                 if (this._quantization) {
                     context.dataType = 'quantization';
-                    context.bits = long.Long.isLong(this._quantization.numberOfBits) ? this._quantization.numberOfBits.toNumber() : this._quantization.numberOfBits;
+                    context.bits = this._quantization.numberOfBits.toNumber();
                     context.data = new DataView(this._data.buffer, this._data.byteOffset, this._data.byteLength);
                 }
                 else {

+ 0 - 1
src/index.html

@@ -290,7 +290,6 @@ body { overflow: hidden; margin: 0; width: 100vw; height: 100vh; font-family: -a
 <script type="text/javascript" src="dagre.min.js"></script>
 <script type="text/javascript" src="marked.min.js"></script>
 <script type="text/javascript" src="pako.min.js"></script>
-<script type="text/javascript" src="long.js"></script>
 <script type="text/javascript" src="base.js"></script>
 <script type="text/javascript" src="protobuf.js"></script>
 <script type="text/javascript" src="flatbuffers.js"></script>

+ 0 - 1
src/mxnet.js

@@ -1,7 +1,6 @@
 /* jshint esversion: 6 */
 
 var mxnet = mxnet || {};
-var long = long || { Long: require('long') };
 var zip = zip || require('./zip');
 var ndarray = ndarray || {};
 

+ 0 - 1
src/npz.js

@@ -3,7 +3,6 @@
 // Experimental
 
 var npz = npz || {};
-var long = long || { Long: require('long') };
 
 npz.ModelFactory = class {
 

+ 10 - 10
src/onnx-proto.js

@@ -154,7 +154,7 @@ $root.onnx.AttributeProto.prototype.ref_attr_name = "";
 $root.onnx.AttributeProto.prototype.doc_string = "";
 $root.onnx.AttributeProto.prototype.type = 0;
 $root.onnx.AttributeProto.prototype.f = 0;
-$root.onnx.AttributeProto.prototype.i = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.AttributeProto.prototype.i = protobuf.Int64.create(0);
 $root.onnx.AttributeProto.prototype.s = new Uint8Array([]);
 $root.onnx.AttributeProto.prototype.t = null;
 $root.onnx.AttributeProto.prototype.g = null;
@@ -476,11 +476,11 @@ $root.onnx.ModelProto = class ModelProto {
     }
 };
 
-$root.onnx.ModelProto.prototype.ir_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.ModelProto.prototype.ir_version = protobuf.Int64.create(0);
 $root.onnx.ModelProto.prototype.producer_name = "";
 $root.onnx.ModelProto.prototype.producer_version = "";
 $root.onnx.ModelProto.prototype.domain = "";
-$root.onnx.ModelProto.prototype.model_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.ModelProto.prototype.model_version = protobuf.Int64.create(0);
 $root.onnx.ModelProto.prototype.doc_string = "";
 $root.onnx.ModelProto.prototype.graph = null;
 
@@ -879,8 +879,8 @@ $root.onnx.TensorProto.Segment = class Segment {
     }
 };
 
-$root.onnx.TensorProto.Segment.prototype.begin = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.onnx.TensorProto.Segment.prototype.end = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.TensorProto.Segment.prototype.begin = protobuf.Int64.create(0);
+$root.onnx.TensorProto.Segment.prototype.end = protobuf.Int64.create(0);
 
 $root.onnx.TensorProto.DataLocation = {
     "DEFAULT": 0,
@@ -1405,7 +1405,7 @@ $root.onnx.OperatorSetIdProto = class OperatorSetIdProto {
 };
 
 $root.onnx.OperatorSetIdProto.prototype.domain = "";
-$root.onnx.OperatorSetIdProto.prototype.version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.OperatorSetIdProto.prototype.version = protobuf.Int64.create(0);
 
 $root.onnx.OperatorStatus = {
     "EXPERIMENTAL": 0,
@@ -1506,7 +1506,7 @@ $root.onnx.FunctionProto = class FunctionProto {
 };
 
 $root.onnx.FunctionProto.prototype.name = "";
-$root.onnx.FunctionProto.prototype.since_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.FunctionProto.prototype.since_version = protobuf.Int64.create(0);
 $root.onnx.FunctionProto.prototype.status = 0;
 $root.onnx.FunctionProto.prototype.doc_string = "";
 
@@ -1569,7 +1569,7 @@ $root.onnx.OperatorProto = class OperatorProto {
 };
 
 $root.onnx.OperatorProto.prototype.op_type = "";
-$root.onnx.OperatorProto.prototype.since_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.OperatorProto.prototype.since_version = protobuf.Int64.create(0);
 $root.onnx.OperatorProto.prototype.status = 0;
 $root.onnx.OperatorProto.prototype.doc_string = "";
 
@@ -1664,9 +1664,9 @@ $root.onnx.OperatorSetProto = class OperatorSetProto {
 };
 
 $root.onnx.OperatorSetProto.prototype.magic = "";
-$root.onnx.OperatorSetProto.prototype.ir_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.OperatorSetProto.prototype.ir_version = protobuf.Int64.create(0);
 $root.onnx.OperatorSetProto.prototype.ir_version_prerelease = "";
 $root.onnx.OperatorSetProto.prototype.ir_build_metadata = "";
 $root.onnx.OperatorSetProto.prototype.domain = "";
-$root.onnx.OperatorSetProto.prototype.opset_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.onnx.OperatorSetProto.prototype.opset_version = protobuf.Int64.create(0);
 $root.onnx.OperatorSetProto.prototype.doc_string = "";

+ 2 - 2
src/paddle-proto.js

@@ -29,7 +29,7 @@ $root.paddle.framework.proto.Version = class Version {
     }
 };
 
-$root.paddle.framework.proto.Version.prototype.version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.paddle.framework.proto.Version.prototype.version = protobuf.Int64.create(0);
 
 $root.paddle.framework.proto.AttrType = {
     "INT": 0,
@@ -171,7 +171,7 @@ $root.paddle.framework.proto.OpDesc.Attr.prototype.f = 0;
 $root.paddle.framework.proto.OpDesc.Attr.prototype.s = "";
 $root.paddle.framework.proto.OpDesc.Attr.prototype.b = false;
 $root.paddle.framework.proto.OpDesc.Attr.prototype.block_idx = 0;
-$root.paddle.framework.proto.OpDesc.Attr.prototype.l = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.paddle.framework.proto.OpDesc.Attr.prototype.l = protobuf.Int64.create(0);
 
 $root.paddle.framework.proto.OpDesc.Var = class Var {
 

+ 49 - 101
src/protobuf.js

@@ -2,7 +2,7 @@
 /* jshint esversion: 6 */
 
 var protobuf = protobuf || {};
-var long = long || { Long: require('long') };
+var base = base || require('./base');
 
 protobuf.get = (name) => {
     protobuf._map = protobuf._map || new Map();
@@ -18,7 +18,7 @@ protobuf.Reader = class {
         this._buffer = buffer;
         this._length = buffer.length;
         this._position = 0;
-        this._dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
+        this._view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
         this._decoder = new TextDecoder('utf-8');
     }
 
@@ -88,35 +88,39 @@ protobuf.Reader = class {
     }
 
     int64() {
-        return this._readLongVarint().toLong(false);
+        return this._varint().toInt64();
     }
 
     uint64() {
-        return this._readLongVarint().toLong(true);
+        return this._varint().toInt64();
     }
 
     sint64() {
-        return this._readLongVarint().zzDecode().toLong(false);
+        return this._varint().zzDecode().toInt64();
     }
 
     fixed64() {
-        return this._readFixed64().toLong(true);
+        const position = this._position;
+        this.skip(8);
+        return this._view.getUint64(position, true);
     }
 
     sfixed64() {
-        return this._readFixed64().toLong(false);
+        const position = this._position;
+        this.skip(8);
+        return this._view.getInt64(position, true);
     }
 
     fixed32() {
-        if (this._position + 4 > this._length) {
-            throw this._indexOutOfRangeError(4);
-        }
-        this._position += 4;
-        return this._readFixed32();
+        const position = this._position;
+        this.skip(4);
+        return this._view.getUint32(position, true);
     }
 
     sfixed32() {
-        return this.fixed32() | 0;
+        const position = this._position;
+        this.skip(4);
+        return this._view.getInt32(position, true);
     }
 
     float() {
@@ -125,7 +129,7 @@ protobuf.Reader = class {
         }
         const position = this._position;
         this._position += 4;
-        return this._dataView.getFloat32(position, true);
+        return this._view.getFloat32(position, true);
     }
 
     double() {
@@ -134,7 +138,7 @@ protobuf.Reader = class {
         }
         const position = this._position;
         this._position += 8;
-        return this._dataView.getFloat64(position, true);
+        return this._view.getFloat64(position, true);
     }
 
     array(obj, item, tag) {
@@ -161,7 +165,7 @@ protobuf.Reader = class {
             obj = size > 1048576 ? new Float32Array(length) : new Array(length);
             let position = this._position;
             for (let i = 0; i < length; i++) {
-                obj[i] = this._dataView.getFloat32(position, true);
+                obj[i] = this._view.getFloat32(position, true);
                 position += 4;
             }
             this._position = end;
@@ -189,7 +193,7 @@ protobuf.Reader = class {
             obj = size > 1048576 ? new Float64Array(length) : new Array(length);
             let position = this._position;
             for (let i = 0; i < length; i++) {
-                obj[i] = this._dataView.getFloat64(position, true);
+                obj[i] = this._view.getFloat64(position, true);
                 position += 8;
             }
             this._position = end;
@@ -206,28 +210,26 @@ protobuf.Reader = class {
         return obj;
     }
 
-    skip(length) {
-        if (typeof length === 'number') {
-            if (this._position + length > this._length) {
-                throw this._indexOutOfRangeError(length);
-            }
-            this._position += length;
+    skip(offset) {
+        this._position += offset;
+        if (this._position > this._length) {
+            throw this._indexOutOfRangeError(length);
         }
-        else {
-            do {
-                if (this._position >= this._length) {
-                    throw this._indexOutOfRangeError();
-                }
+    }
+
+    skipVarint() {
+        do {
+            if (this._position >= this._length) {
+                throw this._indexOutOfRangeError();
             }
-            while (this._buffer[this._position++] & 128);
         }
-        return this;
+        while (this._buffer[this._position++] & 128);
     }
 
     skipType(wireType) {
         switch (wireType) {
             case 0:
-                this.skip();
+                this.skipVarint();
                 break;
             case 1:
                 this.skip(8);
@@ -248,31 +250,19 @@ protobuf.Reader = class {
         }
     }
 
-    pair(obj, key, value) {
-        this.skip();
+    entry(obj, key, value) {
+        this.skipVarint();
         this._position++;
-        const k = typeof key === 'object' ? protobuf.LongBits.hash(key()) : key();
+        let k = key();
+        if (!Number.isInteger(k) && typeof k !== 'string') {
+            k = k.toNumber();
+        }
         this._position++;
         const v = value();
         obj[k] = v;
     }
 
-    _readFixed32() {
-        return (this._buffer[this._position - 4] | this._buffer[this._position - 3] << 8 | this._buffer[this._position - 2] << 16 | this._buffer[this._position - 1] << 24) >>> 0;
-    }
-
-    _readFixed64() {
-        if (this._position + 8 > this._length) {
-            throw this._indexOutOfRangeError(8);
-        }
-        this._position += 4;
-        const lo = this._readFixed32();
-        this._position += 4;
-        const hi = this._readFixed32();
-        return new protobuf.LongBits(lo, hi);
-    }
-
-    _readLongVarint() {
+    _varint() {
         const bits = new protobuf.LongBits(0, 0);
         let i = 0;
         if (this._length - this._position > 4) { // fast route (lo)
@@ -537,7 +527,7 @@ protobuf.TextReader = class {
         return false;
     }
 
-    pair(obj, key, value) {
+    entry(obj, key, value) {
         this.start();
         let k;
         let v;
@@ -801,7 +791,8 @@ protobuf.TextReader = class {
     }
 };
 
-protobuf.Long = long.Long;
+protobuf.Int64 = base.Int64;
+protobuf.Uint64 = base.Uint64;
 
 protobuf.LongBits = class {
 
@@ -810,37 +801,6 @@ protobuf.LongBits = class {
         this.hi = hi >>> 0;
     }
 
-    toLong(unsigned) {
-        return protobuf.Long
-            ? new protobuf.Long(this.lo | 0, this.hi | 0, unsigned)
-            : { low: this.lo | 0, high: this.hi | 0, unsigned: unsigned };
-    }
-
-    toNumber(unsigned) {
-        if (!unsigned && this.hi >>> 31) {
-            const lo = ~this.lo + 1 >>> 0;
-            let hi = ~this.hi     >>> 0;
-            if (!lo) {
-                hi = hi + 1 >>> 0;
-            }
-            return -(lo + hi * 4294967296);
-        }
-        return this.lo + this.hi * 4294967296;
-    }
-
-    toHash() {
-        return String.fromCharCode(
-            this.lo        & 255,
-            this.lo >>> 8  & 255,
-            this.lo >>> 16 & 255,
-            this.lo >>> 24      ,
-            this.hi        & 255,
-            this.hi >>> 8  & 255,
-            this.hi >>> 16 & 255,
-            this.hi >>> 24
-        );
-    }
-
     zzDecode() {
         const mask = -(this.lo & 1);
         this.lo  = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
@@ -848,28 +808,15 @@ protobuf.LongBits = class {
         return this;
     }
 
-    from(value) {
-        if (typeof value === 'number') {
-            return protobuf.LongBits.fromNumber(value);
-        }
-        if (typeof value === 'string' || value instanceof String) {
-            if (!protobuf.Long) {
-                return protobuf.LongBits.fromNumber(parseInt(value, 10));
-            }
-            value = protobuf.Long.fromString(value);
-        }
-        return value.low || value.high ? new protobuf.LongBits(value.low >>> 0, value.high >>> 0) : protobuf.LongBits.zero;
+    toUint64() {
+        return new base.Uint64(this.lo, this.hi);
     }
 
-    hash(value) {
-        return value ? protobuf.LongBits.from(value).toHash() : '\0\0\0\0\0\0\0\0';
+    toInt64() {
+        return new base.Int64(this.lo, this.hi);
     }
 };
 
-protobuf.LongBits.zero = new protobuf.LongBits(0, 0);
-protobuf.LongBits.zero.toNumber = function() { return 0; };
-protobuf.LongBits.zero.zzDecode = function() { return this; };
-
 protobuf.Error = class extends Error {
 
     constructor(message) {
@@ -883,6 +830,7 @@ if (typeof module !== 'undefined' && typeof module.exports === 'object') {
     module.exports.Reader = protobuf.Reader;
     module.exports.TextReader = protobuf.TextReader;
     module.exports.Error = protobuf.Error;
-    module.exports.Long = protobuf.Long;
+    module.exports.Int64 = protobuf.Int64;
+    module.exports.Uint64 = protobuf.Uint64;
     module.exports.get = protobuf.get;
 }

+ 18 - 8
src/pytorch.js

@@ -3,7 +3,7 @@
 // Experimental
 
 var pytorch = pytorch || {};
-var long = long || { Long: require('long') };
+var base = base || require('./base');
 
 pytorch.ModelFactory = class {
 
@@ -829,7 +829,7 @@ pytorch.Tensor = class {
             result.push(indentation + ']');
             return result.join('\n');
         }
-        if (value && long.Long.isLong(value)) {
+        if (value && (value instanceof base.Int64 || value instanceof base.Uint64)) {
             return indentation + value.toString();
         }
         if (typeof value == 'string') {
@@ -2322,7 +2322,7 @@ pytorch.Container.Tar = class {
                 const storage_args = unpickler.load();
                 const storage_key = storage_args[0];
                 const storage_type = storage_args[2];
-                const size = long.Long.fromBytesLE(unpickler.read(8), false).toNumber();
+                const size = pytorch.Utility.readInt64(unpickler.read(8));
                 const storage = execution.invoke(storage_type, [ size ]);
                 storage.data = unpickler.read(storage.dataTypeSize * storage.size);
                 deserialized_objects[storage_key] = storage;
@@ -2343,17 +2343,17 @@ pytorch.Container.Tar = class {
                 const tensor_key = tensor_args[0];
                 const storage_id = tensor_args[1];
                 const storage = deserialized_objects[storage_id];
-                const ndim = long.Long.fromBytesLE(unpickler.read(4), false).toNumber();
+                const ndim = pytorch.Utility.readInt32(unpickler.read(4));
                 unpickler.read(4);
                 const shape = [];
                 for (let k = 0; k < ndim; k++) {
-                    shape.push(long.Long.fromBytesLE(unpickler.read(8), false).toNumber());
+                    shape.push(pytorch.Utility.readInt64(unpickler.read(8)));
                 }
                 const stride = [];
                 for (let l = 0; l < ndim; l++) {
-                    stride.push(long.Long.fromBytesLE(unpickler.read(8), false).toNumber());
+                    stride.push(pytorch.Utility.readInt64(unpickler.read(8)));
                 }
-                const storage_offset = long.Long.fromBytesLE(unpickler.read(8), false).toNumber();
+                const storage_offset = pytorch.Utility.readInt64(unpickler.read(8));
                 const tensor_type_name = storage.__name__.replace('Storage', 'Tensor');
                 const tensor = execution.invoke(storage.__module__ + '.' + tensor_type_name, []);
                 tensor.__setstate__([ storage, storage_offset, shape, stride ]);
@@ -2523,7 +2523,7 @@ pytorch.Container.Pickle = class {
         const deserialized_storage_keys = unpickler.load();
         for (const deserialized_storage_key of deserialized_storage_keys) {
             const storage = deserialized_objects.get(deserialized_storage_key);
-            const size = long.Long.fromBytesLE(unpickler.read(8), false).toNumber();
+            const size = pytorch.Utility.readInt64(unpickler.read(8));
             if (size != storage.size) {
                 throw new pytorch.Error('Storage size mismatch.');
             }
@@ -3406,6 +3406,16 @@ pytorch.Utility = class {
         }
         return null;
     }
+
+    static readInt32(buffer) {
+        const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
+        return view.getInt32(0, true);
+    }
+
+    static readInt64(buffer) {
+        const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
+        return view.getInt64(0, true).toNumber();
+    }
 };
 
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {

+ 0 - 1
src/sklearn.js

@@ -3,7 +3,6 @@
 // Experimental
 
 var sklearn = sklearn || {};
-var long = long || { Long: require('long') };
 var zip = zip || require('./zip');
 
 sklearn.ModelFactory = class {

+ 40 - 40
src/tf-proto.js

@@ -49,7 +49,7 @@ $root.tensorflow.SavedModel = class SavedModel {
     }
 };
 
-$root.tensorflow.SavedModel.prototype.saved_model_schema_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.tensorflow.SavedModel.prototype.saved_model_schema_version = protobuf.Int64.create(0);
 
 $root.tensorflow.MetaGraphDef = class MetaGraphDef {
 
@@ -75,10 +75,10 @@ $root.tensorflow.MetaGraphDef = class MetaGraphDef {
                     message.saver_def = $root.tensorflow.SaverDef.decode(reader, reader.uint32());
                     break;
                 case 4:
-                    reader.pair(message.collection_def, () => reader.string(), () => $root.tensorflow.CollectionDef.decode(reader, reader.uint32()));
+                    reader.entry(message.collection_def, () => reader.string(), () => $root.tensorflow.CollectionDef.decode(reader, reader.uint32()));
                     break;
                 case 5:
-                    reader.pair(message.signature_def, () => reader.string(), () => $root.tensorflow.SignatureDef.decode(reader, reader.uint32()));
+                    reader.entry(message.signature_def, () => reader.string(), () => $root.tensorflow.SignatureDef.decode(reader, reader.uint32()));
                     break;
                 case 6:
                     message.asset_file_def.push($root.tensorflow.AssetFileDef.decode(reader, reader.uint32()));
@@ -110,10 +110,10 @@ $root.tensorflow.MetaGraphDef = class MetaGraphDef {
                     message.saver_def = $root.tensorflow.SaverDef.decodeText(reader, true);
                     break;
                 case "collection_def":
-                    reader.pair(message.collection_def, () => reader.string(), () => $root.tensorflow.CollectionDef.decodeText(reader, true));
+                    reader.entry(message.collection_def, () => reader.string(), () => $root.tensorflow.CollectionDef.decodeText(reader, true));
                     break;
                 case "signature_def":
-                    reader.pair(message.signature_def, () => reader.string(), () => $root.tensorflow.SignatureDef.decodeText(reader, true));
+                    reader.entry(message.signature_def, () => reader.string(), () => $root.tensorflow.SignatureDef.decodeText(reader, true));
                     break;
                 case "asset_file_def":
                     message.asset_file_def.push($root.tensorflow.AssetFileDef.decodeText(reader, true));
@@ -170,7 +170,7 @@ $root.tensorflow.MetaGraphDef.MetaInfoDef = class MetaInfoDef {
                     message.stripped_default_attrs = reader.bool();
                     break;
                 case 8:
-                    reader.pair(message.function_aliases, () => reader.string(), () => reader.string());
+                    reader.entry(message.function_aliases, () => reader.string(), () => reader.string());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -208,7 +208,7 @@ $root.tensorflow.MetaGraphDef.MetaInfoDef = class MetaInfoDef {
                     message.stripped_default_attrs = reader.boolean();
                     break;
                 case "function_aliases":
-                    reader.pair(message.function_aliases, () => reader.string(), () => reader.string());
+                    reader.entry(message.function_aliases, () => reader.string(), () => reader.string());
                     break;
                 default:
                     reader.field(tag, message);
@@ -691,10 +691,10 @@ $root.tensorflow.SignatureDef = class SignatureDef {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.inputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decode(reader, reader.uint32()));
+                    reader.entry(message.inputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decode(reader, reader.uint32()));
                     break;
                 case 2:
-                    reader.pair(message.outputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decode(reader, reader.uint32()));
+                    reader.entry(message.outputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decode(reader, reader.uint32()));
                     break;
                 case 3:
                     message.method_name = reader.string();
@@ -714,10 +714,10 @@ $root.tensorflow.SignatureDef = class SignatureDef {
             const tag = reader.tag();
             switch (tag) {
                 case "inputs":
-                    reader.pair(message.inputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decodeText(reader, true));
+                    reader.entry(message.inputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decodeText(reader, true));
                     break;
                 case "outputs":
-                    reader.pair(message.outputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decodeText(reader, true));
+                    reader.entry(message.outputs, () => reader.string(), () => $root.tensorflow.TensorInfo.decodeText(reader, true));
                     break;
                 case "method_name":
                     message.method_name = reader.string();
@@ -914,22 +914,22 @@ $root.tensorflow.FunctionDef = class FunctionDef {
                     message.signature = $root.tensorflow.OpDef.decode(reader, reader.uint32());
                     break;
                 case 5:
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
                     break;
                 case 7:
-                    reader.pair(message.arg_attr, () => reader.uint32(), () => $root.tensorflow.FunctionDef.ArgAttrs.decode(reader, reader.uint32()));
+                    reader.entry(message.arg_attr, () => reader.uint32(), () => $root.tensorflow.FunctionDef.ArgAttrs.decode(reader, reader.uint32()));
                     break;
                 case 8:
-                    reader.pair(message.resource_arg_unique_id, () => reader.uint32(), () => reader.uint32());
+                    reader.entry(message.resource_arg_unique_id, () => reader.uint32(), () => reader.uint32());
                     break;
                 case 3:
                     message.node_def.push($root.tensorflow.NodeDef.decode(reader, reader.uint32()));
                     break;
                 case 4:
-                    reader.pair(message.ret, () => reader.string(), () => reader.string());
+                    reader.entry(message.ret, () => reader.string(), () => reader.string());
                     break;
                 case 6:
-                    reader.pair(message.control_ret, () => reader.string(), () => reader.string());
+                    reader.entry(message.control_ret, () => reader.string(), () => reader.string());
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -949,22 +949,22 @@ $root.tensorflow.FunctionDef = class FunctionDef {
                     message.signature = $root.tensorflow.OpDef.decodeText(reader, true);
                     break;
                 case "attr":
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
                     break;
                 case "arg_attr":
-                    reader.pair(message.arg_attr, () => reader.integer(), () => $root.tensorflow.FunctionDef.ArgAttrs.decodeText(reader, true));
+                    reader.entry(message.arg_attr, () => reader.integer(), () => $root.tensorflow.FunctionDef.ArgAttrs.decodeText(reader, true));
                     break;
                 case "resource_arg_unique_id":
-                    reader.pair(message.resource_arg_unique_id, () => reader.integer(), () => reader.uint32());
+                    reader.entry(message.resource_arg_unique_id, () => reader.integer(), () => reader.uint32());
                     break;
                 case "node_def":
                     message.node_def.push($root.tensorflow.NodeDef.decodeText(reader, true));
                     break;
                 case "ret":
-                    reader.pair(message.ret, () => reader.string(), () => reader.string());
+                    reader.entry(message.ret, () => reader.string(), () => reader.string());
                     break;
                 case "control_ret":
-                    reader.pair(message.control_ret, () => reader.string(), () => reader.string());
+                    reader.entry(message.control_ret, () => reader.string(), () => reader.string());
                     break;
                 default:
                     reader.field(tag, message);
@@ -990,7 +990,7 @@ $root.tensorflow.FunctionDef.ArgAttrs = class ArgAttrs {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -1007,7 +1007,7 @@ $root.tensorflow.FunctionDef.ArgAttrs = class ArgAttrs {
             const tag = reader.tag();
             switch (tag) {
                 case "attr":
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
                     break;
                 default:
                     reader.field(tag, message);
@@ -1272,7 +1272,7 @@ $root.tensorflow.NameAttrList = class NameAttrList {
                     message.name = reader.string();
                     break;
                 case 2:
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -1292,7 +1292,7 @@ $root.tensorflow.NameAttrList = class NameAttrList {
                     message.name = reader.string();
                     break;
                 case "attr":
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
                     break;
                 default:
                     reader.field(tag, message);
@@ -1589,7 +1589,7 @@ $root.tensorflow.ResourceHandleProto = class ResourceHandleProto {
 $root.tensorflow.ResourceHandleProto.prototype.device = "";
 $root.tensorflow.ResourceHandleProto.prototype.container = "";
 $root.tensorflow.ResourceHandleProto.prototype.name = "";
-$root.tensorflow.ResourceHandleProto.prototype.hash_code = protobuf.Long ? protobuf.Long.fromBits(0, 0, true) : 0;
+$root.tensorflow.ResourceHandleProto.prototype.hash_code = protobuf.Uint64.create(0);
 $root.tensorflow.ResourceHandleProto.prototype.maybe_type_name = "";
 
 $root.tensorflow.ResourceHandleProto.DtypeAndShape = class DtypeAndShape {
@@ -1736,7 +1736,7 @@ $root.tensorflow.TensorShapeProto.Dim = class Dim {
     }
 };
 
-$root.tensorflow.TensorShapeProto.Dim.prototype.size = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.tensorflow.TensorShapeProto.Dim.prototype.size = protobuf.Int64.create(0);
 $root.tensorflow.TensorShapeProto.Dim.prototype.name = "";
 
 $root.tensorflow.DataType = {
@@ -1815,7 +1815,7 @@ $root.tensorflow.NodeDef = class NodeDef {
                     message.device = reader.string();
                     break;
                 case 5:
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decode(reader, reader.uint32()));
                     break;
                 case 6:
                     message.experimental_debug_info = $root.tensorflow.NodeDef.ExperimentalDebugInfo.decode(reader, reader.uint32());
@@ -1847,7 +1847,7 @@ $root.tensorflow.NodeDef = class NodeDef {
                     message.device = reader.string();
                     break;
                 case "attr":
-                    reader.pair(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
+                    reader.entry(message.attr, () => reader.string(), () => $root.tensorflow.AttrValue.decodeText(reader, true));
                     break;
                 case "experimental_debug_info":
                     message.experimental_debug_info = $root.tensorflow.NodeDef.ExperimentalDebugInfo.decodeText(reader, true);
@@ -2198,7 +2198,7 @@ $root.tensorflow.OpDef.AttrDef.prototype.type = "";
 $root.tensorflow.OpDef.AttrDef.prototype.default_value = null;
 $root.tensorflow.OpDef.AttrDef.prototype.description = "";
 $root.tensorflow.OpDef.AttrDef.prototype.has_minimum = false;
-$root.tensorflow.OpDef.AttrDef.prototype.minimum = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.tensorflow.OpDef.AttrDef.prototype.minimum = protobuf.Int64.create(0);
 $root.tensorflow.OpDef.AttrDef.prototype.allowed_values = null;
 
 $root.tensorflow.OpDeprecation = class OpDeprecation {
@@ -2364,7 +2364,7 @@ $root.tensorflow.SavedObjectGraph = class SavedObjectGraph {
                     message.nodes.push($root.tensorflow.SavedObject.decode(reader, reader.uint32()));
                     break;
                 case 2:
-                    reader.pair(message.concrete_functions, () => reader.string(), () => $root.tensorflow.SavedConcreteFunction.decode(reader, reader.uint32()));
+                    reader.entry(message.concrete_functions, () => reader.string(), () => $root.tensorflow.SavedConcreteFunction.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -2384,7 +2384,7 @@ $root.tensorflow.SavedObjectGraph = class SavedObjectGraph {
                     message.nodes.push($root.tensorflow.SavedObject.decodeText(reader, true));
                     break;
                 case "concrete_functions":
-                    reader.pair(message.concrete_functions, () => reader.string(), () => $root.tensorflow.SavedConcreteFunction.decodeText(reader, true));
+                    reader.entry(message.concrete_functions, () => reader.string(), () => $root.tensorflow.SavedConcreteFunction.decodeText(reader, true));
                     break;
                 default:
                     reader.field(tag, message);
@@ -2442,7 +2442,7 @@ $root.tensorflow.SavedObject = class SavedObject {
                     message.resource = $root.tensorflow.SavedResource.decode(reader, reader.uint32());
                     break;
                 case 11:
-                    reader.pair(message.saveable_objects, () => reader.string(), () => $root.tensorflow.SaveableObject.decode(reader, reader.uint32()));
+                    reader.entry(message.saveable_objects, () => reader.string(), () => $root.tensorflow.SaveableObject.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -2486,7 +2486,7 @@ $root.tensorflow.SavedObject = class SavedObject {
                     message.resource = $root.tensorflow.SavedResource.decodeText(reader, true);
                     break;
                 case "saveable_objects":
-                    reader.pair(message.saveable_objects, () => reader.string(), () => $root.tensorflow.SaveableObject.decodeText(reader, true));
+                    reader.entry(message.saveable_objects, () => reader.string(), () => $root.tensorflow.SaveableObject.decodeText(reader, true));
                     break;
                 default:
                     reader.field(tag, message);
@@ -2754,7 +2754,7 @@ $root.tensorflow.SavedBareConcreteFunction = class SavedBareConcreteFunction {
 };
 
 $root.tensorflow.SavedBareConcreteFunction.prototype.concrete_function_name = "";
-$root.tensorflow.SavedBareConcreteFunction.prototype.allowed_positional_arguments = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.tensorflow.SavedBareConcreteFunction.prototype.allowed_positional_arguments = protobuf.Int64.create(0);
 
 $root.tensorflow.SavedConstant = class SavedConstant {
 
@@ -3449,7 +3449,7 @@ $root.tensorflow.DictValue = class DictValue {
             const tag = reader.uint32();
             switch (tag >>> 3) {
                 case 1:
-                    reader.pair(message.fields, () => reader.string(), () => $root.tensorflow.StructuredValue.decode(reader, reader.uint32()));
+                    reader.entry(message.fields, () => reader.string(), () => $root.tensorflow.StructuredValue.decode(reader, reader.uint32()));
                     break;
                 default:
                     reader.skipType(tag & 7);
@@ -3466,7 +3466,7 @@ $root.tensorflow.DictValue = class DictValue {
             const tag = reader.tag();
             switch (tag) {
                 case "fields":
-                    reader.pair(message.fields, () => reader.string(), () => $root.tensorflow.StructuredValue.decodeText(reader, true));
+                    reader.entry(message.fields, () => reader.string(), () => $root.tensorflow.StructuredValue.decodeText(reader, true));
                     break;
                 default:
                     reader.field(tag, message);
@@ -4266,8 +4266,8 @@ $root.tensorflow.BundleEntryProto = class BundleEntryProto {
 $root.tensorflow.BundleEntryProto.prototype.dtype = 0;
 $root.tensorflow.BundleEntryProto.prototype.shape = null;
 $root.tensorflow.BundleEntryProto.prototype.shard_id = 0;
-$root.tensorflow.BundleEntryProto.prototype.offset = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.tensorflow.BundleEntryProto.prototype.size = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.tensorflow.BundleEntryProto.prototype.offset = protobuf.Int64.create(0);
+$root.tensorflow.BundleEntryProto.prototype.size = protobuf.Int64.create(0);
 $root.tensorflow.BundleEntryProto.prototype.crc32c = 0;
 
 $root.tensorflow.TensorSliceProto = class TensorSliceProto {
@@ -4362,7 +4362,7 @@ $root.tensorflow.TensorSliceProto.Extent = class Extent {
     }
 };
 
-$root.tensorflow.TensorSliceProto.Extent.prototype.start = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.tensorflow.TensorSliceProto.Extent.prototype.start = protobuf.Int64.create(0);
 
 $root.tensorflow.SavedSliceMeta = class SavedSliceMeta {
 

+ 4 - 4
src/tf.js

@@ -3,7 +3,7 @@
 // Experimental
 
 var tf = tf || {};
-var long = long || { Long: require('long') };
+var base = base || require('./base');
 var protobuf = protobuf || require('./protobuf');
 
 tf.ModelFactory = class {
@@ -1433,8 +1433,8 @@ tf.TensorBundle = class {
                         const tensor = new tf.proto.TensorProto();
                         tensor.dtype = entry.dtype;
                         tensor.tensor_shape = entry.shape;
-                        const offset = (entry.offset instanceof long.Long) ? entry.offset.toNumber() : entry.offset;
-                        const size = (entry.size instanceof long.Long) ? entry.size.toNumber() : entry.size;
+                        const offset = Number.isInteger(entry.offset) ? entry.offset : entry.offset.toNumber();
+                        const size = Number.isInteger(entry.size) ? entry.size : entry.size.toNumber();
                         if (shards) {
                             tensor.tensor_content = shards[entry.shard_id].slice(offset, offset + size);
                         }
@@ -1608,7 +1608,7 @@ tf.GraphMetadata = class {
         if (value == null) {
             return null;
         }
-        if (value && long.Long.isLong(value)) {
+        if (value && (value instanceof base.Int64 || value instanceof base.Uint64)) {
             value = value.toNumber();
         }
         if (Array.isArray(value)) {

+ 3 - 3
src/uff-proto.js

@@ -76,8 +76,8 @@ $root.uff.MetaGraph = class MetaGraph {
     }
 };
 
-$root.uff.MetaGraph.prototype.version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
-$root.uff.MetaGraph.prototype.descriptor_core_version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.uff.MetaGraph.prototype.version = protobuf.Int64.create(0);
+$root.uff.MetaGraph.prototype.descriptor_core_version = protobuf.Int64.create(0);
 
 $root.uff.MetaGraph.ReferencedDataEntry = class ReferencedDataEntry {
 
@@ -230,7 +230,7 @@ $root.uff.Descriptor = class Descriptor {
 };
 
 $root.uff.Descriptor.prototype.id = "";
-$root.uff.Descriptor.prototype.version = protobuf.Long ? protobuf.Long.fromBits(0, 0, false) : 0;
+$root.uff.Descriptor.prototype.version = protobuf.Int64.create(0);
 $root.uff.Descriptor.prototype.optional = false;
 
 $root.uff.Graph = class Graph {

+ 3 - 6
src/view-sidebar.js

@@ -1,7 +1,7 @@
 /* jshint esversion: 6 */
 
 var sidebar = sidebar || {};
-var long = long || { Long: require('long') };
+var base = base || require('./base');
 var marked = marked || require('marked');
 
 sidebar.Sidebar = class {
@@ -273,10 +273,7 @@ sidebar.NodeSidebar = class {
         if (typeof value === 'function') {
             return value();
         }
-        if (value && long.Long.isLong(value)) {
-            return value.toString();
-        }
-        if (value && long.Long.isLong(value)) {
+        if (value && (value instanceof base.Int64 || value instanceof base.Uint64)) {
             return value.toString();
         }
         if (Number.isNaN(value)) {
@@ -310,7 +307,7 @@ sidebar.NodeSidebar = class {
                 ellipsis = true;
             }
             const array = value.map((item) => {
-                if (item && long.Long.isLong(item)) {
+                if (item && (item instanceof base.Int64 || item instanceof base.Uint64)) {
                     return item.toString();
                 }
                 if (Number.isNaN(item)) {

+ 9 - 10
tools/protoc.js

@@ -2,7 +2,6 @@
 
 const protoc = {};
 const fs = require('fs');
-const long = require('long');
 
 protoc.Object = class {
 
@@ -405,11 +404,7 @@ protoc.Field = class extends protoc.Object {
                 value = type.values[value];
             }
         }
-        if (type.long) {
-            const unsigned = type.name === 'uint64' || type.name === 'fixed64';
-            value = long.fromNumber(value, unsigned);
-        }
-        else if (type === 'bytes' && typeof value === 'string') {
+        if (type === 'bytes' && typeof value === 'string') {
             throw new protoc.Error('Unsupported bytes field.');
         }
         return value;
@@ -1217,8 +1212,12 @@ protoc.Generator = class {
                 first = false;
             }
             if (field.type.long) {
-                const unsigned = field.type.name === 'uint64' || field.type.name === 'fixed64';
-                this._builder.add(name + '.prototype' + protoc.Generator._propertyReference(field.name) + ' = protobuf.Long ? protobuf.Long.fromBits(' + JSON.stringify(field.defaultValue.low) + ', ' + JSON.stringify(field.defaultValue.high) + ', ' + JSON.stringify(field.defaultValue.unsigned) + ') : ' + field.defaultValue.toNumber(unsigned) + ';');
+                if (field.type.name === 'uint64' || field.type.name === 'fixed64') {
+                    this._builder.add(name + '.prototype' + protoc.Generator._propertyReference(field.name) + ' = protobuf.Uint64.create(' + field.defaultValue + ');');
+                }
+                else {
+                    this._builder.add(name + '.prototype' + protoc.Generator._propertyReference(field.name) + ' = protobuf.Int64.create(' + field.defaultValue + ');');
+                }
             }
             else if (field.type.name === 'bytes') {
                 this._builder.add(name + '.prototype' + protoc.Generator._propertyReference(field.name) + ' = new Uint8Array(' + JSON.stringify(Array.prototype.slice.call(field.defaultValue)) + ");");
@@ -1274,7 +1273,7 @@ protoc.Generator = class {
                                 const value = field.type instanceof protoc.PrimitiveType ?
                                     'reader.' + field.type.name + '()' :
                                     fieldTypeName(field) + '.decode(reader, reader.uint32())';
-                                this._builder.add('reader.pair(' + variable + ', () => reader.' + field.keyType.name + '(), () => ' + value + ');');
+                                this._builder.add('reader.entry(' + variable + ', () => reader.' + field.keyType.name + '(), () => ' + value + ');');
                             }
                             else if (field.repeated) {
                                 if (field.type.name === 'float' || field.type.name === 'double') {
@@ -1367,7 +1366,7 @@ protoc.Generator = class {
                                 const value = field.type instanceof protoc.PrimitiveType ?
                                     'reader.' + field.type.name + '()' :
                                     fieldTypeName(field) + '.decodeText(reader, true)';
-                                this._builder.add('reader.pair(' + variable + ', () => reader.' + field.keyType.text + '(), () => ' + value + ');');
+                                this._builder.add('reader.entry(' + variable + ', () => reader.' + field.keyType.text + '(), () => ' + value + ');');
                             }
                             else if (field.repeated) { // Repeated fields
                                 if (field.type instanceof protoc.Enum) {