Module: GTE

Defined in:
lib/gte.rb

Defined Under Namespace

Classes: Model

Constant Summary collapse

VERSION =
File.read(File.expand_path('../VERSION', __dir__)).strip

Class Method Summary collapse

Class Method Details

.fetchObject



54
# File 'lib/gte.rb', line 54

def self.fetch(*) = new(*)

.new(dir, threads: 0, optimization: 3, model_name: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gte.rb', line 36

def self.new(dir, threads: 0, optimization: 3, model_name: nil)
  key = [
    File.expand_path(dir),
    Integer(threads),
    Integer(optimization),
    model_name.to_s
  ].freeze

  @model_cache_mutex.synchronize do
    @model_cache[key] ||= Model.new(
      key[0],
      num_threads: key[1],
      optimization_level: key[2],
      model_name: key[3].empty? ? nil : key[3]
    )
  end
end