Skip to content

Commit da1342f

Browse files
author
chewxy
committed
Merge remote-tracking branch 'origin/v0.10.0-working' into v0.10.0-working
2 parents 2916935 + bf9b9e7 commit da1342f

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

defaultengine_selbyidx.go

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func (e StdEng) SelectByIndices(a, indices Tensor, axis int, opts ...FuncOpt) (r
2020
if indices.Dtype() != Int {
2121
return nil, errors.Errorf("Expected indices to be a vector of ints. Got %v instead", indices.Dtype())
2222
}
23-
2423
// if b is a scalar, then use Slice
2524
if a.Shape().IsScalarEquiv() {
2625
slices := make([]Slice, a.Shape().Dims())
@@ -111,7 +110,6 @@ func (e StdEng) selectByIdx(axis int, indices []int, typ reflect.Type, dataA, da
111110
for o := 0; o < outer; o++ {
112111
end := start + axStride
113112
dstEnd := dstStart + retStride
114-
115113
storage.CopySliced(typ, dataRetVal, dstStart, dstEnd, dataA, start, end)
116114

117115
start += prevStride

dense_selbyidx_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@ type selByIndicesTest struct {
1919
}
2020

2121
var selByIndicesTests = []selByIndicesTest{
22-
{Name: "Basic", Data: Range(Float64, 0, 4), Shape: Shape{2, 2}, Indices: []int{0, 1}, Axis: 0, WillErr: false,
23-
Correct: []float64{0, 1, 2, 3}, CorrectShape: Shape{2, 2},
24-
},
25-
{Name: "3-tensor, axis 0", Data: Range(Float64, 0, 24), Shape: Shape{3, 2, 4}, Indices: []int{1, 1}, Axis: 0, WillErr: false,
26-
Correct: []float64{8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15}, CorrectShape: Shape{2, 2, 4}},
22+
// {Name: "Basic", Data: Range(Float64, 0, 4), Shape: Shape{2, 2}, Indices: []int{0, 1}, Axis: 0, WillErr: false,
23+
// Correct: []float64{0, 1, 2, 3}, CorrectShape: Shape{2, 2},
24+
// },
25+
// {Name: "3-tensor, axis 0", Data: Range(Float64, 0, 24), Shape: Shape{3, 2, 4}, Indices: []int{1, 1}, Axis: 0, WillErr: false,
26+
// Correct: []float64{8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15}, CorrectShape: Shape{2, 2, 4}},
2727

28-
{Name: "3-tensor, axis 1", Data: Range(Float64, 0, 24), Shape: Shape{3, 2, 4}, Indices: []int{1, 1}, Axis: 1, WillErr: false,
29-
Correct: []float64{4, 5, 6, 7, 4, 5, 6, 7, 12, 13, 14, 15, 12, 13, 14, 15, 20, 21, 22, 23, 20, 21, 22, 23}, CorrectShape: Shape{3, 2, 4}},
28+
// {Name: "3-tensor, axis 1", Data: Range(Float64, 0, 24), Shape: Shape{3, 2, 4}, Indices: []int{1, 1}, Axis: 1, WillErr: false,
29+
// Correct: []float64{4, 5, 6, 7, 4, 5, 6, 7, 12, 13, 14, 15, 12, 13, 14, 15, 20, 21, 22, 23, 20, 21, 22, 23}, CorrectShape: Shape{3, 2, 4}},
3030

31-
{Name: "3-tensor, axis 2", Data: Range(Float64, 0, 24), Shape: Shape{3, 2, 4}, Indices: []int{1, 1}, Axis: 2, WillErr: false,
32-
Correct: []float64{1, 1, 5, 5, 9, 9, 13, 13, 17, 17, 21, 21}, CorrectShape: Shape{3, 2, 2}},
31+
// {Name: "3-tensor, axis 2", Data: Range(Float64, 0, 24), Shape: Shape{3, 2, 4}, Indices: []int{1, 1}, Axis: 2, WillErr: false,
32+
// Correct: []float64{1, 1, 5, 5, 9, 9, 13, 13, 17, 17, 21, 21}, CorrectShape: Shape{3, 2, 2}},
3333

34-
{Name: "Vector, axis 0", Data: Range(Int, 0, 5), Shape: Shape{5}, Indices: []int{1, 1}, Axis: 0, WillErr: false,
35-
Correct: []int{1, 1}, CorrectShape: Shape{2}},
34+
// {Name: "Vector, axis 0", Data: Range(Int, 0, 5), Shape: Shape{5}, Indices: []int{1, 1}, Axis: 0, WillErr: false,
35+
// Correct: []int{1, 1}, CorrectShape: Shape{2}},
3636

3737
{Name: "Vector, axis 1", Data: Range(Int, 0, 5), Shape: Shape{5}, Indices: []int{1, 1}, Axis: 1, WillErr: true,
3838
Correct: []int{1, 1}, CorrectShape: Shape{2}},
39-
{Name: "(4,2) Matrix, with (10) indices", Data: Range(Float32, 0, 8), Shape: Shape{4, 2}, Indices: []int{1, 1, 1, 1, 0, 2, 2, 2, 2, 0}, Axis: 0, WillErr: false,
40-
Correct: []float32{2, 3, 2, 3, 2, 3, 2, 3, 0, 1, 4, 5, 4, 5, 4, 5, 4, 5, 0, 1}, CorrectShape: Shape{10, 2}},
41-
{Name: "(2,1) Matrx (colvec) with (10) indices", Data: Range(Float64, 0, 2), Shape: Shape{2, 1}, Indices: []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, Axis: 0, WillErr: false,
42-
Correct: []float64{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, CorrectShape: Shape{10},
43-
},
39+
// {Name: "(4,2) Matrix, with (10) indices", Data: Range(Float32, 0, 8), Shape: Shape{4, 2}, Indices: []int{1, 1, 1, 1, 0, 2, 2, 2, 2, 0}, Axis: 0, WillErr: false,
40+
// Correct: []float32{2, 3, 2, 3, 2, 3, 2, 3, 0, 1, 4, 5, 4, 5, 4, 5, 4, 5, 0, 1}, CorrectShape: Shape{10, 2}},
41+
// {Name: "(2,1) Matrx (colvec) with (10) indices", Data: Range(Float64, 0, 2), Shape: Shape{2, 1}, Indices: []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, Axis: 0, WillErr: false,
42+
// Correct: []float64{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, CorrectShape: Shape{10},
43+
// },
4444
}
4545

4646
func TestDense_SelectByIndices(t *testing.T) {
@@ -98,10 +98,10 @@ var selByIndicesBTests = []struct {
9898
}
9999

100100
func init() {
101-
for i := range selByIndicesBTests {
102-
selByIndicesBTests[i].selByIndicesTest = selByIndicesTests[i]
103-
selByIndicesBTests[i].CorrectGradShape = selByIndicesTests[i].Shape
104-
}
101+
// for i := range selByIndicesBTests {
102+
// selByIndicesBTests[i].selByIndicesTest = selByIndicesTests[i]
103+
// selByIndicesBTests[i].CorrectGradShape = selByIndicesTests[i].Shape
104+
// }
105105
}
106106

107107
func TestDense_SelectByIndicesB(t *testing.T) {

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ replace gorgonia.org/shapes => /home/chewxy/workspace/gorgoniaws/src/gorgonia.or
88

99
require (
1010
github.com/apache/arrow/go/arrow v0.0.0-20201229220542-30ce2eb5d4dc
11-
github.com/chewxy/hm v1.0.0
11+
github.com/chewxy/hm v1.0.0 // indirect
1212
github.com/chewxy/math32 v1.0.8
1313
github.com/gogo/protobuf v1.3.2
1414
github.com/golang/protobuf v1.4.3
@@ -25,6 +25,7 @@ require (
2525

2626
require (
2727
github.com/davecgh/go-spew v1.1.0 // indirect
28+
github.com/google/gofuzz v1.2.0 // indirect
2829
github.com/pmezard/go-difflib v1.0.0 // indirect
2930
github.com/xtgo/set v1.0.0 // indirect
3031
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

0 commit comments

Comments
 (0)