Skip to content

Commit

Permalink
[webgpu] Add support for Elu (#4785)
Browse files Browse the repository at this point in the history
FEATURE
  • Loading branch information
haoyunfeix authored Mar 8, 2021
1 parent a6e3376 commit 42c7f25
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tfjs-backend-webgpu/src/kernels/Elu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2021 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 {Elu, KernelConfig} from '@tensorflow/tfjs-core';
import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils';
import {ELU} from './unary_op_webgpu';

export const elu = unaryKernelFunc({opSnippet: ELU});

export const eluConfig: KernelConfig = {
kernelName: Elu,
backendName: 'webgpu',
kernelFunc: elu
};
2 changes: 2 additions & 0 deletions tfjs-backend-webgpu/src/register_all_kernels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {concatConfig} from './kernels/Concat';
import {conv2DConfig} from './kernels/Conv2D';
import {cropAndResizeConfig} from './kernels/CropAndResize';
import {depthwiseConv2dNativeConfig} from './kernels/DepthwiseConv2dNative';
import {eluConfig} from './kernels/Elu';
import {expConfig} from './kernels/Exp';
import {expandDimsConfig} from './kernels/ExpandDims';
import {expm1Config} from './kernels/Expm1';
Expand Down Expand Up @@ -104,6 +105,7 @@ const kernelConfigs: KernelConfig[] = [
conv2DConfig,
cropAndResizeConfig,
depthwiseConv2dNativeConfig,
eluConfig,
expandDimsConfig,
expConfig,
expm1Config,
Expand Down
8 changes: 8 additions & 0 deletions tfjs-backend-webgpu/src/setup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ const TEST_FILTERS: TestFilter[] = [
'leakyrelu' // Not yet implemented.
]
},
{
include: 'elu',
excludes: [
'selu', // Not yet implemented.
'derivative', // gradient function not found.
'gradient' // gradient function not found.
]
},
{
include: 'resizeBilinear',
excludes: [
Expand Down

0 comments on commit 42c7f25

Please sign in to comment.