You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code crashes when negative values are given as arguments to oneflow's rand/zeros/ones functions for generating tensors.
Code to reproduce bug
rand:
import oneflow
oneflow.rand(-1) # crash
output:
terminate called after throwing an instance of 'oneflow::Exception'
what(): Check failed: (-1 >= 0): elem_cnt must be non-negative, but got -1
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in vm::ThreadCtx::TryReceiveAndRun()
File "liboneflow.so", line <unknown>, in vm::EpStreamPolicyBase::Run(vm::Instruction*) const
File "liboneflow.so", line <unknown>, in vm::Instruction::Compute()
File "liboneflow.so", line <unknown>, in vm::OpCallInstructionPolicy::Compute(vm::Instruction*)
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in vm::OpCallInstructionUtil::Compute(vm::OpCallInstructionPolicy*, vm::Stream*, bool, bool)
File "liboneflow.so", line <unknown>, in StatefulOpKernel::Compute(eager::CallContext*, ep::Stream*, user_op::OpKernel const*, user_op::OpKernelState*, user_op::OpKernelCache const*) const
File "liboneflow.so", line <unknown>, in
File "oneflow/user/kernels/distributions/uniform_distribution.cpp", line 40, in operator()
CHECK_GE_OR_THROW(elem_cnt, 0)
Error Type: oneflow.ErrorProto.check_failed_error
Stack trace (most recent call last) in thread 123483:
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c8217ac249, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c8217ab847, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c8217a7368, in vm::ThreadCtx::TryReceiveAndRun()
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c82173e818, in vm::EpStreamPolicyBase::Run(vm::Instruction*) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c821742be6, in vm::Instruction::Compute()
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c821748d2a, in vm::OpCallInstructionPolicy::Compute(vm::Instruction*)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c8217484af, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c82174dd90, in vm::OpCallInstructionUtil::Compute(vm::OpCallInstructionPolicy*, vm::Stream*, bool, bool)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c8225072d0, in StatefulOpKernel::Compute(eager::CallContext*, ep::Stream*, user_op::OpKernel const*, user_op::OpKernelState*, user_op::OpKernelCache const*) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c821c59633, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c821c37a81, in UniformDistribution<(DeviceType)1, float>::operator()(ep::Stream*, long, float*, std::shared_ptr<Generator> const&) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c821c3411e, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x70c81db48190, in
Aborted (Signal sent by tkill() 123243 0)
Aborted (core dumped)
zeros:
import oneflow
oneflow.zeros(-1) # crash
output:
terminate called after throwing an instance of 'oneflow::Exception'
what(): Check failed: (-1 >= 0):
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in vm::ThreadCtx::TryReceiveAndRun()
File "liboneflow.so", line <unknown>, in vm::EpStreamPolicyBase::Run(vm::Instruction*) const
File "liboneflow.so", line <unknown>, in vm::Instruction::Compute()
File "liboneflow.so", line <unknown>, in vm::OpCallInstructionPolicy::Compute(vm::Instruction*)
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in vm::OpCallInstructionUtil::Compute(vm::OpCallInstructionPolicy*, vm::Stream*, bool, bool)
File "liboneflow.so", line <unknown>, in StatefulOpKernel::Compute(eager::CallContext*, ep::Stream*, user_op::OpKernel const*, user_op::OpKernelState*, user_op::OpKernelCache const*) const
File "oneflow/user/kernels/constant_kernel.cpp", line 47, in Compute
CHECK_GE_OR_THROW(elem_cnt, 0)
Error Type: oneflow.ErrorProto.check_failed_error
Stack trace (most recent call last) in thread 123934:
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e30ac249, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e30ab847, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e30a7368, in vm::ThreadCtx::TryReceiveAndRun()
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e303e818, in vm::EpStreamPolicyBase::Run(vm::Instruction*) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e3042be6, in vm::Instruction::Compute()
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e3048d2a, in vm::OpCallInstructionPolicy::Compute(vm::Instruction*)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e30484af, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e304dd90, in vm::OpCallInstructionUtil::Compute(vm::OpCallInstructionPolicy*, vm::Stream*, bool, bool)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e3e07589, in StatefulOpKernel::Compute(eager::CallContext*, ep::Stream*, user_op::OpKernel const*, user_op::OpKernelState*, user_op::OpKernelCache const*) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e33db793, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02e06c5c32, in details::Throw::operator=(Error&&)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7c02df448190, in
Aborted (Signal sent by tkill() 123694 0)
Aborted (core dumped)
ones:
import oneflow
oneflow.ones (-1) # crash
output:
terminate called after throwing an instance of 'oneflow::Exception'
what(): Check failed: (-1 >= 0):
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in vm::ThreadCtx::TryReceiveAndRun()
File "liboneflow.so", line <unknown>, in vm::EpStreamPolicyBase::Run(vm::Instruction*) const
File "liboneflow.so", line <unknown>, in vm::Instruction::Compute()
File "liboneflow.so", line <unknown>, in vm::OpCallInstructionPolicy::Compute(vm::Instruction*)
File "liboneflow.so", line <unknown>, in
File "liboneflow.so", line <unknown>, in vm::OpCallInstructionUtil::Compute(vm::OpCallInstructionPolicy*, vm::Stream*, bool, bool)
File "liboneflow.so", line <unknown>, in StatefulOpKernel::Compute(eager::CallContext*, ep::Stream*, user_op::OpKernel const*, user_op::OpKernelState*, user_op::OpKernelCache const*) const
File "oneflow/user/kernels/constant_kernel.cpp", line 47, in Compute
CHECK_GE_OR_THROW(elem_cnt, 0)
Error Type: oneflow.ErrorProto.check_failed_error
Stack trace (most recent call last) in thread 124264:
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daafc249, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daafb847, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daaf7368, in vm::ThreadCtx::TryReceiveAndRun()
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daa8e818, in vm::EpStreamPolicyBase::Run(vm::Instruction*) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daa92be6, in vm::Instruction::Compute()
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daa98d2a, in vm::OpCallInstructionPolicy::Compute(vm::Instruction*)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daa984af, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541daa9dd90, in vm::OpCallInstructionUtil::Compute(vm::OpCallInstructionPolicy*, vm::Stream*, bool, bool)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541db857589, in StatefulOpKernel::Compute(eager::CallContext*, ep::Stream*, user_op::OpKernel const*, user_op::OpKernelState*, user_op::OpKernelCache const*) const
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541dae2b793, in
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541d8115c32, in details::Throw::operator=(Error&&)
Object "/home/temp/oneflow-1.0.0/build/liboneflow.so", at 0x7541d6e98190, in
Aborted (Signal sent by tkill() 124024 0)
Aborted (core dumped)
System Information
What is your OneFlow installation (pip, source, dockerhub): pip
OS: Ubuntu 22.04.3 LTS
OneFlow version (run python3 -m oneflow --doctor):
Summary
The code crashes when negative values are given as arguments to oneflow's rand/zeros/ones functions for generating tensors.
Code to reproduce bug
rand:
output:
zeros:
output:
ones:
output:
System Information
python3 -m oneflow --doctor
):The text was updated successfully, but these errors were encountered: