Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ce1adon committed Oct 20, 2017
1 parent 15fdc0c commit 62f1e68
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions driver/rnn_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ int RNNDriver<T>::GetandSetData()
outputTensors.push_back(outputTensor);
}

std::array<int, 3> hid_lens = {hid_len[0], in_len[0], hid_len[1]};
std::array<int, 3> hid_lens = {hid_len[0], in_len[0], hid_len[1]};
miopenSetTensorDescriptor(hiddenTensor, miopenFloat, 3, hid_lens.data(), nullptr);

SetRNNDescriptorFromCmdLineArgs();
Expand Down Expand Up @@ -292,42 +292,42 @@ std::vector<int> RNNDriver<T>::GetInputTensorLengthsFromCmdLine()
int in_h = inflags.GetValueInt("in_h");
std::vector<int> in_n(nseq, 0);
std::string batchstr = inflags.GetValueStr("batchsize");
int cont = 0;

for (int i = 0; i < batchstr.length(); i++)
{
if (cont >= nseq)
{
printf("Length of data sequence is longer than required unrolled time sequence "
"provided.\n"
"The data sequence will be truncated to match unrolled time sequence.\n");
break;
}

if (batchstr[i] == ',')
{
if (cont >= 1)
{
if (in_n[cont] > in_n[cont - 1])
{
printf("Incorrect input batch size at time %d\n", cont);
break;
}
}
cont++;
}
else if (batchstr[i] >= '0' && batchstr[i] <= '9')
{
in_n[cont] = in_n[cont] * 10 + stoi(batchstr.substr(i, 1));
}
else
{
printf("illegal input of in_n batch size");
break;
}
}
adjustedSeqLen = nseq;
in_n.push_back(in_h);
int cont = 0;

for(int i = 0; i < batchstr.length(); i++)
{
if(cont >= nseq)
{
printf("Length of data sequence is longer than required unrolled time sequence "
"provided.\n"
"The data sequence will be truncated to match unrolled time sequence.\n");
break;
}

if(batchstr[i] == ',')
{
if(cont >= 1)
{
if(in_n[cont] > in_n[cont - 1])
{
printf("Incorrect input batch size at time %d\n", cont);
break;
}
}
cont++;
}
else if(batchstr[i] >= '0' && batchstr[i] <= '9')
{
in_n[cont] = in_n[cont] * 10 + stoi(batchstr.substr(i, 1));
}
else
{
printf("illegal input of in_n batch size");
break;
}
}
adjustedSeqLen = nseq;
in_n.push_back(in_h);
return in_n;
}

Expand Down Expand Up @@ -488,7 +488,7 @@ std::vector<int> RNNDriver<T>::GetOutputTensorLengthsFromCmdLine() // need remov
template <typename T>
int RNNDriver<T>::AllocateBuffersAndCopy()
{
//int seqLength = inflags.GetValueInt("seq_len");
// int seqLength = inflags.GetValueInt("seq_len");
size_t in_sz = 0;
size_t out_sz = 0;
size_t wei_sz = 0;
Expand All @@ -504,8 +504,10 @@ int RNNDriver<T>::AllocateBuffersAndCopy()
&in_sz); // use c_array to pass vector for all size function
miopenGetRNNInputSuperTensorSize(
GetHandle(), rnnDesc, adjustedSeqLen, outputTensors.data(), &out_sz);
miopenGetRNNHiddenSuperTensorSize(GetHandle(), rnnDesc, adjustedSeqLen, inputTensors.data(), &hy_sz);
miopenGetRNNWorkspaceSize(GetHandle(), rnnDesc, adjustedSeqLen, inputTensors.data(), &workSpaceSize);
miopenGetRNNHiddenSuperTensorSize(
GetHandle(), rnnDesc, adjustedSeqLen, inputTensors.data(), &hy_sz);
miopenGetRNNWorkspaceSize(
GetHandle(), rnnDesc, adjustedSeqLen, inputTensors.data(), &workSpaceSize);
miopenGetRNNTrainingReserveSize(
GetHandle(), rnnDesc, adjustedSeqLen, inputTensors.data(), &reserveSpaceSize);
miopenGetRNNParamsSize(GetHandle(), rnnDesc, inputTensors[0], &params_sz, miopenFloat);
Expand Down Expand Up @@ -749,7 +751,7 @@ int RNNDriver<T>::RunForwardCPU()

bool bidirection, biased;
int layer;

miopenRNNMode_t mode;
miopenRNNAlgo_t algoMode;
miopenRNNInputMode_t inputMode;
Expand Down Expand Up @@ -844,7 +846,7 @@ int RNNDriver<T>::RunForwardCPU()
template <typename T>
int RNNDriver<T>::RunBackwardGPU()
{
int ret = 0;
int ret = 0;

Timer t;
START_TIME;
Expand Down

0 comments on commit 62f1e68

Please sign in to comment.