Skip to content
Merged
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: 0 additions & 5 deletions tfjs-backend-webgl/src/backend_webgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1743,11 +1743,6 @@ export class MathBackendWebGL extends KernelBackend {
return this.compileAndRun(program, [x]);
}

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

tan<T extends Tensor>(x: T): T {
const program = new UnaryOpProgram(x.shape, unary_op.TAN);
return this.compileAndRun(program, [x]);
Expand Down
32 changes: 32 additions & 0 deletions tfjs-backend-webgl/src/kernels/Cos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

import {Cos, CosInputs, KernelConfig} from '@tensorflow/tfjs-core';

import {MathBackendWebGL} from '../backend_webgl';
import {COS, UnaryOpProgram} from '../unaryop_gpu';

export const cosConfig: KernelConfig = {
kernelName: Cos,
backendName: 'webgl',
kernelFunc: ({inputs, backend}) => {
const {x} = inputs as CosInputs;
const webglBackend = backend as MathBackendWebGL;
const program = new UnaryOpProgram(x.shape, COS);
return webglBackend.runWebGLProgram(program, [x], x.dtype);
}
};
3 changes: 2 additions & 1 deletion tfjs-backend-webgl/src/register_all_kernels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
import {KernelConfig, registerKernel} from '@tensorflow/tfjs-core';

import {cosConfig} from './kernels/Cos';
import {divConfig} from './kernels/Div';
import {flipLeftRightConfig} from './kernels/FlipLeftRight';
import {fromPixelsConfig} from './kernels/FromPixels';
Expand All @@ -31,7 +32,7 @@ import {transposeConfig} from './kernels/Transpose';

// List all kernel configs here
const kernelConfigs: KernelConfig[] = [
maxConfig, flipLeftRightConfig, fromPixelsConfig, divConfig,
cosConfig, maxConfig, flipLeftRightConfig, fromPixelsConfig, divConfig,
maxPoolWithArgmaxConfig, nonMaxSuppressionV3Config, nonMaxSuppressionV4Config,
nonMaxSuppressionV5Config, rotateWithOffsetConfig, squareConfig,
squaredDifferenceConfig, transposeConfig
Expand Down