Skip to content

Commit

Permalink
fix unary funcs async signature
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire committed Sep 13, 2022
1 parent a782667 commit ad6bd01
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions js/web/lib/onnxjs/backends/webgpu/ops/unary-op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ const createElementwiseProgramInfoLoader =
};
};

export const abs = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] =>
export const abs = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> =>
handler.run(createElementwiseProgramInfoLoader(inputs[0], 'abs'), inputs);

export const acos = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] =>
export const acos = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> =>
handler.run(createElementwiseProgramInfoLoader(inputs[0], 'acos'), inputs);

export const asin = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] =>
export const asin = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> =>
handler.run(createElementwiseProgramInfoLoader(inputs[0], 'asin'), inputs);

export const atan = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] =>
export const atan = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> =>
handler.run(createElementwiseProgramInfoLoader(inputs[0], 'atan'), inputs);

export interface ClipAttributes extends AttributeWithCacheKey {
readonly min: number;
readonly max: number;
}

export const clip = (handler: WebGpuInferenceHandler, inputs: Tensor[], attributes: ClipAttributes): Tensor[] =>
handler.run(
createElementwiseProgramInfoLoader(
inputs[0], 'clip', `
export const clip = async(handler: WebGpuInferenceHandler, inputs: Tensor[], attributes: ClipAttributes):
Promise<Tensor[] >=>handler.run(
createElementwiseProgramInfoLoader(
inputs[0], 'clip', `
let clip_min_: vec4<f32> = vec4(f32(${attributes.min}));
let clip_max_: vec4<f32> = vec4(f32(${attributes.max}));
fn clip(x: vec4<f32>) -> vec4<f32> {
return clamp(x, clip_min_, clip_max_);
}`,
attributes.cacheKey),
inputs);
attributes.cacheKey),
inputs);

export const parseClipAttributes = (node: Graph.Node): ClipAttributes => createAttributeWithCacheKey(
{min: node.attributes.getFloat('min', MIN_CLIP), max: node.attributes.getFloat('max', MAX_CLIP)});
Expand All @@ -102,15 +102,15 @@ const generateClipAttributesFromInputs = (handler: WebGpuInferenceHandler, input
return createAttributeWithCacheKey({min, max});
};

export const clipV11 = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] => {
export const clipV11 = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> => {
const attributes = generateClipAttributesFromInputs(handler, inputs);
return clip(handler, [inputs[0]], attributes);
};

export const ceil = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] =>
export const ceil = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> =>
handler.run(createElementwiseProgramInfoLoader(inputs[0], 'ceil'), inputs);

export const cos = (handler: WebGpuInferenceHandler, inputs: Tensor[]): Tensor[] =>
export const cos = async(handler: WebGpuInferenceHandler, inputs: Tensor[]): Promise<Tensor[]> =>
handler.run(createElementwiseProgramInfoLoader(inputs[0], 'cos'), inputs);

// export interface EluAttributes extends AttributeWithCacheKey {
Expand Down

0 comments on commit ad6bd01

Please sign in to comment.