Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d8c9f19a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d8c9f19a
编写于
12月 05, 2022
作者:
C
cyber-pioneer
提交者:
GitHub
12月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move paddle.fluid.layers.tensor.create_tensor to paddle.tensor.creation.create_tensor (#48662)
上级
6cdaa371
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
74 addition
and
70 deletion
+74
-70
python/paddle/distribution/distribution.py
python/paddle/distribution/distribution.py
+1
-1
python/paddle/fluid/layers/tensor.py
python/paddle/fluid/layers/tensor.py
+0
-43
python/paddle/fluid/tests/test_if_else_op.py
python/paddle/fluid/tests/test_if_else_op.py
+2
-2
python/paddle/fluid/tests/unittests/collective/fleet/dist_mnist_gradient_merge.py
...s/unittests/collective/fleet/dist_mnist_gradient_merge.py
+1
-1
python/paddle/fluid/tests/unittests/collective/fleet/pipeline_mnist.py
.../fluid/tests/unittests/collective/fleet/pipeline_mnist.py
+1
-1
python/paddle/fluid/tests/unittests/collective/fleet/pipeline_mnist_multi_device.py
...unittests/collective/fleet/pipeline_mnist_multi_device.py
+1
-1
python/paddle/fluid/tests/unittests/collective/fleet/pipeline_mnist_one_device.py
...s/unittests/collective/fleet/pipeline_mnist_one_device.py
+1
-1
python/paddle/fluid/tests/unittests/dist_allreduce_op.py
python/paddle/fluid/tests/unittests/dist_allreduce_op.py
+1
-1
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer.py
...fluid/tests/unittests/dist_fleet_raw_program_optimizer.py
+1
-1
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer_fuse_allreduce.py
...ttests/dist_fleet_raw_program_optimizer_fuse_allreduce.py
+1
-1
python/paddle/fluid/tests/unittests/dist_mnist.py
python/paddle/fluid/tests/unittests/dist_mnist.py
+1
-1
python/paddle/fluid/tests/unittests/dist_mnist_batch_merge.py
...on/paddle/fluid/tests/unittests/dist_mnist_batch_merge.py
+1
-1
python/paddle/fluid/tests/unittests/dist_mnist_fp16_allreduce.py
...paddle/fluid/tests/unittests/dist_mnist_fp16_allreduce.py
+1
-1
python/paddle/fluid/tests/unittests/dist_mnist_lars.py
python/paddle/fluid/tests/unittests/dist_mnist_lars.py
+1
-1
python/paddle/fluid/tests/unittests/distribution/test_distribution_categorical.py
...s/unittests/distribution/test_distribution_categorical.py
+1
-2
python/paddle/fluid/tests/unittests/npu/test_assign_value_op_npu.py
...dle/fluid/tests/unittests/npu/test_assign_value_op_npu.py
+1
-1
python/paddle/fluid/tests/unittests/test_assign_value_op.py
python/paddle/fluid/tests/unittests/test_assign_value_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conditional_block.py
...on/paddle/fluid/tests/unittests/test_conditional_block.py
+1
-1
python/paddle/fluid/tests/unittests/test_desc_clone.py
python/paddle/fluid/tests/unittests/test_desc_clone.py
+1
-1
python/paddle/fluid/tests/unittests/test_fetch_var.py
python/paddle/fluid/tests/unittests/test_fetch_var.py
+4
-1
python/paddle/fluid/tests/unittests/test_profiler.py
python/paddle/fluid/tests/unittests/test_profiler.py
+1
-1
python/paddle/fluid/tests/unittests/test_square_error_cost.py
...on/paddle/fluid/tests/unittests/test_square_error_cost.py
+2
-3
python/paddle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py
...dle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py
+1
-1
python/paddle/tensor/__init__.py
python/paddle/tensor/__init__.py
+4
-0
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+43
-1
未找到文件。
python/paddle/distribution/distribution.py
浏览文件 @
d8c9f19a
...
...
@@ -203,7 +203,7 @@ class Distribution:
dtype
=
tmp
.
dtype
for
arg
in
numpy_args
:
arg_broadcasted
,
_
=
np
.
broadcast_arrays
(
arg
,
tmp
)
arg_variable
=
tensor
.
create_tensor
(
dtype
=
dtype
)
arg_variable
=
paddle
.
tensor
.
create_tensor
(
dtype
=
dtype
)
tensor
.
assign
(
arg_broadcasted
,
arg_variable
)
variable_args
.
append
(
arg_variable
)
...
...
python/paddle/fluid/layers/tensor.py
浏览文件 @
d8c9f19a
...
...
@@ -47,7 +47,6 @@ from .utils import check_shape
from
paddle
import
_C_ops
,
_legacy_C_ops
__all__
=
[
'create_tensor'
,
'create_global_var'
,
'cast'
,
'tensor_array_to_tensor'
,
...
...
@@ -62,48 +61,6 @@ __all__ = [
]
def
create_tensor
(
dtype
,
name
=
None
,
persistable
=
False
):
"""
Create a variable, which will hold a Tensor with data type dtype.
Args:
dtype(string|numpy.dtype): the data type of Tensor to be created, the
data type is bool, float16, float32, float64, int8, int16, int32 and int64.
name(string, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name`
persistable(bool): Set the persistable flag of the create tensor.
default value is False.
Returns:
Variable: The tensor to be created according to dtype.
Examples:
.. code-block:: python
import paddle.fluid as fluid
tensor = fluid.layers.create_tensor(dtype='float32')
"""
check_dtype
(
dtype
,
'dtype'
,
[
'bool'
,
'float16'
,
'float32'
,
'float64'
,
'int8'
,
'int32'
,
'int32'
,
'int64'
,
],
'create_tensor'
,
)
helper
=
LayerHelper
(
"create_tensor"
,
**
locals
())
return
helper
.
create_variable
(
name
=
helper
.
name
,
dtype
=
dtype
,
persistable
=
persistable
)
def
create_global_var
(
shape
,
value
,
dtype
,
persistable
=
False
,
force_cpu
=
False
,
name
=
None
):
...
...
python/paddle/fluid/tests/test_if_else_op.py
浏览文件 @
d8c9f19a
...
...
@@ -46,7 +46,7 @@ class TestMNISTIfElseOp(unittest.TestCase):
cond
=
paddle
.
less_than
(
x
=
label
,
y
=
limit
)
true_image
,
false_image
=
split_lod_tensor
(
input
=
image
,
mask
=
cond
)
true_out
=
layers
.
create_tensor
(
dtype
=
'float32'
)
true_out
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'float32'
)
true_cond
=
ConditionalBlock
([
cond
])
with
true_cond
.
block
():
...
...
@@ -54,7 +54,7 @@ class TestMNISTIfElseOp(unittest.TestCase):
prob
=
layers
.
fc
(
input
=
hidden
,
size
=
10
,
act
=
'softmax'
)
layers
.
assign
(
input
=
prob
,
output
=
true_out
)
false_out
=
layers
.
create_tensor
(
dtype
=
'float32'
)
false_out
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'float32'
)
false_cond
=
ConditionalBlock
([
cond
])
with
false_cond
.
block
():
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dist_mnist_gradient_merge.py
浏览文件 @
d8c9f19a
...
...
@@ -38,7 +38,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/pipeline_mnist.py
浏览文件 @
d8c9f19a
...
...
@@ -105,7 +105,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Evaluator
with
fluid
.
device_guard
(
"gpu:1"
):
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/pipeline_mnist_multi_device.py
浏览文件 @
d8c9f19a
...
...
@@ -105,7 +105,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Evaluator
with
fluid
.
device_guard
(
"gpu:1"
):
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/pipeline_mnist_one_device.py
浏览文件 @
d8c9f19a
...
...
@@ -97,7 +97,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Evaluator
with
fluid
.
device_guard
(
"gpu:0"
):
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_allreduce_op.py
浏览文件 @
d8c9f19a
...
...
@@ -81,7 +81,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer.py
浏览文件 @
d8c9f19a
...
...
@@ -83,7 +83,7 @@ class TestFleetMetaOptimizerPrecision(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer_fuse_allreduce.py
浏览文件 @
d8c9f19a
...
...
@@ -83,7 +83,7 @@ class TestFleetMetaOptimizerFuseAllReducePrecision(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_mnist.py
浏览文件 @
d8c9f19a
...
...
@@ -82,7 +82,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_mnist_batch_merge.py
浏览文件 @
d8c9f19a
...
...
@@ -47,7 +47,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_mnist_fp16_allreduce.py
浏览文件 @
d8c9f19a
...
...
@@ -41,7 +41,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/dist_mnist_lars.py
浏览文件 @
d8c9f19a
...
...
@@ -38,7 +38,7 @@ class TestDistMnist2x2(TestDistRunnerBase):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/distribution/test_distribution_categorical.py
浏览文件 @
d8c9f19a
...
...
@@ -20,7 +20,6 @@ from test_distribution import DistributionNumpy
import
paddle
from
paddle
import
fluid
from
paddle.distribution
import
Categorical
,
Distribution
,
Normal
,
Uniform
from
paddle.fluid
import
layers
np
.
random
.
seed
(
2022
)
...
...
@@ -380,7 +379,7 @@ class DistributionTestError(unittest.TestCase):
)
value_npdata
=
np
.
array
([
0.8
],
dtype
=
"float32"
)
value_tensor
=
layers
.
create_tensor
(
dtype
=
"float32"
)
value_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
"float32"
)
self
.
assertRaises
(
NotImplementedError
,
distribution
.
log_prob
,
value_tensor
)
...
...
python/paddle/fluid/tests/unittests/npu/test_assign_value_op_npu.py
浏览文件 @
d8c9f19a
...
...
@@ -93,7 +93,7 @@ class TestAssignApi(unittest.TestCase):
def
test_assign
(
self
):
main_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
):
x
=
layers
.
create_tensor
(
dtype
=
self
.
dtype
)
x
=
paddle
.
tensor
.
create_tensor
(
dtype
=
self
.
dtype
)
layers
.
assign
(
input
=
self
.
value
,
output
=
x
)
exe
=
fluid
.
Executor
(
self
.
place
)
...
...
python/paddle/fluid/tests/unittests/test_assign_value_op.py
浏览文件 @
d8c9f19a
...
...
@@ -83,7 +83,7 @@ class TestAssignApi(unittest.TestCase):
def
test_assign
(
self
):
main_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
):
x
=
layers
.
create_tensor
(
dtype
=
self
.
dtype
)
x
=
paddle
.
tensor
.
create_tensor
(
dtype
=
self
.
dtype
)
layers
.
assign
(
input
=
self
.
value
,
output
=
x
)
exe
=
fluid
.
Executor
(
self
.
place
)
...
...
python/paddle/fluid/tests/unittests/test_conditional_block.py
浏览文件 @
d8c9f19a
...
...
@@ -33,7 +33,7 @@ class ConditionalBlockTest(unittest.TestCase):
data
=
layers
.
data
(
name
=
'X'
,
shape
=
[
1
],
dtype
=
'float32'
)
data
.
stop_gradient
=
False
cond
=
ConditionalBlock
(
inputs
=
[
data
])
out
=
layers
.
create_tensor
(
dtype
=
'float32'
)
out
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'float32'
)
with
cond
.
block
():
hidden
=
layers
.
fc
(
input
=
data
,
size
=
10
)
layers
.
assign
(
hidden
,
out
)
...
...
python/paddle/fluid/tests/unittests/test_desc_clone.py
浏览文件 @
d8c9f19a
...
...
@@ -77,7 +77,7 @@ def get_model(batch_size):
avg_cost
=
paddle
.
mean
(
x
=
cost
)
# Evaluator
batch_size_tensor
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size_tensor
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size_tensor
)
...
...
python/paddle/fluid/tests/unittests/test_fetch_var.py
浏览文件 @
d8c9f19a
...
...
@@ -16,6 +16,7 @@ import unittest
import
numpy
as
np
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.layers
as
layers
...
...
@@ -26,7 +27,9 @@ class TestFetchVar(unittest.TestCase):
def
test_fetch_var
(
self
):
self
.
set_input
()
x
=
layers
.
create_tensor
(
dtype
=
"int32"
,
persistable
=
True
,
name
=
"x"
)
x
=
paddle
.
tensor
.
create_tensor
(
dtype
=
"int32"
,
persistable
=
True
,
name
=
"x"
)
layers
.
assign
(
input
=
self
.
val
,
output
=
x
)
exe
=
fluid
.
Executor
(
fluid
.
CPUPlace
())
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{},
fetch_list
=
[])
...
...
python/paddle/fluid/tests/unittests/test_profiler.py
浏览文件 @
d8c9f19a
...
...
@@ -59,7 +59,7 @@ class TestProfiler(unittest.TestCase):
label
=
fluid
.
layers
.
data
(
name
=
'y'
,
shape
=
[
1
],
dtype
=
'int64'
)
cost
=
fluid
.
layers
.
cross_entropy
(
input
=
predict
,
label
=
label
)
avg_cost
=
paddle
.
mean
(
cost
)
batch_size
=
fluid
.
layers
.
create_tensor
(
dtype
=
'int64'
)
batch_size
=
paddle
.
tensor
.
create_tensor
(
dtype
=
'int64'
)
batch_acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
,
total
=
batch_size
)
...
...
python/paddle/fluid/tests/unittests/test_square_error_cost.py
浏览文件 @
d8c9f19a
...
...
@@ -19,7 +19,6 @@ import numpy as np
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
import
paddle.fluid.layers
as
layers
from
paddle.fluid.executor
import
Executor
...
...
@@ -31,8 +30,8 @@ class TestSquareErrorCost(unittest.TestCase):
sub
=
input_val
-
label_val
np_result
=
sub
*
sub
input_var
=
layers
.
create_tensor
(
dtype
=
"float32"
,
name
=
"input"
)
label_var
=
layers
.
create_tensor
(
dtype
=
"float32"
,
name
=
"label"
)
input_var
=
paddle
.
tensor
.
create_tensor
(
dtype
=
"float32"
,
name
=
"input"
)
label_var
=
paddle
.
tensor
.
create_tensor
(
dtype
=
"float32"
,
name
=
"label"
)
output
=
paddle
.
nn
.
functional
.
square_error_cost
(
input
=
input_var
,
label
=
label_var
)
...
...
python/paddle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py
浏览文件 @
d8c9f19a
...
...
@@ -94,7 +94,7 @@ class TestAssignApi(unittest.TestCase):
def
test_assign
(
self
):
main_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
):
x
=
layers
.
create_tensor
(
dtype
=
self
.
dtype
)
x
=
paddle
.
tensor
.
create_tensor
(
dtype
=
self
.
dtype
)
layers
.
assign
(
input
=
self
.
value
,
output
=
x
)
exe
=
fluid
.
Executor
(
self
.
place
)
...
...
python/paddle/tensor/__init__.py
浏览文件 @
d8c9f19a
...
...
@@ -19,6 +19,8 @@ from .attribute import shape # noqa: F401
from
.attribute
import
real
# noqa: F401
from
.attribute
import
imag
# noqa: F401
from
.attribute
import
is_floating_point
# noqa: F401
from
.creation
import
create_parameter
# noqa: F401
from
.creation
import
create_tensor
# noqa: F401
from
.creation
import
to_tensor
# noqa: F401
from
.creation
import
diag
# noqa: F401
from
.creation
import
diagflat
# noqa: F401
...
...
@@ -289,6 +291,8 @@ from .einsum import einsum # noqa: F401
# this list used in math_op_patch.py for _binary_creator_
tensor_method_func
=
[
# noqa
'create_parameter'
,
'create_tensor'
,
'matmul'
,
'dot'
,
'cov'
,
...
...
python/paddle/tensor/creation.py
浏览文件 @
d8c9f19a
...
...
@@ -100,7 +100,7 @@ def create_parameter(
import paddle
paddle.enable_static()
W = paddle.
static.
create_parameter(shape=[784, 200], dtype='float32')
W = paddle.create_parameter(shape=[784, 200], dtype='float32')
"""
check_type
(
shape
,
'shape'
,
(
list
,
tuple
,
np
.
ndarray
),
'create_parameter'
)
for
item
in
shape
:
...
...
@@ -150,6 +150,48 @@ def create_parameter(
)
def
create_tensor
(
dtype
,
name
=
None
,
persistable
=
False
):
"""
Create a variable, which will hold a Tensor with data type dtype.
Args:
dtype(string|numpy.dtype): the data type of Tensor to be created, the
data type is bool, float16, float32, float64, int8, int16, int32 and int64.
name(string, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name`
persistable(bool): Set the persistable flag of the create tensor.
default value is False.
Returns:
Variable: The tensor to be created according to dtype.
Examples:
.. code-block:: python
import paddle
tensor = paddle.tensor.create_tensor(dtype='float32')
"""
check_dtype
(
dtype
,
'dtype'
,
[
'bool'
,
'float16'
,
'float32'
,
'float64'
,
'int8'
,
'int32'
,
'int32'
,
'int64'
,
],
'create_tensor'
,
)
helper
=
LayerHelper
(
"create_tensor"
,
**
locals
())
return
helper
.
create_variable
(
name
=
helper
.
name
,
dtype
=
dtype
,
persistable
=
persistable
)
def
linspace
(
start
,
stop
,
num
,
dtype
=
None
,
name
=
None
):
r
"""
Return fixed number of evenly spaced values within a given interval.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录