I have an MPSGraph* graph and I would like to print it to see the graph as built in MPS. Is there a way to do it?
I have an MPSGraph* graph and I would like to print it to see the graph as built in MPS. Is there a way to do it?
There is an undocumented dump method that will work:
[graph dump];
It will produce output that looks like:
module {
func @main() {
%0 = "mps.placeholder"() : () -> tensor<3x1xf32>
%1 = "mps.placeholder"() : () -> tensor<1xi32>
%2 = "mps.placeholder"() : () -> tensor<1xi32>
%3 = "mps.placeholder"() : () -> tensor<1xi32>
%4 = "mps.constant"() {value = dense<[3, 1]> : tensor<2xi32>} : () -> tensor<2xi32>
%5 = "mps.constant"() {value = dense<-1> : tensor<i32>} : () -> tensor<i32>
%6 = "mps.get_coordinates"(%4, %5) : (tensor<2xi32>, tensor<i32>) -> tensor<3x1xi32>
%7 = "mps.multiply"(%6, %3) : (tensor<3x1xi32>, tensor<1xi32>) -> tensor<3x1xi32>
%8 = "mps.constant"() {value = dense<-2> : tensor<i32>} : () -> tensor<i32>
%9 = "mps.get_coordinates"(%4, %8) : (tensor<2xi32>, tensor<i32>) -> tensor<3x1xi32>
%10 = "mps.multiply"(%9, %2) : (tensor<3x1xi32>, tensor<1xi32>) -> tensor<3x1xi32>
%11 = "mps.add"(%10, %7) : (tensor<3x1xi32>, tensor<3x1xi32>) -> tensor<3x1xi32>
%12 = "mps.add"(%11, %1) : (tensor<3x1xi32>, tensor<1xi32>) -> tensor<3x1xi32>
%13 = "mps.constant"() {value = dense<-1> : tensor<1xi32>} : () -> tensor<1xi32>
%14 = "mps.reshape"(%0, %13) : (tensor<3x1xf32>, tensor<1xi32>) -> tensor<3xf32>
%15 = "mps.constant"() {value = dense<-1> : tensor<1xi32>} : () -> tensor<1xi32>
%16 = "mps.reshape"(%12, %15) : (tensor<3x1xi32>, tensor<1xi32>) -> tensor<3xi32>
%17 = "mps.constant"() {value = dense<0> : tensor<i32>} : () -> tensor<i32>
%18 = "mps.gather"(%14, %16, %17) {batch_dims = 0 : ui32} : (tensor<3xf32>, tensor<3xi32>, tensor<i32>) -> tensor<3xf32>
%19 = "mps.reshape"(%18, %4) : (tensor<3xf32>, tensor<2xi32>) -> tensor<3x1xf32>
}
}