disabled_tensor_map.mlir 1.6 KB
Newer Older
Y
Yan Chunwei 已提交
1
// CHECK-LABEL: @predict
2 3 4
func @predict(%input:!infrt.dense_tensor<CPU, FP32, NCHW>, %map: !infrt.dense_tensor_map) -> (!infrt.dense_tensor<CPU, FP32, NCHW>) {
  %w = dt.get_param(%map, "create_parameter_0.w_0") -> !infrt.dense_tensor<CPU, FP32, NCHW>
  %bias = dt.get_param(%map, "create_parameter_1.w_0") -> !infrt.dense_tensor<CPU, FP32, NCHW>
Y
Yan Chunwei 已提交
5

6
  %out = dt.create_uninit_tensor.f32 [3, 3] -> !infrt.dense_tensor<CPU, FP32, NCHW>
Y
Yan Chunwei 已提交
7 8

  // fc
9 10 11 12
  "external.matmul"(%input, %w, %out) {}: (!infrt.dense_tensor<CPU, FP32, NCHW>, !infrt.dense_tensor<CPU, FP32, NCHW>, !infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
  "external.elementwise_add"(%out, %bias, %out) {axis = -1}: (!infrt.dense_tensor<CPU, FP32, NCHW>, !infrt.dense_tensor<CPU, FP32, NCHW>, !infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
  "external.sigmoid"(%out, %out) {}: (!infrt.dense_tensor<CPU, FP32, NCHW>, !infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
  //dt.print_tensor (%out : !infrt.dense_tensor<CPU, FP32, NCHW>)
Y
Yan Chunwei 已提交
13

14
  infrt.return %out : !infrt.dense_tensor<CPU, FP32, NCHW>
Y
Yan Chunwei 已提交
15 16 17 18
}

// CHECK-LABEL: @main
func @main() {
19 20
  %input = dt.create_uninit_tensor.f32 [3, 3] -> !infrt.dense_tensor<CPU, FP32, NCHW>
  dt.fill_tensor_with_constant.f32 (%input : !infrt.dense_tensor<CPU, FP32, NCHW>) {value=1.0:f32}
Y
Yan Chunwei 已提交
21 22

  // CHECK-LABEL: loading params
23
  %map = dt.load_params() {path="/Infrt/build/paddle/paddle_1.8_fc_model"}
Y
Yan Chunwei 已提交
24

25 26
  %out = infrt.call @predict(%input, %map): (!infrt.dense_tensor<CPU, FP32, NCHW>, !infrt.dense_tensor_map) -> (!infrt.dense_tensor<CPU, FP32, NCHW>)
  dt.print_tensor (%out : !infrt.dense_tensor<CPU, FP32, NCHW>)
Y
Yan Chunwei 已提交
27

28
  infrt.return
Y
Yan Chunwei 已提交
29 30
}