Program Listing for File interpreter.h

Return to documentation for file (/WorkSpace/CINN/cinn/frontend/interpreter.h)

// Copyright (c) 2021 CINN Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once
#include <absl/container/flat_hash_map.h>

#include <algorithm>
#include <memory>
#include <string>
#include <vector>

#include "cinn/frontend/syntax.h"
#include "cinn/hlir/framework/graph_compiler.h"
#include "cinn/hlir/framework/scope.h"

namespace cinn {
namespace frontend {

class Interpreter final {
 public:
  Interpreter(const std::vector<std::string>& input_names, const std::vector<hlir::framework::shape_t>& input_shapes);

  void LoadPaddleModel(const std::string& model_dir,
                       const Target& target,
                       bool params_combined          = false,
                       const std::string& model_name = "");

  void Run();

  hlir::framework::Tensor GetTensor(const std::string& name);

  std::shared_ptr<hlir::framework::Scope> scope();

  ~Interpreter();

 private:
  class Impl;
  std::unique_ptr<Impl> impl_;
};

}  // namespace frontend
}  // namespace cinn