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

Develop lx #33

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion src/Tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,48 @@ class Tensor {
}
}
std::cout << name() << " " << sum / count() << std::endl;
// std::cout << name() << ": shape:[" << batch() << " " << head() << " " << sequence() << " " << dimension() << "] AVG:" << sum / count() << std::endl;
// std::cout << name() << ": shape:[" << num() << " " << channels() << " " << height() << " " << width() << "] AVG:" << sum / count() << std::endl;
}




shared_ptr<Tensor> view(int batch, int head, int sequence, int dimension) {
auto t = std::make_shared<Tensor>();
t->setBackend(backend_);
t->setDtype(dtype_);
t->reshape(batch, head, sequence, dimension);
t->host_ptr_ = host_ptr_;
return t;
}
shared_ptr<Tensor> unfold(int axis, int size, int step) {
CHECK_GE(axis, 0);
CHECK_LT(axis, numAxes());
CHECK_GE(size, 0);
CHECK_GE(step, 0);
CHECK_LE(size, shape(axis));
CHECK_LE(step, shape(axis));
CHECK_EQ(shape(axis) % step, 0);
auto t = std::make_shared<Tensor>();
t->setBackend(backend_);
t->setDtype(dtype_);
vector<int> shape = shape_;
shape[axis] = size;
shape.insert(shape.begin() + axis + 1, shape[axis] / step);
shape[axis + 1] = step;
t->reshape(shape);
t->host_ptr_ = host_ptr_;
return t;
}

//
// void setByteWidth(int bw) {
// byte_width_ = bw;
// }
// TODO:Name?



template <class Dtype>
void fullData(Dtype value) {
for (int n = 0; n < batch(); ++n) {
Expand Down
1 change: 1 addition & 0 deletions src/backends/cpu/CPUKVCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CPUKVCache final : public Op {

private:
bool support_multi_thread_ = false;

int cache_seq_len_= -999;
bool isK_;

Expand Down
Loading