improved ts.Format() info

This commit is contained in:
sugarme 2022-04-28 17:39:46 +10:00
parent ce421dd4c5
commit 7e4799eb52
2 changed files with 5 additions and 1 deletions

View File

@ -319,13 +319,15 @@ func (ts *Tensor) Format(s fmt.State, verb rune) {
strides := shapeToStrides(shape)
device := ts.MustDevice()
dtype := ts.DType().String()
defined := ts.MustDefined()
if verb == 'i' {
fmt.Fprintf(
s,
"\nTENSOR META:\n\tShape:\t\t%v\n\tDType:\t\t%v\n\tDevice:\t\t%v\n",
"\nTENSOR INFO:\n\tShape:\t\t%v\n\tDType:\t\t%v\n\tDevice:\t\t%v\n\tDefined:\t%v\n",
shape,
dtype,
device,
defined,
)
return
}

View File

@ -15,5 +15,7 @@ func TestTensor_Format(t *testing.T) {
x := ts.MustArange(ts.IntScalar(numels), gotch.Float, gotch.CPU).MustView(shape, true)
fmt.Printf("%0.1f", x) // print truncated data
fmt.Printf("%i", x) // print truncated data
// fmt.Printf("%#0.1f", x) // print full data
}