MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / RegisterTensors

Method RegisterTensors

oneflow/api/cpp/framework/graph.cpp:421–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421of::Maybe<void> Graph::GraphImpl::RegisterTensors(const std::vector<Tensor>& inputs) {
422 {
423 std::vector<std::string> input_op_names(inputs.size());
424 std::vector<std::shared_ptr<of::one::Tensor>> input_tensors(inputs.size());
425 for (const auto& input_info : input_infos_) {
426 size_t index = input_info.second.input_output_index_;
427 input_op_names[index] = input_info.first;
428 input_tensors[index] = inputs.at(index).tensor_;
429 }
430 JUST(graph_->RegisterInputOpNamesAndTensors(input_op_names, input_tensors));
431 }
432 {
433 const auto& pair = Unzip(output_name_to_tensor_);
434 const std::vector<std::string>& output_op_names = pair.first;
435 const std::vector<std::shared_ptr<of::one::Tensor>>& output_tensors = pair.second;
436 JUST(graph_->RegisterOutputOpNamesAndTensors(output_op_names, output_tensors));
437 output_tensor_tuple_ = ConvertToTensorTuple(output_tensors);
438 }
439 {
440 const auto& t = of::DumpVariableTensorMgr();
441 const std::vector<std::string>& variable_op_names = std::get<0>(t);
442 const std::vector<std::shared_ptr<of::one::Tensor>>& variable_tensors = std::get<1>(t);
443 JUST(graph_->RegisterVariableOpNamesAndTensors(variable_op_names, variable_tensors));
444 parameter_tensor_tuple_ = ConvertToTensorTuple(variable_tensors);
445 }
446 return of::Maybe<void>::Ok();
447}
448
449Graph::GraphImpl::~GraphImpl() { of::vm::ClusterSync().GetOrThrow(); }
450

Callers

nothing calls this directly

Calls 8

UnzipFunction · 0.85
ConvertToTensorTupleFunction · 0.85
DumpVariableTensorMgrFunction · 0.85
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected