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

Tensor implementation progress (still no compile) #127

Merged
merged 17 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Merge remote-tracking branch 'upstream/master' into ragged_pr
  • Loading branch information
danpovey committed Sep 8, 2020
commit ffb3bba1028a1498eb69001f8770b53385d44977
3 changes: 0 additions & 3 deletions k2/csrc/dtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ struct DtypeOf<uint64_t> {
static const Dtype dtype = kUint64Dtype;
};

#define FOR_DTYPES(


/*
Evaluates Expr for TypeName being all dtypes. E.g.
FOR_ALL_DTYPES(t.GetDtype(), T, SomeFuncCall<T>(a,b,c..));
Expand Down
30 changes: 1 addition & 29 deletions k2/csrc/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Tensor {
// Tensor with one fewer axis.
Tensor Index(int32_t axis, int32_t index) const;


// Assignment is shallow.
Tensor &operator =(const Tensor &other) { impl_ = other.impl_; }

Expand Down Expand Up @@ -172,35 +173,6 @@ class Tensor {
Tensor To(ContextPtr ctx);


Dtype GetDtype() const { return impl_->dtype; }
const Shape &GetShape() const { return impl_->shape; }
int32_t ByteOffset() const { return impl_->bytes_offset; }
std::shared_ptr<Region> &GetRegion() { return impl_->data; }

// Forward some funtions from the shape. Will forward more later.
inline bool SameDim(const Tensor &other) const { return other->impl_.shape.SameDim(shape); }
inline bool NumAxes() const { return impl_->shape.NumAxes(); }
inline int32_t Dim(int32_t i) { return impl_->shape.Dim(i); }


/*
Convert to possibly-different context, may require CPU/GPU transfer.
The returned value may share the same underlying `data` memory as *this.
This should work even for tensors with empty data.

If dim_ == 0 and region_ is NULL, this will return a direct copy of *this
(i.e. with region_ also NULL)

If dim == 0 and region_ is non-NULL, it will return a copy of *this with an
empty region with the supplied context (if different from current region's
context).

Note: the answer will always be contiguous, i.e. there is a possibility that
it will have a different memory layout than the input. [Internally it will
call `Contiguous()`.
*/
Tensor To(ContextPtr ctx);

ContextPtr GetContext() { return impl_->data->context; }

private:
Expand Down
1 change: 1 addition & 0 deletions k2/csrc/tensor_ops.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// See ../../LICENSE for clarification regarding multiple authors


#include "k2/csrc/tensor_ops.h"

namespace k2 {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.