* Create a view of the array. * @param shape The shape of the view. * @param dtype The data type of the new array. * @returns The new sliced ndarray.
(shape: Array<number>, dtype?: string)
| 574 | * @returns The new sliced ndarray. |
| 575 | */ |
| 576 | view(shape: Array<number>, dtype?: string): Tensor { |
| 577 | const shapeArray = shape.map((value) => new Scalar(value, "int")); |
| 578 | if (dtype === undefined) { |
| 579 | dtype = this.dtype; |
| 580 | } |
| 581 | return this.ctx.tensorCreateView( |
| 582 | this, |
| 583 | this.ctx.makeShapeTuple(...shapeArray), |
| 584 | this.dtype, |
| 585 | /*relative_byte_offset=*/ new Scalar(0, "int"), |
| 586 | ); |
| 587 | } |
| 588 | /** |
| 589 | * Get dataPtr of NDarray |
| 590 | * |