-
Notifications
You must be signed in to change notification settings - Fork 699
Implement a new tensorview instruction #158
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I am glad to see this land. I have a few comments about missing docs and one question. Thank you.
@@ -70,7 +70,10 @@ struct IRGenVisitor : NodeWalker { | |||
} | |||
assert(!generatedNodeDest_.count(N) && | |||
"Already generated code for this node"); | |||
assert(isa<AllocActivationInst>(v) && "The value must be an activation"); | |||
auto *dest = v; | |||
if (auto *zn = dyn_cast<ZeroInst>(v)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -59,6 +59,10 @@ class IRBuilder { | |||
|
|||
ReshapeInst *createReshapeOp(Value *input, llvm::ArrayRef<size_t> shape); | |||
|
|||
TensorViewInst *createTensorView(ElemKind elemKind, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -70,6 +70,24 @@ Tensor *Interpreter::getOrCreateTensor(const Value *v) { | |||
return it->second; | |||
} | |||
|
|||
Tensor *Interpreter::getOrCreateUnownedTensor(const Value *v, | |||
const Value *src) { | |||
assert(llvm::isa<TensorViewInst>(v) && "Expected a tensor view"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -60,6 +60,7 @@ class Interpreter final : public Backend { | |||
/// tensor is already allocated for \p v. | |||
/// \returns a tensor for \p v. | |||
Tensor *getOrCreateTensor(const Value *v); | |||
Tensor *getOrCreateUnownedTensor(const Value *v, const Value *src); | |||
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
auto odim = flattenCdr(outW.dims()); | ||
auto idim = flattenCdr(inW.dims()); | ||
assert(odim.first == idim.first && "Mismatch batch size"); | ||
// outW and inW are 2-dimensional. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
assert(inW.dims().size() == 2); | ||
assert(inG.dims().size() == 2); | ||
|
||
// outG and inW are 2-dimensional. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
src/glow/IR/IRGen.cpp
Outdated
Value *InGview = InG; | ||
if (InGview->dims().size() != 2) { | ||
auto idim = flattenCdr(InG->dims()); | ||
builder_.createZeroInst("zero", InG); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
auto idim = flattenCdr(inW.dims()); | ||
assert(odim.first == idim.first && "Mismatch batch size"); | ||
// outW and inW are 2-dimensional. | ||
// Dimensions are batch size x activation. Weights are Y x Z. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This instruction is used to create an unowned tensor with a required dimensionality from an existing tensor. The result is just a view of an existing tensor and does not allocate any new memory. Tensorview is essentially a typecast applied to a tensor.
This instruction is used to create an unowned tensor with a required dimensionality from an existing tensor. The result is just a view of an existing tensor and does not allocate any new memory. Tensorview is essentially a typecast applied to a tensor.