<commit_before>// Copyright 2018 Intel Corporation.

#include <gtest/gtest.h>

#include "testing/matchers.h"
#include "tile/codegen/schedule/deps.h"
#include "tile/stripe/stripe.h"
#include "tile/stripe/stripe.pb.h"

namespace gp = google::protobuf;

using ::testing::EqualsProto;

namespace vertexai {
namespace tile {
namespace codegen {
namespace schedule {

TEST(DepsTest, SmallDepMix) {
  stripe::proto::Block input_proto;
  gp::TextFormat::ParseFromString(R"(
    location { unit { } }
    refs {
      location { unit { } }
      into: "b1"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    refs {
      location { unit { } }
      into: "b2"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    stmts { load { from:"b1" into:"$1" } }
    stmts { store { from:"$1" into:"b2" } }
    stmts { load { from:"b2" into:"$2" } deps: 0}
    stmts { constant { name:"$3" iconst: 0 } }
    stmts { intrinsic { name:"ADD" inputs:"$2" inputs:"$3" outputs:"$4"} }
    stmts { special { name:"COPY" inputs:"b1" outputs:"b2"} }
    stmts { store { from:"$4" into:"b2"} }
  )",
                                  &input_proto);

  std::shared_ptr<stripe::Block> block{stripe::FromProto(input_proto)};

  ComputeDepsForTree(block.get());

  stripe::proto::Block output_proto{IntoProto(*block)};

  EXPECT_THAT(output_proto, EqualsProto(R"proto(
    location { unit { } }
    refs {
      location { unit { } }
      into: "b1"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    refs {
      location { unit { } }
      into: "b2"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    stmts { load { from:"b1" into:"$1" } }
    stmts { store { from:"$1" into:"b2" } deps: 0 }
    stmts { load { from:"b2" into:"$2" } deps: 1}
    stmts { constant { name:"$3" iconst: 0 } }
    stmts { intrinsic { name:"ADD" inputs:"$2" inputs:"$3" outputs:"$4"} deps: 2 deps: 3}
    stmts { special { name:"COPY" inputs:"b1" outputs:"b2"} deps: 2}
    stmts { store { from:"$4" into:"b2"} deps: 4 deps: 5}
  )proto"));
}

}  // namespace schedule
}  // namespace codegen
}  // namespace tile
}  // namespace vertexai
<commit_msg>Separate raw literal use<commit_after>// Copyright 2018 Intel Corporation.

#include <gtest/gtest.h>

#include "testing/matchers.h"
#include "tile/codegen/schedule/deps.h"
#include "tile/stripe/stripe.h"
#include "tile/stripe/stripe.pb.h"

namespace gp = google::protobuf;

using ::testing::EqualsProto;

namespace vertexai {
namespace tile {
namespace codegen {
namespace schedule {

TEST(DepsTest, SmallDepMix) {
  stripe::proto::Block input_proto;
  gp::TextFormat::ParseFromString(R"(
    location { unit { } }
    refs {
      location { unit { } }
      into: "b1"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    refs {
      location { unit { } }
      into: "b2"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    stmts { load { from:"b1" into:"$1" } }
    stmts { store { from:"$1" into:"b2" } }
    stmts { load { from:"b2" into:"$2" } deps: 0}
    stmts { constant { name:"$3" iconst: 0 } }
    stmts { intrinsic { name:"ADD" inputs:"$2" inputs:"$3" outputs:"$4"} }
    stmts { special { name:"COPY" inputs:"b1" outputs:"b2"} }
    stmts { store { from:"$4" into:"b2"} }
  )",
                                  &input_proto);

  std::shared_ptr<stripe::Block> block{stripe::FromProto(input_proto)};

  ComputeDepsForTree(block.get());

  stripe::proto::Block output_proto{IntoProto(*block)};

  const char* expected = R"(
    location { unit { } }
    refs {
      location { unit { } }
      into: "b1"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    refs {
      location { unit { } }
      into: "b2"
      shape {
        type: FLOAT32
        dimensions: {size:1 stride:1}
      }
    }
    stmts { load { from:"b1" into:"$1" } }
    stmts { store { from:"$1" into:"b2" } deps: 0 }
    stmts { load { from:"b2" into:"$2" } deps: 1}
    stmts { constant { name:"$3" iconst: 0 } }
    stmts { intrinsic { name:"ADD" inputs:"$2" inputs:"$3" outputs:"$4"} deps: 2 deps: 3}
    stmts { special { name:"COPY" inputs:"b1" outputs:"b2"} deps: 2}
    stmts { store { from:"$4" into:"b2"} deps: 4 deps: 5}
  )";

  EXPECT_THAT(output_proto, EqualsProto(expected));
}

}  // namespace schedule
}  // namespace codegen
}  // namespace tile
}  // namespace vertexai

{'fraction_non_alphanumeric': 0.16604518534766396, 'fraction_numerical': 0.02719894713753016, 'mean_word_length': 2.6018957345971563, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5431166', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1672, 'n_words': 362}