-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add StorageSize() in tensor #104
Conversation
Conflicts: k2/csrc/cuda/context.cu k2/csrc/cuda/tensor.cu k2/csrc/cuda/tensor.h k2/csrc/cuda/tensor_test.cu
@@ -42,7 +42,7 @@ class CpuContext : public Context { | |||
class CudaContext : public Context { | |||
public: | |||
CudaContext(int gpu_id) : gpu_id_(gpu_id) { | |||
if (gpu_id_ != 1) { | |||
if (gpu_id_ != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems some merge before breaks CudaContext
, fixed now.
@@ -98,9 +111,9 @@ TensorPtr Tensor::Index(int32_t axis, int32_t index) const { | |||
} | |||
|
|||
void Tensor::Init(ContextPtr c) { | |||
int32_t nelement = shape_.Nelement(); | |||
int32_t storage_size = shape_.StorageSize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As tensor
may be not contiguous, we need to use StorageSize()
instead of Nelement()
to allocate memory.
Thanks! |
No description provided.