/** * @license * Copyright 2022 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 { DataType, Rank, ShapeMap, TensorInfo } from '@tensorflow/tfjs-core'; export interface WebGPUProgram { atomic?: boolean; dispatch: [number, number, number]; dispatchLayout: { x: number[]; y?: number[]; z?: number[]; }; isFromPixels?: boolean; isVec4?: boolean; outputShape: number[]; shaderKey: string; size?: boolean; uniforms?: string; variableNames: string[]; variableTypes?: string[]; workgroupSize: [number, number, number]; workPerThread?: number; getUserCode: () => string; } export declare const compileProgram: (device: GPUDevice, program: WebGPUProgram, inputsData: InputInfo[], output: TensorInfo) => GPUComputePipeline; export declare function getCoordsDataType(rank: number): string; export declare function getCoordsXYZ(index: number): string; export declare function getMainHeaderString(): string; export declare function getMainHeaderString(index: string): string; export declare function getStartHeaderString(useGlobalIndex: boolean, program: WebGPUProgram): string; export declare function getWorkgroupSizeString(program: WebGPUProgram): string; export declare function makeShaderKey(program: WebGPUProgram, shapes: Array, inputsData: InputInfo[], output: TensorInfo): string; declare type InputInfo = { dtype: DataType; shape: number[]; name: string; }; export declare type WGSLDataType = 'f32' | 'i32' | 'vec4' | 'vec4' | 'vec4'; export declare function mapToWgslTypes(type: DataType, isVec4: boolean): WGSLDataType | DataType; export {};