Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

EncodeBase64 and DecodeBase64 ops #259

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/nodejs_kernel_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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';
import {Conv2DInfo, Conv3DInfo} from '@tensorflow/tfjs-core/dist/ops/conv_util';
import {Activation} from '@tensorflow/tfjs-core/dist/ops/fused_util';
import {Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
import {StringTensor, Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
import {upcastType} from '@tensorflow/tfjs-core/dist/types';
import {isNullOrUndefined} from 'util';

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

encodeBase64<T extends StringTensor>(str: StringTensor|Tensor, pad = false):
T {
const opAttrs =
[{name: 'pad', type: this.binding.TF_ATTR_BOOL, value: pad}];
return this.executeSingleOutput('EncodeBase64', opAttrs, [str as Tensor]) as
T;
}

decodeBase64<T extends StringTensor>(str: StringTensor|Tensor): T {
// return this.executeSingleInput('DecodeBase64', str as Tensor) as Tensor;
const opAttrs: TFEOpAttr[] = [];
return this.executeSingleOutput('DecodeBase64', opAttrs, [str as Tensor]) as
T;
}

fromPixels(
pixels: ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement,
numChannels: number): Tensor3D {
Expand Down