forked from jiuyuan/InfiniTensor
Chore: move TensorObj::clone to .cc
This commit is contained in:
parent
84f9d6731a
commit
0865f8d823
|
@ -78,25 +78,8 @@ class TensorObj : public TensorBaseObj {
|
|||
void setData(
|
||||
std::function<void(void *, size_t, DataType)> const &generator) const;
|
||||
void setData(const Blob &_blob) { data = _blob; }
|
||||
Tensor clone() const {
|
||||
auto obj = make_ref<TensorObj>(*this);
|
||||
obj->freeData();
|
||||
obj->targets.clear();
|
||||
obj->source.reset();
|
||||
return obj;
|
||||
}
|
||||
Tensor clone(Runtime runtime) const {
|
||||
auto obj = make_ref<TensorObj>(*this);
|
||||
obj->runtime = runtime;
|
||||
obj->freeData();
|
||||
obj->targets.clear();
|
||||
obj->source.reset();
|
||||
if (hasData()) {
|
||||
obj->dataMalloc();
|
||||
obj->copyData(this);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
Tensor clone() const;
|
||||
Tensor clone(Runtime runtime) const;
|
||||
|
||||
void printData() const;
|
||||
bool equalData(const Tensor &rhs, double relativeError = 1e-6) const;
|
||||
|
@ -127,6 +110,12 @@ class TensorObj : public TensorBaseObj {
|
|||
if (i % dimSzVec[j] == 0)
|
||||
builder << "[";
|
||||
|
||||
if (iEnd > 1000 && i > 20 && i < iEnd - 20) {
|
||||
printf("... , ");
|
||||
i = iEnd - 20;
|
||||
continue;
|
||||
}
|
||||
|
||||
builder << ptr[i];
|
||||
for (size_t j = 0; j < numDims; ++j)
|
||||
if ((int)i % dimSzVec[j] == dimSzVec[j] - 1)
|
||||
|
|
|
@ -182,4 +182,26 @@ size_t TensorObj::getOffsetByBroadcastOffset(size_t bcOffset,
|
|||
|
||||
return getOffsetByPos(pos, shape);
|
||||
}
|
||||
|
||||
Tensor TensorObj::clone() const {
|
||||
auto obj = make_ref<TensorObj>(*this);
|
||||
obj->freeData();
|
||||
obj->targets.clear();
|
||||
obj->source.reset();
|
||||
return obj;
|
||||
}
|
||||
|
||||
Tensor TensorObj::clone(Runtime runtime) const {
|
||||
auto obj = make_ref<TensorObj>(*this);
|
||||
obj->runtime = runtime;
|
||||
obj->freeData();
|
||||
obj->targets.clear();
|
||||
obj->source.reset();
|
||||
if (hasData()) {
|
||||
obj->dataMalloc();
|
||||
obj->copyData(this);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
}; // namespace infini
|
||||
|
|
Loading…
Reference in New Issue