MCPcopy Index your code
hub / github.com/tensorflow/tfjs / constructor

Method constructor

tfjs-core/src/tensor.ts:51–70  ·  view source on GitHub ↗
(shape: ShapeMap[R], public dtype: D, values?: DataTypeMap[D])

Source from the content-addressed store, hash-verified

49 values: DataTypeMap[D];
50
51 constructor(shape: ShapeMap[R], public dtype: D, values?: DataTypeMap[D]) {
52 this.shape = shape.slice() as ShapeMap[R];
53 this.size = util.sizeFromShape(shape);
54
55 if (values != null) {
56 const n = values.length;
57 util.assert(
58 n === this.size,
59 () => `Length of values '${n}' does not match the size ` +
60 `inferred by the shape '${this.size}'.`);
61 }
62 if (dtype === 'complex64') {
63 throw new Error(
64 `complex64 dtype TensorBuffers are not supported. Please create ` +
65 `a TensorBuffer for the real and imaginary parts separately and ` +
66 `call tf.complex(real, imag).`);
67 }
68 this.values = values || util.getArrayFromDType(dtype, this.size);
69 this.strides = computeStrides(shape);
70 }
71
72 /**
73 * Sets a value in the buffer at a given location.

Callers

nothing calls this directly

Calls 2

computeStridesFunction · 0.90
sliceMethod · 0.65

Tested by

no test coverage detected