Skip to content

Commit

Permalink
add encodeBase64, decodeBase64
Browse files Browse the repository at this point in the history
  • Loading branch information
vabarbosa committed Jun 11, 2019
1 parent 83bcb2d commit 59b37d5
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit 59b37d5

Please sign in to comment.