2020-09-17 08:31:40 +08:00
|
|
|
// RUN: npcomp-opt -split-input-file -lower-constant-tensors-to-memref <%s | FileCheck %s
|
2020-07-11 08:31:24 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: module {
|
|
|
|
// We check the debug name too since we put some effort into making that readable.
|
|
|
|
// The name isn't load-bearing though.
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
// CHECK: refback.global @__constant_3x4xf32 dense<7.000000e+00> : tensor<3x4xf32>
|
2020-07-11 08:31:24 +08:00
|
|
|
// CHECK: func @basic
|
|
|
|
func @basic() -> tensor<3x4xf32> {
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
// CHECK: %[[MEMREF:.*]] = refback.get_global_memref @__constant_3x4xf32 : memref<3x4xf32>
|
2020-10-15 10:28:43 +08:00
|
|
|
// CHECK: %[[TENSOR:.*]] = tensor_load %[[MEMREF]]
|
2020-07-11 08:31:24 +08:00
|
|
|
%0 = constant dense<7.0> : tensor<3x4xf32>
|
|
|
|
// CHECK: return %[[TENSOR]]
|
|
|
|
return %0 : tensor<3x4xf32>
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: }
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// CHECK-LABEL: module {
|
|
|
|
|
|
|
|
// Only one global is created.
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
// CHECK: refback.global
|
|
|
|
// CHECK-NOT: refback.global
|
2020-07-11 08:31:24 +08:00
|
|
|
func @duplicate_constants() -> (tensor<3x4xf32>, tensor<3x4xf32>) {
|
|
|
|
%0 = constant dense<7.0> : tensor<3x4xf32>
|
|
|
|
%1 = constant dense<7.0> : tensor<3x4xf32>
|
|
|
|
// CHECK: return %[[TENSOR]]
|
|
|
|
return %0, %1 : tensor<3x4xf32>, tensor<3x4xf32>
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: }
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// CHECK-LABEL: module {
|
|
|
|
|
|
|
|
// Two globals are created.
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
// CHECK: refback.global
|
|
|
|
// CHECK: refback.global
|
|
|
|
// CHECK-NOT: refback.global
|
2020-07-11 08:31:24 +08:00
|
|
|
func @multiple_constants() -> (tensor<3x4xf32>, tensor<3x4xf32>) {
|
|
|
|
%0 = constant dense<7.0> : tensor<3x4xf32>
|
|
|
|
%1 = constant dense<8.0> : tensor<3x4xf32>
|
|
|
|
// CHECK: return %[[TENSOR]]
|
|
|
|
return %0, %1 : tensor<3x4xf32>, tensor<3x4xf32>
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: }
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// CHECK-LABEL: module {
|
|
|
|
// We don't convert non-tensor globals.
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
// CHECK-NOT: refback.global
|
2020-07-11 08:31:24 +08:00
|
|
|
func @non_tensor() {
|
|
|
|
%0 = constant 7 : i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-17 08:31:40 +08:00
|
|
|
// CHECK: }
|