MCPcopy Create free account
hub / github.com/cogentcore/core / New

Function New

tensor/tensor.go:168–188  ·  view source on GitHub ↗

New returns a new n-dimensional tensor of given value type with the given sizes per dimension (shape), and optional dimension names.

(sizes []int, names ...string)

Source from the content-addressed store, hash-verified

166// New returns a new n-dimensional tensor of given value type
167// with the given sizes per dimension (shape), and optional dimension names.
168func New[T string | bool | float32 | float64 | int | int32 | byte](sizes []int, names ...string) Tensor {
169 var v T
170 switch any(v).(type) {
171 case string:
172 return NewString(sizes, names...)
173 case bool:
174 return NewBits(sizes, names...)
175 case float64:
176 return NewNumber[float64](sizes, names...)
177 case float32:
178 return NewNumber[float32](sizes, names...)
179 case int:
180 return NewNumber[int](sizes, names...)
181 case int32:
182 return NewNumber[int32](sizes, names...)
183 case byte:
184 return NewNumber[byte](sizes, names...)
185 default:
186 panic("tensor.New: unexpected error: type not supported")
187 }
188}
189
190// NewOfType returns a new n-dimensional tensor of given reflect.Kind type
191// with the given sizes per dimension (shape), and optional dimension names.

Callers

nothing calls this directly

Calls 2

NewStringFunction · 0.85
NewBitsFunction · 0.85

Tested by

no test coverage detected