Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/backend_webgl2compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ export class WebGL2ComputeBackend extends KernelBackend {
return this.compileAndRun(program, [x]) as T;
}

log<T extends Tensor>(x: T): T {
const program = new UnaryOpProgram(unary_op.LOG, x.shape);
return this.compileAndRun(program, [x]) as T;
}

resizeBilinear(
x: Tensor4D, newHeight: number, newWidth: number,
alignCorners: boolean): Tensor4D {
Expand Down
2 changes: 2 additions & 0 deletions src/kernels/unary_op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {computeDispatch} from '../webgl2compute_util';
import {WebGL2ComputeProgram} from './webgl2compute_program';

export const RELU = 'return max(a, 0.0);';
// TODO(xinghua): Need to verify that x is greater than or equal to 0.
export const LOG = 'return log(a);';

export class UnaryOpProgram implements WebGL2ComputeProgram {
outputShape: number[];
Expand Down
13 changes: 12 additions & 1 deletion src/setup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const INCLUDE_LIST: string[] = [
'resizeBilinear',
'relu',
'pad',
'log',
];
/** Tests that have these substrings in their name will be excluded. */
const EXCLUDE_LIST: string[] = [
Expand Down Expand Up @@ -82,7 +83,17 @@ const EXCLUDE_LIST: string[] = [
'accepts tensor with bool values', // tensor with bool value is not yet
// implemented
'N > than parallelization threshold',
'grad', // pad grad, slice is not yet implemented.
'grad', // pad grad, slice is not yet implemented.
'logicalNot', // not yet implemented.
'logSumExp', // not yet implemented.
'logicalXor', // not yet implemented.
'logLoss', // not yet implemented.
'logSoftmax', // not yet implemented.
'log1p', // not yet implemented.
'logSigmoid', // not yet implemented.
'logicalOr', // not yet implemented.
'logicalAnd', // not yet implemented.
'downloadMatrixFromPackedOutputTexture', // readSync is not yet implemented.
];

/**
Expand Down