github.com/wzzhu/tensor@v0.9.24/api_reduction.go (about) 1 package tensor 2 3 import "github.com/pkg/errors" 4 5 // Sum sums a Tensor along the given axes 6 func Sum(t Tensor, along ...int) (retVal Tensor, err error) { 7 if sumer, ok := t.Engine().(Sumer); ok { 8 return sumer.Sum(t, along...) 9 } 10 return nil, errors.New("Engine does not support Sum()") 11 } 12 13 // Argmax finds the index of the max value along the axis provided 14 func Argmax(t Tensor, axis int) (retVal Tensor, err error) { 15 if argmaxer, ok := t.Engine().(Argmaxer); ok { 16 return argmaxer.Argmax(t, axis) 17 } 18 return nil, errors.New("Engine does not support Argmax()") 19 } 20 21 // Argmin finds the index of the min value along the axis provided 22 func Argmin(t Tensor, axis int) (retVal Tensor, err error) { 23 if argminer, ok := t.Engine().(Argminer); ok { 24 return argminer.Argmin(t, axis) 25 } 26 return nil, errors.New("Engine does not support Argmax()") 27 }