tensor_map.mlir.in 1.3 KB
Newer Older
1 2 3
// RUN: infrtexec -i %s | FileCheck %s

func @load_tensor_map() {
4
  %map = dt.load_params(){path="@CMAKE_BINARY_DIR@/multi_fc_model"}
5
  %size = dt.tensor_map_get_size(%map) -> i32
6
  infrt.print.i32 %size
7

8
  %a = dt.tensor_map_get_tensor(%map) {name="fc_bias"} -> !infrt.dense_tensor<CPU, FP32, NCHW>
9 10

  // CHECK: tensor: shape=shape[2], values=[0, 0]
11
  dt.print_tensor (%a : !infrt.dense_tensor<CPU, FP32, NCHW>)
12

13
  infrt.return
14
}
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

func @load_phi_tensor_map() {
  %map = phi_dt.load_params(){path="@CMAKE_BINARY_DIR@/multi_fc_model"}
  %size = phi_dt.tensor_map_get_size(%map) -> i32
  infrt.print.i32 %size

  %a = phi_dt.tensor_map_get_tensor(%map) {name="fc_bias"} -> !infrt.dense_tensor<CPU, FP32, NCHW>

  // CHECK: dense_tensor: shape=shape[2], value=[0,0]
  phi_dt.print_tensor (%a : !infrt.dense_tensor<CPU, FP32, NCHW>)

  infrt.return
}

func @load_combined_phi_tensor_map() {
  %map = phi_dt.load_combined_params(){model_path="@CMAKE_BINARY_DIR@/multi_fc_model/fc.pdmodel",
    params_path="@CMAKE_BINARY_DIR@/multi_fc_model/fc.pdiparams"}
  %size = phi_dt.tensor_map_get_size(%map) -> i32
  infrt.print.i32 %size

  %a = phi_dt.tensor_map_get_tensor(%map) {name="fc_bias"} -> !infrt.dense_tensor<CPU, FP32, NCHW>

  // CHECK: dense_tensor: shape=shape[2], value=[0,0]
  phi_dt.print_tensor (%a : !infrt.dense_tensor<CPU, FP32, NCHW>)

  infrt.return
}