MCPcopy Create free account
hub / github.com/tensorflow/tfjs / abs

Method abs

tfjs-backend-webgl/src/backend_webgl.ts:766–781  ·  view source on GitHub ↗
(x: T)

Source from the content-addressed store, hash-verified

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,

Callers 1

floatPrecisionMethod · 0.95

Calls 9

shouldExecuteOnCPUMethod · 0.95
makeOutputMethod · 0.95
packedUnaryOpMethod · 0.95
compileAndRunMethod · 0.95
envFunction · 0.90
engineFunction · 0.90
getBoolMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected