Skip to content

Commit

Permalink
move to types.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Oct 25, 2023
1 parent de1e83d commit fd23313
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/common/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export type TypeEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export function assertTypeTrue<T extends true>() {}

/** `ReadonlyArray` of `ReadonlyArray`s. */
export type ROArrayArray<T> = ReadonlyArray<ReadonlyArray<T>>;
/** `ReadonlyArray` of `ReadonlyArray`s of `ReadonlyArray`s. */
export type ROArrayArrayArray<T> = ReadonlyArray<ReadonlyArray<ReadonlyArray<T>>>;

/**
* Deep version of the Readonly<> type, with support for tuples (up to length 7).
* <https://gist.github.com/masterkidan/7322752f569b1bba53e0426266768623>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/shader/execution/expression/expression.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -25,7 +26,6 @@ import {
QuantizeFunc,
quantizeToI32,
quantizeToU32,
ROArrayArray,
} from '../../../util/math.js';

export type Expectation =
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/util/conversion.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -11,7 +12,6 @@ import {
isSubnormalNumberF16,
isSubnormalNumberF32,
isSubnormalNumberF64,
ROArrayArray,
} from './math.js';

/**
Expand Down
3 changes: 1 addition & 2 deletions src/webgpu/util/floating_point.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -38,8 +39,6 @@ import {
quantizeToF16,
unflatten2DArray,
every2DArray,
ROArrayArray,
ROArrayArrayArray,
} from './math.js';
import {
reinterpretF16AsU16,
Expand Down
4 changes: 1 addition & 3 deletions src/webgpu/util/math.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ROArrayArray, ROArrayArrayArray } from '../../common/util/types.js';
import { assert } from '../../common/util/util.js';
import {
Float16Array,
Expand All @@ -14,9 +15,6 @@ import {
reinterpretU16AsF16,
} from './reinterpret.js';

export type ROArrayArray<T> = ReadonlyArray<ReadonlyArray<T>>;
export type ROArrayArrayArray<T> = ReadonlyArray<ReadonlyArray<ReadonlyArray<T>>>;

/**
* 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.
Expand Down

0 comments on commit fd23313

Please sign in to comment.