Skip to content

Commit 59b37d5

Browse files
committed
add encodeBase64, decodeBase64
see - tensorflow/tfjs-core#1779 - tensorflow/tfjs-converter#376
1 parent 83bcb2d commit 59b37d5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/nodejs_kernel_backend.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import {BackendTimingInfo, DataMover, DataType, fill, KernelBackend, ones, Rank, rsqrt, Scalar, scalar, ShapeMap, Tensor, Tensor1D, tensor1d, Tensor2D, tensor2d, Tensor3D, tensor3d, Tensor4D, tidy, util} from '@tensorflow/tfjs-core';
2020
import {Conv2DInfo, Conv3DInfo} from '@tensorflow/tfjs-core/dist/ops/conv_util';
2121
import {Activation} from '@tensorflow/tfjs-core/dist/ops/fused_util';
22-
import {Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
22+
import {StringTensor, Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
2323
import {upcastType} from '@tensorflow/tfjs-core/dist/types';
2424
import {isNullOrUndefined} from 'util';
2525

@@ -1552,6 +1552,21 @@ export class NodeJSKernelBackend extends KernelBackend {
15521552
return this.executeSingleOutput('LinSpace', opAttrs, inputs) as Tensor1D;
15531553
}
15541554

1555+
encodeBase64<T extends StringTensor>(str: StringTensor|Tensor, pad = false):
1556+
T {
1557+
const opAttrs =
1558+
[{name: 'pad', type: this.binding.TF_ATTR_BOOL, value: pad}];
1559+
return this.executeSingleOutput('EncodeBase64', opAttrs, [str as Tensor]) as
1560+
T;
1561+
}
1562+
1563+
decodeBase64<T extends StringTensor>(str: StringTensor|Tensor): T {
1564+
// return this.executeSingleInput('DecodeBase64', str as Tensor) as Tensor;
1565+
const opAttrs: TFEOpAttr[] = [];
1566+
return this.executeSingleOutput('DecodeBase64', opAttrs, [str as Tensor]) as
1567+
T;
1568+
}
1569+
15551570
fromPixels(
15561571
pixels: ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement,
15571572
numChannels: number): Tensor3D {

0 commit comments

Comments
 (0)