transferFromNHWCtoNCHW.es6 798 字节
Newer Older
W
wangqun 已提交
1 2 3 4 5 6 7 8 9 10 11 12
/* eslint-disable */
/**
 * @file 公共方法
 * @author chenhaoze
 */
// TEXTURE_NAME, tensor name
// 获取材质中的数据
// uniform sampler2D TEXTURE_NAME;
export default `
ivec4 transferFromNHWCtoNCHW( int sumVal,  const int channel, const int width_shape, const int height_shape, const int total_shape) {

	int n_origin = int(total_shape/(channel * width_shape * height_shape));
13
	int new_a = int(mod(float(sumVal), float(width_shape)));
W
wangqun 已提交
14
	sumVal = int((sumVal - new_a) / width_shape);
15
	int new_b = int(mod(float(sumVal), float(height_shape)));
W
wangqun 已提交
16
	sumVal = int((sumVal - new_b) / height_shape);
17
	int new_g = int(mod(float(sumVal), float(channel)));
W
wangqun 已提交
18
	sumVal = int((sumVal - new_g) / channel);
19
	int new_r = int(mod(float(sumVal), float(n_origin)));
W
wangqun 已提交
20 21 22
	return ivec4(new_r,new_g,new_b,new_a);
}
`;