Skip to content

Commit f93749a

Browse files
authored
[src] More work on tensor library draft in kaldi10 (#3124)
1 parent b9efc54 commit f93749a

File tree

2 files changed

+365
-29
lines changed

2 files changed

+365
-29
lines changed

src/tensor/tensor-functions.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "tensor/tensor.h"
2+
3+
4+
namespace kaldi {
5+
namespace tensor {
6+
7+
// This file contains functions that operate on Tensors in various ways. To
8+
// avoid class Tensor blowing up hugely, we implement these things outside
9+
// class Tensor.
10+
11+
12+
// Note: we use the distinction between references and pointers the same way as
13+
// you might expect from Google-style-guide code, to reflect which Tensors'
14+
// contents are changed (so a pointer argument might have its contents changed.
15+
// But these are in most cases pointers to const Tensors; they can be
16+
// donst because the metadata is not changed, even if the data is.
17+
18+
19+
// Sets all elements of the tensor to zero.
20+
void SetZero(const Tensor *tensor);
21+
22+
// Sets all elements of the tensor to value f (cast to whatever type
23+
// this Tensor has).
24+
void SetZero(float f, const Tensor *tensor);
25+
26+
27+
// Return a transposed version of this Tensor that shares the underlying memory.
28+
Tensor Transpose(const Tensor &tensor, int64_t axis1 = 0, int64_t axis2 = 1);
29+
30+
31+
}
32+
}

0 commit comments

Comments
 (0)