Commit 25fd50be by huchi

fixed a bug in XList

parent 913e2251
...@@ -97,8 +97,6 @@ void TensorListBase<T>::Add(T&& item) ...@@ -97,8 +97,6 @@ void TensorListBase<T>::Add(T&& item)
else else
newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1)); newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1));
memcpy(newItems, items, sizeof(T) * maxNum); memcpy(newItems, items, sizeof(T) * maxNum);
if (mem == NULL)
delete[] items;
items = newItems; items = newItems;
maxNum = maxNum * 2 + 1; maxNum = maxNum * 2 + 1;
} }
...@@ -120,8 +118,6 @@ void TensorListBase<T>::Add(const T& item) ...@@ -120,8 +118,6 @@ void TensorListBase<T>::Add(const T& item)
else else
newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1)); newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1));
memcpy(newItems, items, sizeof(T) * maxNum); memcpy(newItems, items, sizeof(T) * maxNum);
if (mem == NULL)
delete[] items;
items = newItems; items = newItems;
maxNum = maxNum * 2 + 1; maxNum = maxNum * 2 + 1;
} }
...@@ -145,8 +141,6 @@ void TensorListBase<T>::Add(T* inputItems, int inputItemCount) ...@@ -145,8 +141,6 @@ void TensorListBase<T>::Add(T* inputItems, int inputItemCount)
else else
newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * newMaxNum); newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * newMaxNum);
memcpy(newItems, items, sizeof(T) * maxNum); memcpy(newItems, items, sizeof(T) * maxNum);
if (mem == NULL)
delete[] items;
items = newItems; items = newItems;
maxNum = newMaxNum; maxNum = newMaxNum;
} }
...@@ -179,8 +173,6 @@ void TensorListBase<T>::Insert(int pos, const T& item) ...@@ -179,8 +173,6 @@ void TensorListBase<T>::Insert(int pos, const T& item)
else else
newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1)); newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1));
memcpy(newItems, items, sizeof(T) * maxNum); memcpy(newItems, items, sizeof(T) * maxNum);
if (mem == NULL)
delete[] items;
items = newItems; items = newItems;
maxNum = maxNum * 2 + 1; maxNum = maxNum * 2 + 1;
} }
...@@ -201,8 +193,6 @@ void TensorListBase<T>::Insert(int pos, T&& item) ...@@ -201,8 +193,6 @@ void TensorListBase<T>::Insert(int pos, T&& item)
else else
newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1)); newItems = (T*)mem->Alloc(mem->devID, sizeof(T) * (maxNum * 2 + 1));
memcpy(newItems, items, sizeof(T) * maxNum); memcpy(newItems, items, sizeof(T) * maxNum);
if (mem == NULL)
delete[] items;
items = newItems; items = newItems;
maxNum = maxNum * 2 + 1; maxNum = maxNum * 2 + 1;
} }
...@@ -260,7 +250,6 @@ inline int TensorListBase<T>::FindFirst(const T& item) ...@@ -260,7 +250,6 @@ inline int TensorListBase<T>::FindFirst(const T& item)
template <typename T> template <typename T>
void TensorListBase<T>::Clear() void TensorListBase<T>::Clear()
{ {
delete[] items;
count = 0; count = 0;
} }
......
...@@ -82,7 +82,6 @@ public: ...@@ -82,7 +82,6 @@ public:
/* maps tokens to integers */ /* maps tokens to integers */
vector<int> Token2ID(vector<string> tokens); vector<int> Token2ID(vector<string> tokens);
/* constructor */ /* constructor */
/* load the vocabulary from a file */ /* load the vocabulary from a file */
explicit Vocabulary(const char* vocabPath); explicit Vocabulary(const char* vocabPath);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论