Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
pi
Commits
c630a7a7
Commit
c630a7a7
authored
6 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
1731b762
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
TensorFlow/tf1pi.html
+34
-0
34 additions, 0 deletions
TensorFlow/tf1pi.html
TensorFlow/tf2pi.html
+53
-0
53 additions, 0 deletions
TensorFlow/tf2pi.html
with
87 additions
and
0 deletions
TensorFlow/tf1pi.html
0 → 100644
+
34
−
0
View file @
c630a7a7
<html>
<body>
<script
src=
tf.min.js
></script>
<script>
//
// tfpi.html
// Neil Gershenfeld 11/18/18
// Nikhil Thorat 11/20/18
// TensorFlow.js pi calculation benchmark
// pi = 3.14159265358979323846
//
const
points
=
1
e7
const
a
=
tf
.
scalar
(
0.5
)
const
b
=
tf
.
scalar
(
0.75
)
const
c
=
tf
.
scalar
(
0.25
)
function
f
()
{
const
index
=
tf
.
range
(
1
,
points
)
return
tf
.
sum
(
tf
.
div
(
a
,
tf
.
mul
(
index
.
sub
(
b
),
index
.
sub
(
c
)))).
dataSync
();
}
// Warmup
f
();
const
tstart
=
performance
.
now
()
/
1000
const
sum
=
f
();
const
tend
=
performance
.
now
()
/
1000
const
mflops
=
points
*
5.0
*
1
e
-
6
/
(
tend
-
tstart
);
document
.
write
(
'
pi:
'
+
sum
.
toString
())
document
.
write
(
'
<br>
'
)
document
.
write
(
'
time:
'
+
(
tend
-
tstart
)
+
'
s
'
)
document
.
write
(
'
<br>
'
)
document
.
write
(
'
estimated MFlops:
'
+
mflops
)
</script>
This diff is collapsed.
Click to expand it.
TensorFlow/tf2pi.html
0 → 100644
+
53
−
0
View file @
c630a7a7
<html>
<body>
<script
src=
tf.min.js
></script>
<script>
//
// tfpi.html
// Neil Gershenfeld 11/18/18
// Nikhil Thorat 11/20/18
// TensorFlow.js pi calculation benchmark
// pi = 3.14159265358979323846
//
const
points
=
1
e7
const
a
=
tf
.
scalar
(
0.5
)
const
b
=
tf
.
scalar
(
0.75
)
const
c
=
tf
.
scalar
(
0.25
)
const
indexSubProgram
=
{
variableNames
:
[
'
X
'
],
outputShape
:
[
points
],
userCode
:
`
void main() {
float x = getX();
int i = getOutputCoords();
float value = float(i) - x;
setOutput(value);
}
`
}
function
indexSub
(
x
)
{
return
tf
.
ENV
.
backend
.
compileAndRun
(
indexSubProgram
,
[
x
]);
}
function
f
(
index
)
{
// const index = tf.range(1,points)
return
tf
.
sum
(
tf
.
div
(
a
,
tf
.
mul
(
indexSub
(
b
),
indexSub
(
c
)))).
dataSync
();
}
// Warmup
f
()
const
tstart
=
performance
.
now
()
/
1000
//const sum = tf.range(1,points)
const
sum
=
f
()
//const sum = f();
const
tend
=
performance
.
now
()
/
1000
const
mflops
=
points
*
5.0
*
1
e
-
6
/
(
tend
-
tstart
);
document
.
write
(
'
pi:
'
+
sum
.
toString
())
document
.
write
(
'
<br>
'
)
document
.
write
(
'
time:
'
+
(
tend
-
tstart
)
+
'
s
'
)
document
.
write
(
'
<br>
'
)
document
.
write
(
'
estimated MFlops:
'
+
mflops
)
</script>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment