Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
face
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
face
Commits
29644fad
Commit
29644fad
authored
Jun 07, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove TensorArray implementation
parent
c493d1fd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
57 deletions
+0
-57
TensorArray.ts
src/tfcpatches/TensorArray.ts
+0
-57
No files found.
src/tfcpatches/TensorArray.ts
deleted
100644 → 0
View file @
c493d1fd
import
*
as
tf
from
'@tensorflow/tfjs-core'
;
export
class
TensorArray
{
private
_tensors
:
tf
.
Tensor
[]
constructor
(
size
:
number
,
private
_dtype
:
tf
.
DataType
|
null
=
null
,
private
_elementShape
:
number
[]
|
null
=
null
,
private
_dynamicSize
:
boolean
=
false
,
private
_clearAfterRead
:
boolean
=
true
,
private
_identicalElementShapes
:
boolean
=
false
,
private
_tensorArrayName
:
string
=
''
)
{
this
.
_tensors
=
size
?
Array
(
size
).
fill
(
0
).
map
(
_
=>
tf
.
scalar
(
0
))
:
[]
}
public
scatter
(
indices
:
tf
.
Tensor1D
,
value
:
tf
.
Tensor
,
unusedFlow
:
tf
.
Scalar
):
tf
.
Scalar
{
this
.
expectValidSize
(
'scatter'
,
indices
)
if
(
indices
.
shape
.
length
!==
1
)
{
throw
new
Error
(
`scatter - expected rank of indices (
${
indices
.
shape
.
length
}
) to be 1`
)
}
if
(
indices
.
shape
[
0
]
!==
value
.
shape
[
0
])
{
throw
new
Error
(
`scatter - expected indices.shape[0] (
${
indices
.
shape
[
0
]}
) to equal value.shape[0] (
${
value
.
shape
[
0
]}
)`
)
}
const
unstacked
=
tf
.
unstack
(
value
,
0
)
Array
.
from
(
indices
.
dataSync
()).
forEach
((
idx
,
i
)
=>
{
(
this
.
_tensors
as
tf
.
Tensor
[])[
idx
]
=
unstacked
[
i
]
})
const
unusedFlowOut
=
tf
.
scalar
(
0
)
return
unusedFlowOut
}
public
gather
(
indices
:
tf
.
Tensor1D
,
unusedFlow
:
tf
.
Scalar
,
dtype
?:
tf
.
DataType
,
elementShape
?:
number
[])
:
tf
.
Tensor
{
this
.
expectValidSize
(
'gather'
,
indices
)
const
tensors
=
Array
.
from
(
indices
.
dataSync
()).
map
(
idx
=>
this
.
_tensors
[
idx
])
return
tf
.
concat
(
tensors
)
}
public
size
(
unusedFlow
?:
tf
.
Scalar
)
{
return
this
.
_tensors
.
length
}
private
expectValidSize
(
methodName
:
string
,
indices
:
tf
.
Tensor1D
)
{
if
(
!
this
.
_tensors
)
{
throw
new
Error
(
'scatter - TensorArray is not initialized'
)
}
if
(
indices
.
shape
[
0
]
>
this
.
_tensors
.
length
)
{
throw
new
Error
(
`
${
methodName
}
- expected indices.shape[0] (
${
indices
.
shape
[
0
]}
) to be >= this.size() (
${
this
.
size
()}
)`
)
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment