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

replace SetZero and AddVecToCols with CopyColsFromVec. #3994

Merged
merged 1 commit into from
Mar 11, 2020

Conversation

csukuangfj
Copy link
Contributor

CopyColsFromVec is more efficient to set the initial value of alpha in chain denominator computation.

@danpovey
Copy link
Contributor

tested? I know it should definitely work, just checking.

@csukuangfj
Copy link
Contributor Author

I wrote the following program for testing.

#include "cudamatrix/cu-device.h"
#include "cudamatrix/cu-matrix.h"

int main() {
  using namespace kaldi;

  CuDevice::Instantiate().SelectGpuId("yes");

  CuMatrix<BaseFloat> m(2, 3);
  m.SetZero();

  CuVector<BaseFloat> v(2);
  v(0) = 10;
  v(1) = 20;
  m.CopyColsFromVec(v);

  m.Write(std::cout, false);
  m.SetZero();
  v(0) = 100;
  v(1) = 200;
  m.AddVecToCols(1, v, 0);
  m.Write(std::cout, false);
  return 0;
}

Its output is

LOG ([5.5.1030~1-1ffb8]:SelectGpuId():cu-device.cc:273) CUDA setup operating under Compute Exclusive Mode.
LOG ([5.5.1030~1-1ffb8]:FinalizeActiveGpu():cu-device.cc:358) The active GPU is [0]: TITAN Xp	free:11850M, used:345M, total:12196M, free/total:0.971671 version 6.1
 [
  10 10 10
  20 20 20 ]
 [
  100 100 100
  200 200 200 ]

I am confident that CopyColsFromVec is equivalent to SetZero with AddVecToCols.

@csukuangfj
Copy link
Contributor Author

csukuangfj commented Mar 11, 2020

I also tried with CuSubMatrix

  CuMatrix<BaseFloat> m(2, 3);
  m.SetZero();
  CuSubMatrix<BaseFloat> sub(m, 0, 2, 0, 3);

  CuVector<BaseFloat> v(2);
  v(0) = 10;
  v(1) = 20;
  sub.CopyColsFromVec(v);

  m.Write(std::cout, false);

The output is identical with the above one.

@danpovey danpovey merged commit d74beb9 into kaldi-asr:master Mar 11, 2020
@csukuangfj csukuangfj deleted the fangjun-fix-den branch March 11, 2020 07:13
megazone87 pushed a commit to megazone87/kaldi that referenced this pull request Mar 16, 2020
pc-seawind pushed a commit to pc-seawind/kaldi that referenced this pull request Jun 4, 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