diff --git a/src/unittests/floating_point.spec.ts b/src/unittests/floating_point.spec.ts index 4c32e11459af..052ee84bc6d4 100644 --- a/src/unittests/floating_point.spec.ts +++ b/src/unittests/floating_point.spec.ts @@ -3647,7 +3647,7 @@ g.test('saturateInterval') g.test('signInterval') .params(u => u - .combine('trait', ['f32', 'f16'] as const) + .combine('trait', ['f32', 'f16', 'abstract'] as const) .beginSubcases() .expandWithParams(p => { const constants = FP[p.trait].constants(); diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index 867e33f82d8a..fa57ff978139 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1356,7 +1356,7 @@ "webgpu:shader,execution,expression,call,builtin,saturate:f32:*": { "subcaseMS": 116.275 }, "webgpu:shader,execution,expression,call,builtin,select:scalar:*": { "subcaseMS": 6.882 }, "webgpu:shader,execution,expression,call,builtin,select:vector:*": { "subcaseMS": 7.096 }, - "webgpu:shader,execution,expression,call,builtin,sign:abstract_float:*": { "subcaseMS": 31.708 }, + "webgpu:shader,execution,expression,call,builtin,sign:abstract_float:*": { "subcaseMS": 412.925 }, "webgpu:shader,execution,expression,call,builtin,sign:abstract_int:*": { "subcaseMS": 25.806 }, "webgpu:shader,execution,expression,call,builtin,sign:f16:*": { "subcaseMS": 25.103 }, "webgpu:shader,execution,expression,call,builtin,sign:f32:*": { "subcaseMS": 8.188 }, diff --git a/src/webgpu/shader/execution/expression/call/builtin/sign.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/sign.spec.ts index 454ff48e6edc..a147acf6fb24 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/sign.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/sign.spec.ts @@ -9,13 +9,24 @@ Returns the sign of e. Component-wise when T is a vector. import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; import { GPUTest } from '../../../../../gpu_test.js'; -import { i32, TypeF32, TypeF16, TypeI32 } from '../../../../../util/conversion.js'; +import { + i32, + TypeF32, + TypeF16, + TypeI32, + TypeAbstractFloat, +} from '../../../../../util/conversion.js'; import { FP } from '../../../../../util/floating_point.js'; -import { fullF32Range, fullF16Range, fullI32Range } from '../../../../../util/math.js'; +import { + fullF32Range, + fullF16Range, + fullI32Range, + fullF64Range, +} from '../../../../../util/math.js'; import { makeCaseCache } from '../../case_cache.js'; -import { allInputSources, run } from '../../expression.js'; +import { allInputSources, onlyConstInputSource, run } from '../../expression.js'; -import { builtin } from './builtin.js'; +import { abstractBuiltin, builtin } from './builtin.js'; export const g = makeTestGroup(GPUTest); @@ -26,6 +37,13 @@ export const d = makeCaseCache('sign', { f16: () => { return FP.f16.generateScalarToIntervalCases(fullF16Range(), 'unfiltered', FP.f16.signInterval); }, + abstract_float: () => { + return FP.abstract.generateScalarToIntervalCases( + fullF64Range(), + 'unfiltered', + FP.abstract.signInterval + ); + }, i32: () => fullI32Range().map(i => { const signFunc = (i: number): number => (i < 0 ? -1 : i > 0 ? 1 : 0); @@ -37,13 +55,18 @@ g.test('abstract_float') .specURL('https://www.w3.org/TR/WGSL/#sign-builtin') .desc(`abstract float tests`) .params(u => - u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4] as const) + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) ) - .unimplemented(); + .fn(async t => { + const cases = await d.get('abstract_float'); + await run(t, abstractBuiltin('sign'), [TypeAbstractFloat], TypeAbstractFloat, t.params, cases); + }); g.test('abstract_int') .specURL('https://www.w3.org/TR/WGSL/#sign-builtin') - .desc(`abstract float tests`) + .desc(`abstract int tests`) .params(u => u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4] as const) ) diff --git a/src/webgpu/util/floating_point.ts b/src/webgpu/util/floating_point.ts index e9f6271c323b..4d2f9a324cb5 100644 --- a/src/webgpu/util/floating_point.ts +++ b/src/webgpu/util/floating_point.ts @@ -5070,7 +5070,7 @@ class FPAbstractTraits extends FPTraits { }; public readonly roundInterval = this.unimplementedScalarToInterval.bind(this, 'roundInterval'); public readonly saturateInterval = this.saturateIntervalImpl.bind(this); - public readonly signInterval = this.unimplementedScalarToInterval.bind(this, 'signInterval'); + public readonly signInterval = this.signIntervalImpl.bind(this); public readonly sinInterval = this.unimplementedScalarToInterval.bind(this, 'sinInterval'); public readonly sinhInterval = this.unimplementedScalarToInterval.bind(this, 'sinhInterval'); public readonly smoothStepInterval = this.unimplementedScalarTripleToInterval.bind(