Skip to content
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

Merged
merged 8 commits into from
Sep 1, 2020
Merged

Conversation

qindazhu
Copy link
Collaborator

@qindazhu qindazhu commented Sep 1, 2020

No description provided.

@@ -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) {
Copy link
Collaborator Author

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();
Copy link
Collaborator Author

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.

@danpovey
Copy link
Collaborator

danpovey commented Sep 1, 2020

Thanks!

@danpovey danpovey merged commit d6d947e into k2-fsa:cuda_draft Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants