Skip to content

Instantly share code, notes, and snippets.

@annanay25
Last active July 3, 2017 07:45
Show Gist options
  • Save annanay25/1940f591f7f09527510ba551a47a53c1 to your computer and use it in GitHub Desktop.
Save annanay25/1940f591f7f09527510ba551a47a53c1 to your computer and use it in GitHub Desktop.
Multiply every element of a [1,784] matrix by a constant (float 5.0)
; ModuleID = '__compute_module'
source_filename = "__compute_module"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux_gnu"
define void @"cluster_2[_XlaCompiledKernel=true,_XlaNumConstantArgs=0].v5"(i8* align 16 dereferenceable(3136) %retval, i8* noalias %run_options, i8** noalias %params, i8** noalias %temps, i64* noalias %prof_counters) {
entry:
%invar_address.dim.1 = alloca i64
%invar_address.dim.0 = alloca i64
%0 = getelementptr inbounds i8*, i8** %params, i64 0
%1 = load i8*, i8** %0, !tbaa !0, !dereferenceable !3, !align !4
%2 = bitcast i8* %1 to [1 x [784 x float]]*
%3 = getelementptr inbounds i8*, i8** %params, i64 1
%4 = load i8*, i8** %3, !tbaa !5, !dereferenceable !7, !align !8
%5 = bitcast i8* %4 to float*
%6 = bitcast i8* %retval to [1 x [784 x float]]*
store i64 0, i64* %invar_address.dim.0
br label %loop_header.dim.0
loop_header.dim.0: ; preds = %loop_exit.dim.1, %entry
%indvar.dim.0 = load i64, i64* %invar_address.dim.0
%7 = icmp uge i64 %indvar.dim.0, 1
br i1 %7, label %loop_exit.dim.0, label %loop_body.dim.0
loop_body.dim.0: ; preds = %loop_header.dim.0
store i64 0, i64* %invar_address.dim.1
br label %loop_header.dim.1
loop_header.dim.1: ; preds = %loop_body.dim.1, %loop_body.dim.0
%indvar.dim.1 = load i64, i64* %invar_address.dim.1
%8 = icmp uge i64 %indvar.dim.1, 784
br i1 %8, label %loop_exit.dim.1, label %loop_body.dim.1
loop_body.dim.1: ; preds = %loop_header.dim.1
%9 = getelementptr inbounds [1 x [784 x float]], [1 x [784 x float]]* %2, i64 0, i64 0, i64 %indvar.dim.1
%10 = load float, float* %9, !tbaa !9, !invariant.load !11, !noalias !12
%11 = load float, float* %5, !tbaa !15, !invariant.load !11, !noalias !12
%12 = fmul fast float %10, %11
%13 = getelementptr inbounds [1 x [784 x float]], [1 x [784 x float]]* %6, i64 0, i64 0, i64 %indvar.dim.1
store float %12, float* %13, !tbaa !9, !alias.scope !12
%invar.inc1 = add nuw nsw i64 %indvar.dim.1, 1
store i64 %invar.inc1, i64* %invar_address.dim.1
br label %loop_header.dim.1
loop_exit.dim.1: ; preds = %loop_header.dim.1
%invar.inc = add nuw nsw i64 %indvar.dim.0, 1
store i64 %invar.inc, i64* %invar_address.dim.0
br label %loop_header.dim.0
loop_exit.dim.0: ; preds = %loop_header.dim.0
%prof_counter_computation = getelementptr i64, i64* %prof_counters, i64 0
ret void
}
!0 = !{!1, !1, i64 0}
!1 = !{!"pointer-to element_type: F32 dimensions: 1 dimensions: 784 layout { minor_to_major: 1 minor_to_major: 0 }", !2}
!2 = !{!"XLA TBAA"}
!3 = !{i64 3136}
!4 = !{i64 16}
!5 = !{!6, !6, i64 0}
!6 = !{!"pointer-to element_type: F32", !2}
!7 = !{i64 4}
!8 = !{i64 8}
!9 = !{!10, !10, i64 0}
!10 = !{!"element_type: F32 dimensions: 1 dimensions: 784 layout { minor_to_major: 1 minor_to_major: 0 }", !2}
!11 = !{}
!12 = !{!13}
!13 = !{!"buffer: 1", !14}
!14 = distinct !{!14}
!15 = !{!16, !16, i64 0}
!16 = !{!"element_type: F32", !2}
@annanay25
Copy link
Author

HLO

2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52] HloModule cluster_2[_XlaCompiledKernel=true,_XlaNumConstantArgs=0]_module:
2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52] 
2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52] ENTRY cluster_2[_XlaCompiledKernel=true,_XlaNumConstantArgs=0].v5 (arg0: f32[1,784], arg1: f32[]) -> f32[1,784] { 
2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52]   %arg0 = f32[1,784]{1,0} parameter()
2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52]   %arg1 = f32[] parameter()
2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52]   %multiply = f32[1,784]{1,0} multiply(f32[1,784]{1,0} %arg0, f32[] %arg1)
2017-07-03 07:10:27: I tensorflow/compiler/xla/service/hlo_pass_pipeline.cc:52] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment