Skip to content

scheduling: bug in fuse transformation #355

Closed
@rohany

Description

@rohany

The following test fails due to undefined variables causing the compilation process to error:

TEST(scheduling, fuseBug) {
    Tensor<double> A("A", {4, 4}, {Dense, Dense});
    Tensor<double> B("B", {4, 4}, {Dense, Dense});
    Tensor<double> C("C", {4, 4}, {Dense, Dense});
    IndexVar i("i"), j("j"), f("f");
    C(i, j) = A(i, j) * B(i, j);
    auto stmt = C.getAssignment().concretize();
    C.compile(stmt.fuse(i, j, f));
}

The generated code looks like:

int compute(taco_tensor_t *A, taco_tensor_t *B, taco_tensor_t *C) {
  int A1_dimension = (int)(A->dimensions[0]);
  int A2_dimension = (int)(A->dimensions[1]);
  double* restrict A_vals = (double*)(A->vals);
  double* restrict B_vals = (double*)(B->vals);
  int C1_dimension = (int)(C->dimensions[0]);
  int C2_dimension = (int)(C->dimensions[1]);
  double* restrict C_vals = (double*)(C->vals);

  for (int32_t f = 0; f < (C1_dimension * C2_dimension); f++) {
    int32_t i = f / C2_dimension;
    if (i >= C1_dimension)
      continue;

    int32_t j = f % C2_dimension;
    if (j >= C2_dimension)
      continue;

    int32_t jA = i * A2_dimension + j;
    A_vals[jA] = B_vals[jB] * C_vals[jC];
  }
  return 0;
}

The jB and jC variables are undefined and probably should be replaced with i and j.

Metadata

Metadata

Assignees

No one assigned

    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