Skip to content

Commit

Permalink
handle std::move for uninitialized tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
solomonik committed Aug 9, 2019
1 parent d4aeb2b commit 23180b0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/interface/tensor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1726,8 +1726,15 @@ NORM_INFTY_INST(double)
Tensor<dtype>& Tensor<dtype>::operator=(Tensor<dtype> A){

free_self();
init(A.sr, A.order, A.lens, A.sym, A.wrld, 0, A.name, A.profile, A.is_sparse);
copy_tensor_data(&A);
if (A.order < 0){
this->order = A.order;
if (A.order == -1){
this->sr = A.sr->clone();
}
} else {
init(A.sr, A.order, A.lens, A.sym, A.wrld, 0, A.name, A.profile, A.is_sparse);
copy_tensor_data(&A);
}
return *this;
/*
sr = A.sr;
Expand Down
2 changes: 2 additions & 0 deletions src/tensor/algstrct.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace CTF_int {
};


algstrct::~algstrct(){ }

algstrct::algstrct(int el_size_){
el_size = el_size_;
has_coo_ker = false;
Expand Down
4 changes: 2 additions & 2 deletions src/tensor/algstrct.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace CTF_int {
/**
* \brief destructor
*/
virtual ~algstrct() = 0;
virtual ~algstrct();

/**
* \brief ''copy constructor''
Expand Down Expand Up @@ -447,7 +447,7 @@ namespace CTF_int {

};
//http://stackoverflow.com/questions/630950/pure-virtual-destructor-in-c
inline algstrct::~algstrct(){}
//inline algstrct::~algstrct(){}

/**
* \brief depins keys of n pairs
Expand Down
11 changes: 10 additions & 1 deletion src/tensor/untyped_tensor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ namespace CTF_int {
delete sr;
cdealloc(name);
}
if (order == -1)
if (order == -1){
delete sr;
order = -2;
}
}

tensor::~tensor(){
Expand Down Expand Up @@ -172,6 +174,13 @@ namespace CTF_int {
}

tensor::tensor(tensor const * other, bool copy, bool alloc_data){
if (other->order < 0){
this->order = other->order;
if (other->order == -1){
this->sr = other->sr->clone();
}
return;
}
char * nname = (char*)alloc(strlen(other->name) + 2);
char d[] = "\'";
strcpy(nname, other->name);
Expand Down

0 comments on commit 23180b0

Please sign in to comment.