浏览代码

Update tf.js (#563)

Lutz Roeder 4 年之前
父节点
当前提交
eb8710effb
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      source/tf.js

+ 4 - 0
source/tf.js

@@ -1225,6 +1225,10 @@ tf.Tensor = class {
                 case DataType.DT_UINT32:
                 case DataType.DT_INT64:
                 case DataType.DT_UINT64:
+                    if (!this._buffer || this._buffer.length === 0) {
+                        context.state = 'Tensor has content.';
+                        return context;
+                    }
                     context.rawData = new DataView(this._buffer.buffer, this._buffer.byteOffset, this._buffer.byteLength);
                     break;
             }