I didn’t get the same undefine behavior using g++. But I guess
Maybe you missed the usage of template version of data_ptr:
output.data_ptr<float>()
The output.data_ptr() returns a void pointer, and sometimes memcpy btwn pointers with different types has undefined behavior