Skip to content

Split/merge of size-0 slices #366

@jacobhinkle

Description

@jacobhinkle

In a very similar test to that in #365, we hit a different error in FusionKernelRuntime::getKernelConfig.

TEST_F(NVFuserTest, SizeZeroSlice) {
  auto fusion = std::make_unique<Fusion>();
  FusionGuard fg(fusion.get());

  std::vector<int64_t> shape({8});
  auto tv0 = makeContigConcreteTensor(shape);
  fusion->addInput(tv0);

  auto tv1 = slice(
      tv0,
      {{IrBuilder::create<Int>(0),
        IrBuilder::create<Int>(2),
        IrBuilder::create<Int>(1)}});
  auto tv2 = slice(
      tv0,
      {{IrBuilder::create<Int>(2),
        IrBuilder::create<Int>(4),
        IrBuilder::create<Int>(1)}});
  auto tv3 = slice(
      tv0,
      {{IrBuilder::create<Int>(4),
        IrBuilder::create<Int>(6),
        IrBuilder::create<Int>(1)}});
  auto tv4 = slice(
      tv0,
      {{IrBuilder::create<Int>(6),
        IrBuilder::create<Int>(6),
        IrBuilder::create<Int>(1)}});
  auto tv5 = slice(
      tv0,
      {{IrBuilder::create<Int>(6),
        IrBuilder::create<Int>(6),
        IrBuilder::create<Int>(1)}});
  auto tv6 = slice(
      tv0,
      {{IrBuilder::create<Int>(6),
        IrBuilder::create<Int>(8),
        IrBuilder::create<Int>(1)}});
  fusion->addOutput(tv1);
  fusion->addOutput(tv2);
  fusion->addOutput(tv3);
  fusion->addOutput(tv4);
  fusion->addOutput(tv5);
  fusion->addOutput(tv6);

  auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0);
  at::manual_seed(0);

  auto t0 = at::randn(shape, options);
  std::vector<c10::IValue> aten_inputs({t0});

  FusionExecutorCache executor_cache(std::move(fusion));
  executor_cache.runFusionWithInputs(aten_inputs);
}

The error is

[E thread_pool.cpp:109] Exception in thread pool task: Splitting IterDomains with ending values that are 0 is not supported at this time.
Exception raised from split at /opt/pytorch/nvfuser/csrc/ir_nodes.cpp:2333

This happens when we choose a reference tensor that's not empty, but attempt to replay transforms on a size-0 tensor. We probably just need to carefully add size-0 support in IterDomain::split. Note that other incantations also expose this limitation in Merge so they should both be tested.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions