Skip to content

[pytorch] bug the torch.sum() or tensor.sum() get the result shape is null! #1300

@mullerhai

Description

@mullerhai

HI ,when I want to invoke the sum method to compute sum of tensor , but can not get the correct shape, and the shape is null,I don't know why

system : macos intel
jdk 15 8
scala 2.12.11
pytorch version: 1.13.0-1.5.9-SNAPSHOT

x shape is (500|32 )
val yx = torch.sum(x,new DimnameArrayRef(1)) 
println(s"FeaturesLinear x sum shape ${x.sum().shape().mkString("|")}  two ${x.sum(new DimnameArrayRef(1)).shape().mkString("|")} x shape ${x.shape().mkString("|")} sum yx shape ${yx.shape().mkString("|")}")

in console

FeaturesLinear x sum shape   two  x shape 500|32 sum yx shape 

in old pytorch-javacpp version, I remember the sum maybe can really work, why new version get the bad result ,is DimnameArrayRef class I use it with false operate?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions