MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Initialize

Method Initialize

tensorflow/lite/delegates/gpu/cl/api.cc:545–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543 graph_(std::move(graph)) {}
544
545 Status Initialize() {
546 // Select precision based on given options.
547 CalculationsPrecision precision = CalculationsPrecision::F32;
548 if (options_.allow_precision_loss) {
549 precision = options_.priority == InferencePriority::MAX_PRECISION
550 ? CalculationsPrecision::F32_F16
551 : CalculationsPrecision::F16;
552 }
553
554 // Increase precision if not supported.
555 if (!environment_->IsSupported(precision)) {
556 precision = CalculationsPrecision::F32_F16;
557 if (!environment_->IsSupported(precision)) {
558 precision = CalculationsPrecision::F32;
559 }
560 }
561
562 context_ = absl::make_unique<InferenceContext>();
563 InferenceContext::CreateInferenceInfo create_info;
564 create_info.precision = precision;
565 create_info.storage_type = GetOptimalStorageType(environment_->device());
566 create_info.hints.Add(ModelHints::kReduceKernelsCount);
567 // TODO(sorokin) temporary hack to speed up init time in some cases.
568 // TODO(sorokin): move this check to the place where hint is applied.
569 if ((precision == CalculationsPrecision::F16 ||
570 precision == CalculationsPrecision::F32_F16) &&
571 create_info.storage_type == TensorStorageType::TEXTURE_ARRAY &&
572 environment_->device().IsAdreno6xxOrHigher()) {
573 create_info.hints.Add(ModelHints::kFastTuning);
574 }
575 RETURN_IF_ERROR(
576 context_->InitFromGraph(create_info, *graph_, environment_));
577
578 if (env_options_.IsGlAware()) {
579 gl_interop_fabric_ = absl::make_unique<GlInteropFabric>(
580 env_options_.egl_display, environment_);
581 }
582 tie_factory_ = absl::make_unique<TensorTieFactory>(
583 environment_, context_.get(), gl_interop_fabric_.get());
584
585 inputs_ = LinkTensors(graph_->inputs());
586 outputs_ = LinkTensors(graph_->outputs());
587 return OkStatus();
588 }
589
590 std::vector<TensorObjectDef> inputs() const override {
591 return GetExternalDefinitions(inputs_);

Callers

nothing calls this directly

Calls 11

GetOptimalStorageTypeFunction · 0.85
OkStatusFunction · 0.85
IsAdreno6xxOrHigherMethod · 0.80
IsGlAwareMethod · 0.80
IsSupportedMethod · 0.45
deviceMethod · 0.45
AddMethod · 0.45
InitFromGraphMethod · 0.45
getMethod · 0.45
inputsMethod · 0.45
outputsMethod · 0.45

Tested by

no test coverage detected