chore: remove unused lock

add-tracing
Meng Zhang 2023-05-26 00:06:08 -07:00
parent 364cbf8ee0
commit c296b83de9
1 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ mod ffi {
} }
} }
#[derive(Builder)] #[derive(Builder, Debug)]
pub struct TextInferenceEngineCreateOptions { pub struct TextInferenceEngineCreateOptions {
model_path: String, model_path: String,
@ -54,7 +54,7 @@ pub struct TextInferenceOptions {
} }
pub struct TextInferenceEngine { pub struct TextInferenceEngine {
engine: Mutex<cxx::UniquePtr<ffi::TextInferenceEngine>>, engine: cxx::UniquePtr<ffi::TextInferenceEngine>,
tokenizer: Tokenizer, tokenizer: Tokenizer,
} }
@ -70,14 +70,14 @@ impl TextInferenceEngine {
options.num_replicas_per_device, options.num_replicas_per_device,
); );
return TextInferenceEngine { return TextInferenceEngine {
engine: Mutex::new(engine), engine: engine,
tokenizer: Tokenizer::from_file(&options.tokenizer_path).unwrap(), tokenizer: Tokenizer::from_file(&options.tokenizer_path).unwrap(),
}; };
} }
pub fn inference(&self, prompt: &str, options: TextInferenceOptions) -> String { pub fn inference(&self, prompt: &str, options: TextInferenceOptions) -> String {
let encoding = self.tokenizer.encode(prompt, true).unwrap(); let encoding = self.tokenizer.encode(prompt, true).unwrap();
let output_tokens = self.engine.lock().unwrap().inference( let output_tokens = self.engine.inference(
encoding.get_tokens(), encoding.get_tokens(),
options.max_decoding_length, options.max_decoding_length,
options.sampling_temperature, options.sampling_temperature,