disabled_tensor_map.mlir 1.4 KB
Newer Older
Y
Yan Chunwei 已提交
1
// CHECK-LABEL: @predict
2 3 4
func @predict(%input:!Infrt.tensor<X86, NCHW, F32>, %map: !Infrt.tensor_map) -> (!Infrt.tensor<X86, NCHW, F32>) {
  %w = dt.get_param(%map, "create_parameter_0.w_0") -> !Infrt.tensor<X86, NCHW, F32>
  %bias = dt.get_param(%map, "create_parameter_1.w_0") -> !Infrt.tensor<X86, NCHW, F32>
Y
Yan Chunwei 已提交
5

6
  %out = dt.create_uninit_tensor.f32 [3, 3] -> !Infrt.tensor<X86, NCHW, F32>
Y
Yan Chunwei 已提交
7 8

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

14
  Infrt.return %out : !Infrt.tensor<X86, NCHW, F32>
Y
Yan Chunwei 已提交
15 16 17 18
}

// CHECK-LABEL: @main
func @main() {
19 20
  %input = dt.create_uninit_tensor.f32 [3, 3] -> !Infrt.tensor<X86, NCHW, F32>
  dt.fill_tensor_with_constant.f32 (%input : !Infrt.tensor<X86, NCHW, F32>) {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.tensor<X86, NCHW, F32>, !Infrt.tensor_map) -> (!Infrt.tensor<X86, NCHW, F32>)
  dt.print_tensor (%out : !Infrt.tensor<X86, NCHW, F32>)
Y
Yan Chunwei 已提交
27

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