opencl_kernel_configure.bzl 3.0 KB
Newer Older
1 2 3 4 5 6 7
"""Repository rule for opencl encrypt kernel autoconfiguration, borrow from tensorflow
"""
def _opencl_encrypt_kernel_impl(repository_ctx):
  repository_ctx.template(
      "BUILD",
      Label("//repository/opencl-kernel:BUILD.tpl"))

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  unused_var = repository_ctx.path(Label("//:.git/HEAD"))
  unused_var = repository_ctx.path(Label("//:.git/refs/heads/master"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/activation.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/addn.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/batch_norm.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/bias_add.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/buffer_to_image.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/channel_shuffle.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/common.h"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/concat.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d_1x1.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d_3x3.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/deconv_2d.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/depth_to_space.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/depthwise_conv2d.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/eltwise.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/fully_connected.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/matmul.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/pad.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/pooling.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/reduce_mean.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/resize_bilinear.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/slice.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/softmax.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/space_to_batch.cl"))
  unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/winograd_transform.cl"))

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  mace_root_path = str(repository_ctx.path(Label("@mace//:BUILD")))[:-len("BUILD")]

  generated_files_path = repository_ctx.path("gen")

  python_bin_path = repository_ctx.which("python")

  repository_ctx.execute([
      python_bin_path, '%s/mace/python/tools/encrypt_opencl_codegen.py' % mace_root_path,
      '--cl_kernel_dir=%s/mace/kernels/opencl/cl' % mace_root_path,
      '--output_path=%s/encrypt_opencl_kernel' % generated_files_path
  ], quiet=False)


encrypt_opencl_kernel_repository = repository_rule(
    implementation = _opencl_encrypt_kernel_impl,
)