赞
踩
- __aicore__ inline int64_t get_index(int64_t i, int64_t j) {
- int64_t index = 0, step = 1, offset = 1;
- for (int64_t k = numshapes - 1; k >= 0; --k) {
- const int64_t idx = i / step % outshape[k];
- step *= outshape[k];
- index += idx % shape[j][k] * offset;
- offset *= shape[j][k];
- }
- return index;
- }
- __aicore__ inline void Process() {
- using F = typename map<T>::type;
- for (int64_t i = 0; i < maxbatchSize; ++i) {
- for (int64_t j = 0; j < maxstepSize; ++j) {
- auto index1 = i * 3 * maxstepSize + 0 * maxstepSize + j;
- auto index2 = i * 3 * maxstepSize + 1 * maxstepSize + j;
- auto index3 = i * 3 * maxstepSize + 2 * maxstepSize + j;
- F a1 = Gm_x1.GetValue(get_index(index1, 0));
- F a2 = Gm_x1.GetValue(get_index(index2, 0));
- F a3 = Gm_x1.GetValue(get_index(index3, 0));
- F b1 = Gm_x2.GetValue(get_index(index1, 1));
- F b2 = Gm_x2.GetValue(get_index(index2, 1));
- F b3 = Gm_x2.GetValue(get_index(index3, 1));
- auto result1 = a2 * b3 - a3 * b2;
- auto result2 = a3 * b1 - a1 * b3;
- auto result3 = a1 * b2 - a2 * b1;
- Gm_y(index1) = (T)result1;
- Gm_y(index2) = (T)result2;
- Gm_y(index3) = (T)result3;
- }
- }
- }

- x1_tensor = np.random.uniform(-1e9, 1e9, [4, 3, 6, 5, 7, 8, 3]).astype(np.int8)
- x2_tensor = np.random.uniform(-1e9, 1e9, [1, 3, 1, 1, 1, 1, 1]).astype(np.int8)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。