MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RunTestPermutation

Function RunTestPermutation

tensorflow/lite/kernels/transpose_test.cc:29–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28template <typename T>
29void RunTestPermutation(const std::vector<int>& shape,
30 const std::vector<int>& perms,
31 std::vector<T>* input_transposed) {
32 // Count elements and allocate output.
33 int count = 1;
34 for (auto factor : shape) count *= factor;
35 input_transposed->resize(count);
36
37 // Create the dummy data
38 std::vector<T> input(count);
39 for (int i = 0; i < input.size(); i++) {
40 input[i] = i;
41 }
42
43 // Make input and output shapes.
44 const RuntimeShape input_shape = GetTensorShape(shape);
45 RuntimeShape output_shape(perms.size());
46 for (int i = 0; i < perms.size(); i++) {
47 output_shape.SetDim(i, input_shape.Dims(perms[i]));
48 }
49
50 TransposeParams params;
51 params.perm_count = perms.size();
52 for (int i = 0; i < perms.size(); ++i) {
53 params.perm[i] = perms[i];
54 }
55
56 reference_ops::Transpose<T>(params, input_shape, input.data(), output_shape,
57 input_transposed->data());
58}
59
60TEST(TransposeTest, TestRefOps1D) {
61 // Basic 1D identity.

Callers 1

TESTFunction · 0.85

Calls 6

SetDimMethod · 0.80
DimsMethod · 0.80
GetTensorShapeFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected