From fd233135c5b0a20518f4ae44416e685926b640e7 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Wed, 25 Oct 2023 16:48:15 -0700 Subject: [PATCH] move to types.ts --- src/common/util/types.ts | 5 +++++ .../execution/expression/call/builtin/faceForward.spec.ts | 2 +- .../shader/execution/expression/call/builtin/refract.spec.ts | 2 +- src/webgpu/shader/execution/expression/expression.ts | 2 +- src/webgpu/util/conversion.ts | 2 +- src/webgpu/util/floating_point.ts | 3 +-- src/webgpu/util/math.ts | 4 +--- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/common/util/types.ts b/src/common/util/types.ts index 5714df73f00b..e677cbb6c78a 100644 --- a/src/common/util/types.ts +++ b/src/common/util/types.ts @@ -13,6 +13,11 @@ export type TypeEqual = (() => T extends X ? 1 : 2) extends () => T /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ export function assertTypeTrue() {} +/** `ReadonlyArray` of `ReadonlyArray`s. */ +export type ROArrayArray = ReadonlyArray>; +/** `ReadonlyArray` of `ReadonlyArray`s of `ReadonlyArray`s. */ +export type ROArrayArrayArray = ReadonlyArray>>; + /** * Deep version of the Readonly<> type, with support for tuples (up to length 7). * diff --git a/src/webgpu/shader/execution/expression/call/builtin/faceForward.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/faceForward.spec.ts index 2af216f66e0a..6b6794fb9ff0 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/faceForward.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/faceForward.spec.ts @@ -7,6 +7,7 @@ Returns e1 if dot(e2,e3) is negative, and -e1 otherwise. `; import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; +import { ROArrayArray } from '../../../../../../common/util/types.js'; import { GPUTest } from '../../../../../gpu_test.js'; import { anyOf } from '../../../../../util/compare.js'; import { toVector, TypeF32, TypeF16, TypeVec } from '../../../../../util/conversion.js'; @@ -15,7 +16,6 @@ import { cartesianProduct, sparseVectorF32Range, sparseVectorF16Range, - ROArrayArray, } from '../../../../../util/math.js'; import { makeCaseCache } from '../../case_cache.js'; import { allInputSources, Case, IntervalFilter, run } from '../../expression.js'; diff --git a/src/webgpu/shader/execution/expression/call/builtin/refract.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/refract.spec.ts index 234938bbb94a..be1a76b4372f 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/refract.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/refract.spec.ts @@ -11,6 +11,7 @@ vector e3*e1- (e3* dot(e2,e1) + sqrt(k)) *e2. `; import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; +import { ROArrayArray } from '../../../../../../common/util/types.js'; import { GPUTest } from '../../../../../gpu_test.js'; import { toVector, TypeF32, TypeF16, TypeVec } from '../../../../../util/conversion.js'; import { FP, FPKind } from '../../../../../util/floating_point.js'; @@ -19,7 +20,6 @@ import { sparseVectorF16Range, sparseF32Range, sparseF16Range, - ROArrayArray, } from '../../../../../util/math.js'; import { makeCaseCache } from '../../case_cache.js'; import { allInputSources, Case, IntervalFilter, run } from '../../expression.js'; diff --git a/src/webgpu/shader/execution/expression/expression.ts b/src/webgpu/shader/execution/expression/expression.ts index 2211beb7dc25..8765476831d4 100644 --- a/src/webgpu/shader/execution/expression/expression.ts +++ b/src/webgpu/shader/execution/expression/expression.ts @@ -1,4 +1,5 @@ import { globalTestConfig } from '../../../../common/framework/test_config.js'; +import { ROArrayArray } from '../../../../common/util/types.js'; import { assert, objectEquals, unreachable } from '../../../../common/util/util.js'; import { GPUTest } from '../../../gpu_test.js'; import { compare, Comparator, ComparatorImpl } from '../../../util/compare.js'; @@ -25,7 +26,6 @@ import { QuantizeFunc, quantizeToI32, quantizeToU32, - ROArrayArray, } from '../../../util/math.js'; export type Expectation = diff --git a/src/webgpu/util/conversion.ts b/src/webgpu/util/conversion.ts index bfb8ee3c4c76..e78af9783288 100644 --- a/src/webgpu/util/conversion.ts +++ b/src/webgpu/util/conversion.ts @@ -1,4 +1,5 @@ import { Colors } from '../../common/util/colors.js'; +import { ROArrayArray } from '../../common/util/types.js'; import { assert, objectEquals, TypedArrayBufferView, unreachable } from '../../common/util/util.js'; import { Float16Array } from '../../external/petamoriken/float16/float16.js'; @@ -11,7 +12,6 @@ import { isSubnormalNumberF16, isSubnormalNumberF32, isSubnormalNumberF64, - ROArrayArray, } from './math.js'; /** diff --git a/src/webgpu/util/floating_point.ts b/src/webgpu/util/floating_point.ts index 91d0eab6bdfd..79af5f7b97e5 100644 --- a/src/webgpu/util/floating_point.ts +++ b/src/webgpu/util/floating_point.ts @@ -1,3 +1,4 @@ +import { ROArrayArray, ROArrayArrayArray } from '../../common/util/types.js'; import { assert, unreachable } from '../../common/util/util.js'; import { Float16Array } from '../../external/petamoriken/float16/float16.js'; import { Case, IntervalFilter } from '../shader/execution/expression/expression.js'; @@ -38,8 +39,6 @@ import { quantizeToF16, unflatten2DArray, every2DArray, - ROArrayArray, - ROArrayArrayArray, } from './math.js'; import { reinterpretF16AsU16, diff --git a/src/webgpu/util/math.ts b/src/webgpu/util/math.ts index d94059528220..6e8c9951ce34 100644 --- a/src/webgpu/util/math.ts +++ b/src/webgpu/util/math.ts @@ -1,3 +1,4 @@ +import { ROArrayArray, ROArrayArrayArray } from '../../common/util/types.js'; import { assert } from '../../common/util/util.js'; import { Float16Array, @@ -14,9 +15,6 @@ import { reinterpretU16AsF16, } from './reinterpret.js'; -export type ROArrayArray = ReadonlyArray>; -export type ROArrayArrayArray = ReadonlyArray>>; - /** * A multiple of 8 guaranteed to be way too large to allocate (just under 8 pebibytes). * This is a "safe" integer (ULP <= 1.0) very close to MAX_SAFE_INTEGER.