FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/TensorFlowNET.Core/Eager/EagerTensor.cs at master · dmnhwjin/TensorFlow.NET · GitHub
dmnhwjin
/
TensorFlow.NET
Public
forked from
SciSharp/TensorFlow.NET
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
Eager
/
EagerTensor.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (74 loc) · 2.45 KB
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
Eager
/
EagerTensor.cs
Copy path
File metadata and controls
85 lines (74 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using
System
;
using
Tensorflow
.
Util
;
using
static
Tensorflow
.
Binding
;
namespace
Tensorflow
.
Eager
{
public
partial
class
EagerTensor
:
Tensor
{
public
override
SafeTensorHandle
Handle
{
get
{
Resolve
(
)
;
return
_handle
;
}
}
public
override
IntPtr
buffer
{
get
{
Resolve
(
)
;
return
base
.
buffer
;
}
}
public
override
string
Device
=>
c_api
.
StringPiece
(
c_api
.
TFE_TensorHandleDeviceName
(
_eagerTensorHandle
,
tf
.
Status
.
Handle
)
)
;
public
override
TF_DataType
dtype
=>
c_api
.
TFE_TensorHandleDataType
(
_eagerTensorHandle
)
;
public
override
int
rank
=>
c_api
.
TFE_TensorHandleNumDims
(
EagerTensorHandle
,
tf
.
Status
.
Handle
)
;
public
override
ulong
bytesize
{
get
{
Resolve
(
)
;
return
base
.
bytesize
;
}
}
public
override
IntPtr
TensorDataPointer
{
get
{
Resolve
(
)
;
return
base
.
TensorDataPointer
;
}
}
protected
override
Shape
GetShapeInternal
(
)
{
var
dims
=
new
int
[
c_api
.
TFE_TensorHandleNumDims
(
_eagerTensorHandle
,
tf
.
Status
.
Handle
)
]
;
for
(
int
i
=
0
;
i
<
dims
.
Length
;
i
++
)
dims
[
i
]
=
c_api
.
TFE_TensorHandleDim
(
_eagerTensorHandle
,
i
,
tf
.
Status
.
Handle
)
;
return
dims
;
}
protected
override
void
SetShapeInternal
(
Shape
value
)
{
if
(
!
shape
.
is_compatible_with
(
value
)
)
throw
new
ValueError
(
$
"Tensor's shape is not compatible."
)
;
}
public
static
int
GetRank
(
IntPtr
handle
)
{
var
tfe_tensor_handle
=
c_api
.
TFE_EagerTensorHandle
(
handle
)
;
return
c_api
.
TFE_TensorHandleNumDims
(
tfe_tensor_handle
,
tf
.
Status
.
Handle
)
;
}
public
static
int
[
]
GetDims
(
IntPtr
handle
)
{
var
tfe_tensor_handle
=
c_api
.
TFE_EagerTensorHandle
(
handle
)
;
var
dims
=
new
int
[
c_api
.
TFE_TensorHandleNumDims
(
tfe_tensor_handle
,
tf
.
Status
.
Handle
)
]
;
for
(
int
i
=
0
;
i
<
dims
.
Length
;
i
++
)
dims
[
i
]
=
c_api
.
TFE_TensorHandleDim
(
tfe_tensor_handle
,
i
,
tf
.
Status
.
Handle
)
;
return
dims
;
}
public
override
T
[
]
ToArray
<
T
>
(
)
{
Resolve
(
)
;
return
base
.
ToArray
<
T
>
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL