oneflow
oneflow copied to clipboard
[bug][nn.Graph] flow.full with 0-D Graph proxy tensor as fill_value crashes with "This is a oneflow bug"
Summary
When calling flow.full inside an nn.Graph, if the fill_value comes from indexing (thus a 0-D proxy tensor), OneFlow crashes with a runtime error "This is a oneflow bug…" instead of handling the case gracefully.
This works fine in eager mode but fails in Graph mode.
Code to reproduce bug
import oneflow as flow
import oneflow.nn as nn
class Bug(nn.Module):
def forward(self, x):
v = x[0,0,0,0] # scalar (0-D tensor, proxy in Graph)
return flow.full((7,), v) # BUG: Graph mode crashes here
class G(nn.Graph):
def __init__(self, m):
super().__init__()
self.m = m
def build(self, x):
return self.m(x)
x = flow.randn(1,3,2,2)
g = G(Bug())
g(x) # reproduces "This is a oneflow bug..."
Output
UserWarning: To copy construct from a tensor, use clone().detach() ...
[ERROR](GRAPH:G_0:G) building graph got error.
RuntimeError: Error: RuntimeError : This is a oneflow bug, please submit an issue ...
System Information
- OS: Ubuntu 22.04.4 LTS (x86_64)
- OneFlow version : 1.0.0.dev20250921+cpu
- Python version: 3.10.16