Vengineerの妄想(準備期間)

人生は短いけど、長いです。人生を楽しみましょう!

Glow、その3


Windows subsystem for Linuxにて、GLOWをビルドしてみた。

準備、

  cmake : Ubuntu 16.04のcmakeは、3.5.xだった。3.7以上を要求されたので、3.11.2をソースコードからビルドし、
          /usr/local/bin にインストールした

  ソースコードを解凍して、

  % ./bootstrap

  を実行したら、Cursesライブラリが無いと怒られたので、

  % sudo apt-get install ncurses-dev

  でインストール。

ビルド

README.md に従って、
なお、OpenCLをサポートしていないときは、
CMakeLists.txtのoption(GLOW_WITH_OPENCL "Build the OpenCL backend" ON)コメントアウト
  % git submodule update --init --recursive
  % sudo apt-get install graphviz clang cmake wget ninja-build llvm-5.0 libprotobuf-dev protobuf-compiler

  % mkdir build_Debug
  % cd build_Debug
  % cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ..
  % ninja all

テストプログラムの実行

  % cd tests
  % ./backendTest[==========] Running 4 tests from 3 test cases.
  [----------] Global test environment set-up.
  [----------] 2 tests from Interpreter
  [ RUN      ] Interpreter.NotImplementedSave
  ../lib/Backends/Backends.cpp:58: Saving a bundle is not supported by the backend
  [       OK ] Interpreter.NotImplementedSave (13 ms)
  [ RUN      ] Interpreter.profileQuantizationForANetwork
  [       OK ] Interpreter.profileQuantizationForANetwork (3 ms)
  [----------] 2 tests from Interpreter (16 ms total)

  [----------] 1 test from Interpreter/BackendTest
  [ RUN      ] Interpreter/BackendTest.simpleInference/0
  print1: %input = WeightVar float<1 x 32 x 32 x 3> mutable
  shape: ( 1 32 32 3 )
  [ Zero tensor ]

  [       OK ] Interpreter/BackendTest.simpleInference/0 (760 ms)
  [----------] 1 test from Interpreter/BackendTest (760 ms total)

  [----------] 1 test from JIT/BackendTest
  [ RUN      ] JIT/BackendTest.simpleInference/0
  [       OK ] JIT/BackendTest.simpleInference/0 (473 ms)
  [----------] 1 test from JIT/BackendTest (473 ms total)

  [----------] Global test environment tear-down
  [==========] 4 tests from 3 test cases ran. (1252 ms total)
  [  PASSED  ] 4 tests.

2 tests from Interpreterにあるように、Interpreterのテストが2つ。
1つ目。
引用
TEST(Interpreter, NotImplementedSave) {
  // Interpreter backend does not support a save method.
  // Exercise it and make sure that it fails.
  ExecutionEngine EE;
  auto &mod = EE.getModule();

  // Create a few nodes to make sure IR can be normally generated.
  Function *F = mod.createFunction("main");
  F->createSave("save", mod.createVariable(ElemKind::FloatTy, {2}, "A",
                                           VisibilityKind::Public,
                                           Variable::TrainKind::None));

  EXPECT_DEATH(EE.save(CompilationMode::Infer, F, "output"), "");
}

  [ RUN      ] Interpreter.NotImplementedSave
  ../lib/Backends/Backends.cpp:58: Saving a bundle is not supported by the backend

とワーニングを出している。どうやら、saveメソッドないでエラーが発生している。
void Backend::save(llvm::StringRef outputDir) {
  GLOW_UNREACHABLE("Saving a bundle is not supported by the backend");
}

他の2つのテストはエラー無しで、実行できています。
  [----------] 1 test from Interpreter/BackendTest
  [ RUN      ] Interpreter/BackendTest.simpleInference/0
  print1: %input = WeightVar float<1 x 32 x 32 x 3> mutable
  shape: ( 1 32 32 3 )
  [ Zero tensor ]
  [       OK ] Interpreter/BackendTest.simpleInference/0 (760 ms)
  [----------] 1 test from Interpreter/BackendTest (760 ms total)

  [----------] 1 test from JIT/BackendTest
  [ RUN      ] JIT/BackendTest.simpleInference/0
  [       OK ] JIT/BackendTest.simpleInference/0 (473 ms)
  [----------] 1 test from JIT/BackendTest (473 ms total)