| 25 | namespace oneflow { |
| 26 | |
| 27 | Maybe<void> VariableTensorMgr::Set(const std::string& variable_op_name, |
| 28 | const std::shared_ptr<one::Tensor>& variable_tensor, |
| 29 | const Symbol<DType>& dtype) { |
| 30 | if (dtype && variable_tensor->dtype() != dtype) { |
| 31 | LazyMode::Guard guard{false}; |
| 32 | variables_[variable_op_name] = JUST(one::functional::Cast(variable_tensor, dtype, false)); |
| 33 | } else { |
| 34 | variables_[variable_op_name] = variable_tensor; |
| 35 | } |
| 36 | return Maybe<void>::Ok(); |
| 37 | } |
| 38 | |
| 39 | Maybe<one::Tensor> VariableTensorMgr::Get(const std::string& variable_op_name, |
| 40 | const Symbol<DType>& dtype) { |
no test coverage detected