8000 better tostring · dotnet/TorchSharp@2fb57a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fb57a0

Browse files
committed
better tostring
1 parent 95a00da commit 2fb57a0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/TorchSharp/Tensor/Tensor 8000 .cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6519,15 +6519,16 @@ public string ToString(TensorStringStyle style,
65196519
CultureInfo? cultureInfo = null,
65206520
string? newLine = null)
65216521
{
6522-
var w = width.HasValue ? width.Value : torch.lineWidth;
6523-
var nl = newLine is null ? torch.newLine : newLine;
6524-
var fmt = fltFormat is null ? torch.floatFormat : fltFormat;
6522+
var w = width ?? torch.lineWidth;
6523+
var nl = newLine ?? torch.newLine;
6524+
var fmt = fltFormat ?? torch.floatFormat;
65256525

6526-
if (device_type == DeviceType.META)
6527-
return ToMetadataString();
6526+
if (style is TensorStringStyle.Default)
6527+
style = torch.TensorStringStyle;
6528+
if (device_type is DeviceType.META)
6529+
style = TensorStringStyle.Metadata;
65286530

65296531
return style switch {
6530-
TensorStringStyle.Default => ToString(torch.TensorStringStyle, fltFormat, width, cultureInfo, nl),
65316532
TensorStringStyle.Metadata => ToMetadataString(),
65326533
TensorStringStyle.Julia => ToJuliaString(fmt, w, cultureInfo, nl),
65336534
TensorStringStyle.Numpy => ToNumpyString(this, ndim, true, fmt, cultureInfo, nl),

0 commit comments

Comments
 (0)
0