Skip to content

Commit 01cd0e0

Browse files
committed
Removed Tensor_batch_slice from utils.c
1 parent 26f7e08 commit 01cd0e0

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

src/utils.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -222,35 +222,6 @@ TensorMaxMinResult Tensor_min_dim(Tensor self, int dim) {
222222
return result;
223223
}
224224

225-
Tensor Tensor_batch_slice(Tensor t, int batch_idx, int group_idx) {
226-
int dim = TensorShape_dim(t.shape);
227-
228-
int m, n, offset;
229-
TensorShape slice_shape = {0, 0, 0, 0};
230-
231-
if (dim == 3) {
232-
int b = t.shape[0]; m = t.shape[1]; n = t.shape[2];
233-
assert(batch_idx >= 0 && batch_idx < b);
234-
235-
offset = batch_idx * m * n;
236-
slice_shape[0] = m; slice_shape[1] = n;
237-
} else if (dim == 4) {
238-
int b = t.shape[0], g = t.shape[1];
239-
m = t.shape[2]; n = t.shape[3];
240-
241-
assert(batch_idx >= 0 && batch_idx < b);
242-
assert(group_idx >= 0 && group_idx < g);
243-
offset = (batch_idx * g + group_idx) * m * n;
244-
slice_shape[0] = m; slice_shape[1] = n;
245-
} else {
246-
assert(0);
247-
}
248-
249-
Tensor res = Tensor_new(slice_shape, t.node != NULL);
250-
memcpy(res.data->flex, t.data->flex + offset, sizeof(float) * m * n);
251-
return res;
252-
}
253-
254225
void cten_assert(bool cond, const char* fmt, ...) {
255226
if(!cond) {
256227
va_list args;

0 commit comments

Comments
 (0)