(x: T)
| 764 | // a copy is needed here to break a circular dependency. |
| 765 | // Also remove the op from unary_op. |
| 766 | abs<T extends Tensor>(x: T): T { |
| 767 | // TODO: handle cases when x is complex. |
| 768 | if (this.shouldExecuteOnCPU([x]) && x.dtype !== 'complex64') { |
| 769 | const outValues = |
| 770 | simpleAbsImplCPU(this.texData.get(x.dataId).values as TypedArray); |
| 771 | return this.makeOutput(x.shape, x.dtype, outValues); |
| 772 | } |
| 773 | |
| 774 | if (env().getBool('WEBGL_PACK_UNARY_OPERATIONS')) { |
| 775 | return this.packedUnaryOp(x, unary_op.ABS, x.dtype) as T; |
| 776 | } |
| 777 | |
| 778 | const program = new UnaryOpProgram(x.shape, unary_op.ABS); |
| 779 | const outInfo = this.compileAndRun(program, [x]); |
| 780 | return engine().makeTensorFromTensorInfo(outInfo) as T; |
| 781 | } |
| 782 | |
| 783 | makeTensorInfo( |
| 784 | shape: number[], dtype: DataType, |
no test coverage detected