mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-13 18:08:13 +00:00
* add web * add script and test * fix lint * add test/data/ops * add test/data/node/ to gitignore * modify scripts * add onnxjs * fix tests * fix test-runner * fix sourcemap * fix onnxjs profiling * update test list * update README * resolve comments * set wasm as default backend * rename package * update copyright header * do not use class "Buffer" in browser context * revise readme
32 lines
861 B
TypeScript
32 lines
861 B
TypeScript
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
export function getVecChannels(name: string, rank: number): string[] {
|
|
return ['x', 'y', 'z', 'w', 'u', 'v'].slice(0, rank).map(d => `${name}.${d}`);
|
|
}
|
|
|
|
export function getChannels(name: string, rank: number): string[] {
|
|
if (rank === 1) {
|
|
return [name];
|
|
}
|
|
return getVecChannels(name, rank);
|
|
}
|
|
|
|
export function unpackFromChannel(rank: number): string {
|
|
if (rank <= 1) {
|
|
return `
|
|
float getChannel(vec4 frag, int dim) {
|
|
int modCoord = imod(dim, 2);
|
|
return modCoord == 0 ? frag.r : frag.g;
|
|
}
|
|
`;
|
|
}
|
|
return `
|
|
float getChannel(vec4 frag, vec2 innerDims) {
|
|
vec2 modCoord = mod(innerDims, 2.);
|
|
return modCoord.x == 0. ?
|
|
(modCoord.y == 0. ? frag.r : frag.g) :
|
|
(modCoord.y == 0. ? frag.b : frag.a);
|
|
}
|
|
`;
|
|
}
|