Skip to content

Commit

Permalink
Fix OperatorTests::insertTensorTest (#3337)
Browse files Browse the repository at this point in the history
Summary:
In OperatorTests::insertTensorTests the insertTensor is getting optimized out because all inputs are constant splats. Changing them to Placeholders not known at compile time fixes this.

Documentation: n/a
Pull Request resolved: #3337

Test Plan: unit tests, added printfs to libjit_insert_tensor to verify that the InsertTensorInst is in the final product.

Differential Revision: D16586565

Pulled By: nickgg

fbshipit-source-id: d7dc82ff6eaaf64d4382f66326b626a892596a56
  • Loading branch information
nickgg authored and facebook-github-bot committed Jul 31, 2019
1 parent df34a13 commit 94d10eb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/unittests/OperatorTest.cpp
Expand Up @@ -6986,18 +6986,17 @@ TEST_P(OperatorTest, SigmoidCrossEntropyWithLogits) {
TEST_P(OperatorTest, insertTensorTest) {
ENABLED_BACKENDS(Interpreter, CPU);

auto SN0Ty = mod_.uniqueType(ElemKind::Int64ITy, {4, 6});
auto SN1Ty = mod_.uniqueType(ElemKind::Int64ITy, {2, 2});

// 0 0 0 0 0 0
// 0 0 0 0 0 0
// 0 0 0 0 0 0
// 0 0 0 0 0 0
Node *SN0 = F_->createSplat("zero", SN0Ty, 0.);
auto *SN0 = mod_.createPlaceholder(ElemKind::Int64ITy, {4, 6}, "SN0", false);
bindings_.allocate(SN0)->init(Tensor::InitKind::Broadcast, 0, mod_.getPRNG());

// 1 1
// 1 1
Node *SN1 = F_->createSplat("one", SN1Ty, 1.);
auto *SN1 = mod_.createPlaceholder(ElemKind::Int64ITy, {2, 2}, "SN1", false);
bindings_.allocate(SN1)->init(Tensor::InitKind::Broadcast, 1, mod_.getPRNG());

// 0 0 0 0 0 0
// 0 1 1 1 1 0
Expand Down

0 comments on commit 94d10eb

Please sign in to comment.