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

Function TestNewTensor

tensorflow/go/tensor_test.go:26–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestNewTensor(t *testing.T) {
27 var tests = []struct {
28 shape []int64
29 value interface{}
30 }{
31 {nil, bool(true)},
32 {nil, int8(5)},
33 {nil, int16(5)},
34 {nil, int32(5)},
35 {nil, int64(5)},
36 {nil, uint8(5)},
37 {nil, uint16(5)},
38 {nil, uint32(5)},
39 {nil, uint64(5)},
40 {nil, float32(5)},
41 {nil, float64(5)},
42 {nil, complex(float32(5), float32(6))},
43 {nil, complex(float64(5), float64(6))},
44 {nil, "a string"},
45 {[]int64{1}, []uint32{1}},
46 {[]int64{1}, []uint64{1}},
47 {[]int64{2}, []bool{true, false}},
48 {[]int64{1}, []float64{1}},
49 {[]int64{1}, [1]float64{1}},
50 {[]int64{1, 1}, [1][1]float64{{1}}},
51 {[]int64{1, 1, 1}, [1][1][]float64{{{1}}}},
52 {[]int64{1, 1, 2}, [1][][2]float64{{{1, 2}}}},
53 {[]int64{1, 1, 1, 1}, [1][][1][]float64{{{{1}}}}},
54 {[]int64{2}, []string{"string", "slice"}},
55 {[]int64{2}, [2]string{"string", "array"}},
56 {[]int64{3, 2}, [][]float64{{1, 2}, {3, 4}, {5, 6}}},
57 {[]int64{2, 3}, [2][3]float64{{1, 2, 3}, {3, 4, 6}}},
58 {[]int64{4, 3, 2}, [][][]float64{
59 {{1, 2}, {3, 4}, {5, 6}},
60 {{7, 8}, {9, 10}, {11, 12}},
61 {{0, -1}, {-2, -3}, {-4, -5}},
62 {{-6, -7}, {-8, -9}, {-10, -11}},
63 }},
64 {[]int64{2, 0}, [][]int64{{}, {}}},
65 {[]int64{2, 2}, [][]string{{"row0col0", "row0,col1"}, {"row1col0", "row1,col1"}}},
66 {[]int64{2, 3}, [2][3]string{
67 {"row0col0", "row0,col1", "row0,col2"},
68 {"row1col0", "row1,col1", "row1,col2"},
69 }},
70 }
71
72 var errorTests = []interface{}{
73 struct{ a int }{5},
74 new(int32),
75 new([]int32),
76 // native ints not supported
77 int(5),
78 []int{5},
79 // Mismatched dimensions
80 [][]float32{{1, 2, 3}, {4}},
81 // Mismatched dimensions. Should return "mismatched slice lengths" error instead of "BUG"
82 [][][]float32{{{1, 2}, {3, 4}}, {{1}, {3}}},
83 // Mismatched dimensions. Should return error instead of valid tensor

Callers

nothing calls this directly

Calls 7

ShapeMethod · 0.95
ValueMethod · 0.95
int64Function · 0.85
complexFunction · 0.85
NewTensorFunction · 0.85
TypeOfMethod · 0.80
KindMethod · 0.45

Tested by

no test coverage detected