Skip to content

Commit

Permalink
[JIT] Use is_buffer in BufferPolicy::valid (#49053)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #49053

**Summary**
`BufferPolicy::valid` uses `!typ->is_parameter(i)` to check if an
attribute is a buffer or not; it should use `type->is_buffer(i)` instead.

**Test Plan**
It is difficult to write an additional test that would have failed before this
commit because the two booleans `is_parameter` and `is_buffer` are never set
to `true` at the same time.

**Fixes**
This commit fixes #48746.

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D25434956

Pulled By: SplitInfinity

fbshipit-source-id: ff2229058abbafed0b67d7b26254d406e5f7b074
  • Loading branch information
Meghan Lele authored and facebook-github-bot committed Dec 10, 2020
1 parent c892c3a commit a480ca5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch/csrc/jit/api/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ struct TORCH_API BufferPolicy {
}
static bool valid(const ClassTypePtr& typ, size_t i, const IValue& v) {
return typ->getAttribute(i)->isSubtypeOf(TensorType::get()) &&
!typ->is_parameter(i);
typ->is_buffer(i);
}
static CONSTEXPR_EXCEPT_WIN_CUDA bool all_slots = false;
};
Expand Down

0 comments on commit a480ca5

Please sign in to comment.