|
| 1 | +module TT |
| 2 | + |
| 3 | +using Reactant: Reactant |
| 4 | +using Scratch: @get_scratch! |
| 5 | +using Downloads |
| 6 | + |
| 7 | +const tt_pjrt_plugin_dir = Ref{Union{Nothing,String}}(nothing) |
| 8 | + |
| 9 | +function __init__() |
| 10 | + @static if Sys.islinux() |
| 11 | + Reactant.precompiling() || setup_tt_pjrt_plugin!() |
| 12 | + end |
| 13 | +end |
| 14 | + |
| 15 | +has_tt() = true |
| 16 | + |
| 17 | +function setup_tt_pjrt_plugin!() |
| 18 | + path_from_env = get(ENV, "TT_LIBRARY_PATH", nothing) |
| 19 | + if path_from_env !== nothing && ispath(path_from_env) |
| 20 | + tt_pjrt_plugin_dir[] = path_from_env |
| 21 | + else |
| 22 | + tt_pjrt_plugin_dir[] = @get_scratch!("pjrt_tt_plugin") |
| 23 | + end |
| 24 | + # download_tt_pjrt_plugin_if_needed(tt_pjrt_plugin_dir[]) |
| 25 | + return nothing |
| 26 | +end |
| 27 | + |
| 28 | +get_tt_pjrt_plugin_dir() = tt_pjrt_plugin_dir[] |
| 29 | + |
| 30 | +function get_tt_pjrt_plugin_path() |
| 31 | + return joinpath(get_tt_pjrt_plugin_dir(), "pjrt_plugin_tt.so") |
| 32 | +end |
| 33 | + |
| 34 | +# function download_tt_pjrt_plugin_if_needed(path=nothing) |
| 35 | +# path === nothing && (path = get_tt_pjrt_plugin_dir()) |
| 36 | +# @assert path !== nothing "tt_pjrt_plugin_dir is not set!" |
| 37 | + |
| 38 | +# tt_pjrt_plugin_path = joinpath(path, "pjrt_plugin_tt_14.dylib") |
| 39 | +# if !isfile(tt_pjrt_plugin_path) |
| 40 | +# zip_file_path = joinpath(path, "pjrt-plugin-tt.zip") |
| 41 | +# tmp_dir = joinpath(path, "tmp") |
| 42 | +# Downloads.download( |
| 43 | +# if Sys.ARCH === :aarch64 |
| 44 | +# "https://files.pythonhosted.org/packages/09/dc/6d8fbfc29d902251cf333414cf7dcfaf4b252a9920c881354584ed36270d/jax_tt-0.1.1-py3-none-macosx_13_0_arm64.whl" |
| 45 | +# elseif Sys.ARCH === :x86_64 |
| 46 | +# "https://files.pythonhosted.org/packages/87/ec/9bb7f7f0ffd06c3fb89813126b2f698636ac7a4263ed7bdd1ff7d7c94f8f/jax_tt-0.1.1-py3-none-macosx_10_14_x86_64.whl" |
| 47 | +# else |
| 48 | +# error("Unsupported architecture: $(Sys.ARCH)") |
| 49 | +# end, |
| 50 | +# zip_file_path, |
| 51 | +# ) |
| 52 | +# run(`unzip -qq $(zip_file_path) -d $(tmp_dir)`) |
| 53 | +# mv( |
| 54 | +# joinpath(tmp_dir, "jax_plugins", "tt_plugin", "pjrt_plugin_tt_14.dylib"), |
| 55 | +# tt_pjrt_plugin_path, |
| 56 | +# ) |
| 57 | +# rm(tmp_dir; recursive=true) |
| 58 | +# rm(zip_file_path; recursive=true) |
| 59 | +# end |
| 60 | +# end |
| 61 | + |
| 62 | +end # module TT |
0 commit comments