Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbolic local tensor meta #8662

Merged
merged 191 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 183 commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
6e8e9c9
ThreadLocalGuard
lixinqi May 12, 2022
08e9178
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi May 14, 2022
f59d17d
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi May 18, 2022
3eb809a
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi May 18, 2022
55c163c
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi May 20, 2022
8aa2e8f
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 1, 2022
7612597
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 6, 2022
de5f971
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 8, 2022
8e86949
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 9, 2022
2ca0707
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 16, 2022
8537b7e
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 16, 2022
55c5160
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 17, 2022
e643eb1
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 18, 2022
eccdfe6
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 20, 2022
043accc
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 20, 2022
97b0eef
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 20, 2022
1591853
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 23, 2022
ba6f2d7
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 23, 2022
5e1a86a
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 23, 2022
1ee004c
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 24, 2022
e853c71
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 24, 2022
c5afe82
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 24, 2022
14226d6
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 26, 2022
754d6a7
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 27, 2022
acb7c98
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 28, 2022
5916848
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jun 28, 2022
913f6f5
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 1, 2022
fa3867e
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 2, 2022
61bee99
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 3, 2022
7eb2d72
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 4, 2022
5862a95
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 6, 2022
29ad00c
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 6, 2022
7297192
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 6, 2022
78cc1fc
refactor EagerBlobObjectList
lixinqi Jul 7, 2022
720262f
op_args_reserved_size
lixinqi Jul 8, 2022
0a54078
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 8, 2022
b360aa0
Merge branch 'master' into profiling_main_thread
lixinqi Jul 8, 2022
75ba7b6
remove useless comments
lixinqi Jul 8, 2022
9a40b23
rename one::EagerBlobObjectList* to vm::EagerBlobObject*
lixinqi Jul 9, 2022
bf87255
refactor signature of InstructionsBuiler::Call
lixinqi Jul 9, 2022
2dc89b6
PhysicalRun
lixinqi Jul 10, 2022
8ac3e43
refactor InstructionsBuilder::Call
lixinqi Jul 10, 2022
f87dcdf
remove unused StatefulOpKernel::need_check_mem_case
lixinqi Jul 10, 2022
fd288f7
remove EagerLocalTensorImpl::is_shape_synced_
lixinqi Jul 10, 2022
cec8a1d
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 11, 2022
ca36321
eager_local_interpreter_with_infer_cache
clackhan Jul 11, 2022
fb69d8b
remove useless code
clackhan Jul 11, 2022
98a8996
Merge branch 'master' into eager_local_interpreter_with_infer_cache
clackhan Jul 11, 2022
b50e236
Merge branch 'master' of github.com:Oneflow-Inc/oneflow
lixinqi Jul 11, 2022
fcf6f58
merge master
lixinqi Jul 11, 2022
1dd3c3c
Merge branch 'refine_naive_interpret' of https://github.com/Oneflow-I…
clackhan Jul 11, 2022
2f74f49
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 11, 2022
7845311
reslove comments
clackhan Jul 11, 2022
cb2b22f
refactor TensorMeta::TensorMeta(const TensorMeta)
lixinqi Jul 11, 2022
c3dccba
use small vector
clackhan Jul 13, 2022
c0e643f
Symbolic LocalTensorMeta
clackhan Jul 13, 2022
ee9a525
check shape in critical_sectio
clackhan Jul 15, 2022
5cfa06b
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 18, 2022
2c4bf73
Merge branch 'refine_naive_interpret' of https://github.com/Oneflow-I…
clackhan Jul 18, 2022
012c86a
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
754e5e4
Merge branch 'master' into refine_naive_interpret
clackhan Jul 18, 2022
c633449
Merge branch 'refine_naive_interpret' of https://github.com/Oneflow-I…
clackhan Jul 18, 2022
70943af
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
d2e16ef
add kMaxNumDims
clackhan Jul 18, 2022
0cfa3d5
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
a395638
fix error include
clackhan Jul 18, 2022
e3ea898
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
ff369af
fix split Symbol LocalTensorMeta error
clackhan Jul 18, 2022
415f84b
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
83c68b7
fix split cache and symbolic local tensor meta error
clackhan Jul 18, 2022
db6cb63
refactor SoftSync
lixinqi Jul 18, 2022
02f7bf3
move SmallVector from common/container_util.h to framework/instructio…
lixinqi Jul 18, 2022
20ed423
Merge branch 'master' into refine_naive_interpret
clackhan Jul 18, 2022
2ebf5ee
Merge branch 'refine_naive_interpret' of https://github.com/Oneflow-I…
clackhan Jul 18, 2022
851a668
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
a88fd42
mone ONEFLOW_EAGER_ENABLE_LOCAL_INFER_CACHE to eager.h
clackhan Jul 18, 2022
efd48c6
add blank line
clackhan Jul 18, 2022
4ed595c
reslove comments
clackhan Jul 18, 2022
82bbec5
minor fix
clackhan Jul 18, 2022
d46eb7d
Merge branch 'master' into refine_naive_interpret
lixinqi Jul 18, 2022
fe3131a
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
f747252
refine
clackhan Jul 18, 2022
f0ad5c5
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
88367cb
explicit scalar initialization
lixinqi Jul 18, 2022
38ee056
Merge branch 'master' into refine_naive_interpret
clackhan Jul 18, 2022
51737e4
Merge branch 'refine_naive_interpret' of https://github.com/Oneflow-I…
clackhan Jul 18, 2022
82dfbd7
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 18, 2022
3221d2e
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 19, 2022
69f82ab
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 19, 2022
25692df
Merge branch 'master' into eager_local_interpreter_with_infer_cache
clackhan Jul 19, 2022
f5fcbf0
fix static check error
clackhan Jul 19, 2022
f2a2a36
Merge branch 'master' into eager_local_interpreter_with_infer_cache
clackhan Jul 19, 2022
faeb57e
auto format by CI
oneflow-ci-bot Jul 19, 2022
358a018
of_format
clackhan Jul 19, 2022
d11cb55
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 19, 2022
403620a
reslove comment
clackhan Jul 19, 2022
ebddd17
refine
clackhan Jul 19, 2022
783ecb5
refine
clackhan Jul 19, 2022
a2b874b
refine
clackhan Jul 19, 2022
21b4e6f
Merge branch 'eager_local_interpreter_with_infer_cache' of https://gi…
clackhan Jul 19, 2022
2959505
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 20, 2022
a3c6f57
fix error
clackhan Jul 20, 2022
d25f71d
define MutOutputShape and MutOutputStride in InferContext
clackhan Jul 20, 2022
37a81ee
Merge branch 'master' into symbolic_local_tensor_meta
clackhan Jul 20, 2022
eda0dc3
define_mut_output_shape_and_mut_output_stride_in_infer_ctx
clackhan Jul 20, 2022
15bd973
Merge branch 'master' into define_mut_output_shape_and_mut_output_str…
clackhan Jul 20, 2022
148048a
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 21, 2022
4d7490b
fix merge master error
clackhan Jul 21, 2022
d4ac72f
fix typo
clackhan Jul 21, 2022
7937095
Merge branch 'define_mut_output_shape_and_mut_output_stride_in_infer_…
clackhan Jul 21, 2022
422ca7f
Merge branch 'define_mut_output_shape_and_mut_output_stride_in_infer_…
clackhan Jul 21, 2022
e7ac48a
fix static check error
clackhan Jul 21, 2022
8008a8d
define_mut_output_dtype_and_mut_output_is_dynamic_in_infer_ctx
clackhan Jul 21, 2022
92c7898
Merge branch 'define_mut_output_shape_and_mut_output_stride_in_infer_…
clackhan Jul 21, 2022
60eac2f
Merge branch 'master' into define_mut_output_shape_and_mut_output_str…
clackhan Jul 21, 2022
955e2c9
define_mut_output_dtype_and_mut_output_tensor_desc
clackhan Jul 21, 2022
c6d6895
Merge branch 'define_mut_output_shape_and_mut_output_stride_in_infer_…
clackhan Jul 21, 2022
f806f87
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 21, 2022
8259180
Merge branch 'define_mut_output_dtype_and_mut_output_tensor_desc' of …
clackhan Jul 21, 2022
3cdd6bb
Merge branch 'master' into define_mut_output_shape_and_mut_output_str…
mergify[bot] Jul 21, 2022
e6ba760
replce const DataType& with DataType
clackhan Jul 21, 2022
f424d66
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 21, 2022
cbc01d1
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 21, 2022
86c5491
split const and mut func in LocalTensorMeta
clackhan Jul 21, 2022
1504b63
Merge branch 'define_mut_output_shape_and_mut_output_stride_in_infer_…
clackhan Jul 21, 2022
2f895df
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 21, 2022
e4ec386
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 21, 2022
52046b6
replace const DataType& with DataType ret
clackhan Jul 21, 2022
f20d096
Merge branch 'master' into define_mut_output_shape_and_mut_output_str…
mergify[bot] Jul 21, 2022
cca9465
split TensorDesc4ArgNameAndIndex and MutTensorDesc4ArgNameAndIndex
clackhan Jul 21, 2022
9ffb9ae
refine
clackhan Jul 21, 2022
b481016
Merge branch 'master' into define_mut_output_shape_and_mut_output_str…
clackhan Jul 22, 2022
cb26912
Merge branch 'define_mut_output_shape_and_mut_output_stride_in_infer_…
clackhan Jul 22, 2022
8693110
minor fix
clackhan Jul 22, 2022
adddeb1
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
556ac47
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
190dba7
fix merge error
clackhan Jul 22, 2022
7f94455
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
5432485
fix warning error
clackhan Jul 22, 2022
4feb8c5
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
3fb2868
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 22, 2022
b38490a
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
3ba438b
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
3c09540
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
clackhan Jul 22, 2022
1b11443
refine
clackhan Jul 22, 2022
ccabf99
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
e6b6e1e
fix static check error
clackhan Jul 22, 2022
c816414
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 22, 2022
1add5c0
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
47bbaab
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
ea3a604
Update op_expr.cpp
clackhan Jul 22, 2022
c8f6b6f
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
c8bcacb
Update op_expr.cpp
clackhan Jul 22, 2022
88348d7
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
8e0d388
split MutTensorMeta and MutLocalTensorMeta
clackhan Jul 22, 2022
d34e1a6
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
ad55324
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
clackhan Jul 22, 2022
855ee7c
Update stateful_opkernel.cpp
clackhan Jul 22, 2022
fb46e49
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 22, 2022
04fa1ee
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 22, 2022
175f2bb
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
clackhan Jul 22, 2022
c5797f3
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
mergify[bot] Jul 22, 2022
767af85
refine
clackhan Jul 23, 2022
194edbc
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 23, 2022
2c0c773
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 23, 2022
6165100
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
clackhan Jul 23, 2022
8acc6d9
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
mergify[bot] Jul 23, 2022
863f010
fix static check error
clackhan Jul 24, 2022
46c5c44
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 24, 2022
d3a8a22
refine
clackhan Jul 24, 2022
d22413e
Merge branch 'master' into define_mut_output_dtype_and_mut_output_is_…
mergify[bot] Jul 24, 2022
c8c333f
refine
clackhan Jul 24, 2022
d97722c
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 24, 2022
1874e98
Merge branch 'define_mut_output_dtype_and_mut_output_is_dynamic_in_in…
clackhan Jul 24, 2022
3fb0178
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 24, 2022
f4460d4
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Jul 24, 2022
e41381a
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 24, 2022
4a54c33
Merge branch 'master' into define_mut_output_tensor_desc
clackhan Jul 25, 2022
68e1c5f
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 25, 2022
a1f6255
Merge branch 'master' into define_mut_output_tensor_desc
clackhan Jul 25, 2022
18dba91
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 25, 2022
5d760ff
reslove comment
clackhan Jul 25, 2022
53e21e4
refine
clackhan Jul 25, 2022
c201a6f
Merge branch 'master' into define_mut_output_tensor_desc
clackhan Jul 25, 2022
8f91ce7
fix typo
clackhan Jul 25, 2022
44d3728
fxi typo
clackhan Jul 25, 2022
f102944
Merge branch 'symbolic_local_tensor_meta' of https://github.com/Onefl…
clackhan Jul 25, 2022
b2f9696
use OpArgsVector
clackhan Jul 25, 2022
fefab92
Merge branch 'master' into define_mut_output_tensor_desc
mergify[bot] Jul 25, 2022
fdd87ba
Merge branch 'define_mut_output_tensor_desc' of https://github.com/On…
clackhan Jul 25, 2022
2814c1b
Merge branch 'master' into symbolic_local_tensor_meta
clackhan Jul 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions oneflow/api/python/functional/tensor_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class LocalTensorSharedNumpyDataFunctor {
}
stride_val /= element_size_in_bytes;
}
auto tensor_meta = std::make_shared<LocalTensorMeta>(shape, strides, data_type, device, 0);
auto tensor_meta = SymbolOf(LocalTensorMeta(shape, strides, data_type, device, 0));

// Build TensorBuffer
const auto& Free = [array](char* dptr) {
Expand All @@ -286,12 +286,12 @@ class LocalTensorSharedNumpyDataFunctor {
auto tensor_storage = std::make_shared<TensorStorage>(tensor_data);

// Build Tensor
auto tensor_impl = std::make_shared<EagerLocalTensorImpl>(tensor_meta, tensor_storage,
auto tensor_impl = std::make_shared<EagerLocalTensorImpl>(tensor_storage,
/*requires_grad=*/false,
/*ls_leaf=*/true);

// Init blob
JUST(tensor_impl->InitEagerBlobObject(NewLocalDepObject()));
JUST(tensor_impl->InitEagerBlobObject(tensor_meta, NewLocalDepObject()));
const auto& stream = JUST(GetDefaultStreamByDevice(device));
const auto& eager_blob_object = JUST(tensor_impl->eager_blob_object());
JUST(eager_blob_object->init_producer_stream(stream));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "oneflow/core/framework/tensor_desc.h"
#include "oneflow/core/common/tensor_desc.h"
#include "oneflow/core/register/blob_desc.pb.h"

namespace oneflow {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef ONEFLOW_CORE_FRAMEWORK_TENSOR_DESC_H_
#define ONEFLOW_CORE_FRAMEWORK_TENSOR_DESC_H_
#ifndef ONEFLOW_CORE_COMMON_TENSOR_DESC_H_
#define ONEFLOW_CORE_COMMON_TENSOR_DESC_H_

#include "oneflow/core/common/util.h"
#include "oneflow/core/register/blob_desc.pb.h"
#include "oneflow/core/common/shape.h"
#include "oneflow/core/common/stride.h"
#include "oneflow/core/common/data_type.pb.h"

namespace oneflow {

class BlobDescProto;

namespace user_op {

class TensorDesc {
Expand Down Expand Up @@ -77,4 +79,4 @@ class NaiveTensorDesc final : public TensorDesc {

} // namespace oneflow

#endif // ONEFLOW_CORE_FRAMEWORK_TENSOR_DESC_H_
#endif // ONEFLOW_CORE_COMMON_TENSOR_DESC_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,36 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "oneflow/core/framework/tensor_meta.h"
#include "oneflow/core/common/tensor_meta.h"
#include "oneflow/core/common/stride.h"
#include "oneflow/core/framework/device.h"

namespace oneflow {
namespace one {

MutTensorMeta::MutTensorMeta()
: TensorMeta(std::make_shared<const Shape>(), std::make_shared<const Stride>(),
kInvalidDataType) {}

MutTensorMeta::MutTensorMeta(const std::shared_ptr<const Shape>& shape, DataType dtype)
: TensorMeta(shape, std::make_shared<const Stride>(*shape), dtype) {}

MutTensorMeta::MutTensorMeta(const std::shared_ptr<const Shape>& shape,
const std::shared_ptr<const Stride>& stride, DataType dtype)
: TensorMeta(shape, stride, dtype) {}

bool MutTensorMeta::operator==(const MutTensorMeta& other) const {
// It's correct to ignore is_dynamic_ field.
return *this->shape_ptr() == *other.shape_ptr() && this->dtype() == other.dtype()
&& this->stride() == other.stride();
}

size_t MutTensorMeta::CalcHashValue() const {
// It's correct to ignore is_dynamic_ field.
return std::hash<Shape>()(*shape_ptr()) ^ std::hash<DataType>()(dtype())
^ std::hash<Stride>()(stride());
}

LocalTensorMeta::LocalTensorMeta()
: TensorMeta(std::make_shared<const Shape>(), std::make_shared<const Stride>(),
DataType::kInvalidDataType),
Expand Down Expand Up @@ -50,6 +73,36 @@ size_t LocalTensorMeta::CalcHashValue() const {
^ std::hash<Device>()(*device()) ^ std::hash<Stride>()(stride()) ^ storage_offset();
}

MutLocalTensorMeta::MutLocalTensorMeta()
: MutTensorMeta(std::make_shared<const Shape>(), std::make_shared<const Stride>(),
kInvalidDataType),
device_(Symbol<Device>()),
storage_offset_(0) {}

MutLocalTensorMeta::MutLocalTensorMeta(const std::shared_ptr<const Shape>& shape, DataType dtype,
Symbol<Device> device)
: MutTensorMeta(shape, std::make_shared<const Stride>(*shape), dtype),
device_(device),
storage_offset_(0) {}

MutLocalTensorMeta::MutLocalTensorMeta(const std::shared_ptr<const Shape>& shape,
const std::shared_ptr<const Stride>& stride, DataType dtype,
Symbol<Device> device, int64_t storage_offset)
: MutTensorMeta(shape, stride, dtype), device_(device), storage_offset_(storage_offset) {}

bool MutLocalTensorMeta::operator==(const MutLocalTensorMeta& other) const {
// It's correct to ignore is_dynamic_ field.
return *this->shape_ptr() == *other.shape_ptr() && this->dtype() == other.dtype()
&& *this->device() == *other.device() && this->stride() == other.stride()
&& this->storage_offset() == other.storage_offset();
}

size_t MutLocalTensorMeta::CalcHashValue() const {
// It's correct to ignore is_dynamic_ field.
return std::hash<Shape>()(*shape_ptr()) ^ std::hash<DataType>()(dtype())
^ std::hash<Device>()(*device()) ^ std::hash<Stride>()(stride()) ^ storage_offset();
}

bool GlobalTensorMeta::operator==(const GlobalTensorMeta& other) const {
// It's correct to ignore is_dynamic_ field.
return *this->shape_ptr() == *other.shape_ptr() && this->dtype() == other.dtype()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef ONEFLOW_FRAMEWORK_TENSOR_META_H_
#define ONEFLOW_FRAMEWORK_TENSOR_META_H_
#ifndef ONEFLOW_COMMON_TENSOR_META_H_
#define ONEFLOW_COMMON_TENSOR_META_H_

#include <memory>
#include "oneflow/core/framework/tensor_desc.h"
#include "oneflow/core/common/tensor_desc.h"
#include "oneflow/core/common/symbol.h"

namespace oneflow {
Expand Down Expand Up @@ -60,15 +60,23 @@ class TensorMeta : public user_op::TensorDesc {
bool is_dynamic() const override { return is_dynamic_; }
bool is_contiguous() const { return IsContiguous(shape(), *stride_); }

void set_shape(const std::shared_ptr<const Shape>& val) { shape_ = val; }
Shape* mut_shape() override { return const_cast<Shape*>(shape_.get()); }
void set_stride(const std::shared_ptr<const Stride>& val) { stride_ = val; }
Stride* mut_stride() override { return const_cast<Stride*>(stride_.get()); }
DataType* mut_dtype() { return &data_type_; }
void set_dtype(DataType data_type) { data_type_ = data_type; }
DataType* mut_data_type() override { return &data_type_; }
bool* mut_is_dynamic() override { return &is_dynamic_; }
void set_is_dynamic(bool val) override { is_dynamic_ = val; }
virtual Shape* mut_shape() override {
PRINT_BUG_PROMPT_AND_ABORT();
return nullptr;
}
virtual Stride* mut_stride() override {
PRINT_BUG_PROMPT_AND_ABORT();
return nullptr;
}
virtual DataType* mut_data_type() override {
PRINT_BUG_PROMPT_AND_ABORT();
return nullptr;
}
virtual bool* mut_is_dynamic() override {
PRINT_BUG_PROMPT_AND_ABORT();
return nullptr;
}
virtual void set_is_dynamic(bool val) override { PRINT_BUG_PROMPT_AND_ABORT(); }

protected:
TensorMeta& operator=(const TensorMeta& other) {
Expand All @@ -79,13 +87,39 @@ class TensorMeta : public user_op::TensorDesc {
return *this;
}

private:
std::shared_ptr<const Shape> shape_;
std::shared_ptr<const Stride> stride_;
DataType data_type_;
bool is_dynamic_;
};

class MutTensorMeta : public TensorMeta {
public:
// uninitialized MutTensorMeta.
MutTensorMeta();
MutTensorMeta(const MutTensorMeta&) = default;
MutTensorMeta(const std::shared_ptr<const Shape>& shape, DataType dtype);
MutTensorMeta(const std::shared_ptr<const Shape>& shape,
const std::shared_ptr<const Stride>& stride, DataType dtype);
virtual ~MutTensorMeta() = default;

Shape* mut_shape() override { return const_cast<Shape*>(shape_.get()); }
Stride* mut_stride() override { return const_cast<Stride*>(stride_.get()); }
DataType* mut_data_type() override { return &data_type_; }
bool* mut_is_dynamic() override { return &is_dynamic_; }
void set_is_dynamic(bool val) override { is_dynamic_ = val; }

void set_shape(const std::shared_ptr<const Shape>& val) { shape_ = val; }
void set_stride(const std::shared_ptr<const Stride>& val) { stride_ = val; }
DataType* mut_dtype() { return &data_type_; }
void set_dtype(DataType data_type) { data_type_ = data_type; }

bool operator==(const MutTensorMeta& other) const;
size_t CalcHashValue() const;

MutTensorMeta& operator=(const MutTensorMeta& other) = default;
};

class LocalTensorMeta : public TensorMeta {
public:
// uninitialized LocalTensorMeta.
Expand All @@ -100,13 +134,38 @@ class LocalTensorMeta : public TensorMeta {
const Symbol<Device>& device() const { return device_; }
int64_t storage_offset() const { return storage_offset_; }

bool operator==(const LocalTensorMeta& other) const;
size_t CalcHashValue() const;

LocalTensorMeta& operator=(const LocalTensorMeta& other) = default;

private:
Symbol<Device> device_;
int64_t storage_offset_;
};

class MutLocalTensorMeta : public MutTensorMeta {
public:
// uninitialized MutLocalTensorMeta.
MutLocalTensorMeta();
MutLocalTensorMeta(const MutLocalTensorMeta&) = default;
MutLocalTensorMeta(const std::shared_ptr<const Shape>& shape, DataType dtype,
Symbol<Device> device);
MutLocalTensorMeta(const std::shared_ptr<const Shape>& shape,
const std::shared_ptr<const Stride>& stride, DataType dtype,
Symbol<Device> device, int64_t storage_offset);
virtual ~MutLocalTensorMeta() = default;

const Symbol<Device>& device() const { return device_; }
int64_t storage_offset() const { return storage_offset_; }

Symbol<Device>* mut_device() { return &device_; }
void set_storage_offset(int64_t offset) { storage_offset_ = offset; }

bool operator==(const LocalTensorMeta& other) const;
bool operator==(const MutLocalTensorMeta& other) const;
size_t CalcHashValue() const;

LocalTensorMeta& operator=(const LocalTensorMeta& other) = default;
MutLocalTensorMeta& operator=(const MutLocalTensorMeta& other) = default;

private:
Symbol<Device> device_;
Expand All @@ -127,10 +186,6 @@ class GlobalTensorMeta : public TensorMeta {
Symbol<NdSbp> nd_sbp() const { return nd_sbp_; }
Symbol<ParallelDesc> parallel_desc() const { return parallel_desc_; }

void set_nd_sbp(Symbol<NdSbp> val) { nd_sbp_ = val; }

void set_parallel_desc(Symbol<ParallelDesc> val) { parallel_desc_ = val; }

size_t CalcHashValue() const;

private:
Expand Down Expand Up @@ -159,4 +214,4 @@ struct hash<oneflow::one::GlobalTensorMeta> final {

} // namespace std

#endif // ONEFLOW_FRAMEWORK_TENSOR_META_H_
#endif // ONEFLOW_COMMON_TENSOR_META_H_
5 changes: 2 additions & 3 deletions oneflow/core/eager/critical_section_phy_instr_operand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void InputCriticalSectionBeginPhyInstrOperand::AccessBlobByOpName(uint64_t of_bl
{
size_t header_size = of_blob->mut_blob()->blob_desc().ByteSizeOfBlobHeader();
CHECK_EQ(header_size, eager_blob_object->shape().NumAxes() * sizeof(int64_t));
std::memcpy(of_blob->mut_blob()->mut_header_ptr(), eager_blob_object->mut_header_ptr(),
header_size);
CHECK_EQ(of_blob->blob().static_shape(), eager_blob_object->shape());
}
const auto& end_event_record = op_name2end_event_record_->at(op_name);
if (eager_blob_object->dptr() == nullptr) {
Expand All @@ -93,7 +92,7 @@ void OutputCriticalSectionBeginPhyInstrOperand::AccessBlobByOpName(uint64_t of_b
CHECK(interfaces_valid().at(i));
OfBlob* of_blob = reinterpret_cast<OfBlob*>(of_blob_ptr);
auto& eager_blob_object = eager_blob_objects_->at(i);
of_blob->blob().shape_view().ToShape(eager_blob_object->mut_shape());
CHECK_EQ(of_blob->blob().static_shape(), eager_blob_object->shape());
const auto& end_event_record = op_name2end_event_record_->at(op_name);
if (eager_blob_object->dptr() == nullptr) {
end_event_record->Init(std::make_shared<NaiveEventRecord>());
Expand Down
67 changes: 57 additions & 10 deletions oneflow/core/eager/eager_blob_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,79 @@ limitations under the License.
#include "oneflow/core/framework/to_string.h"
#include "oneflow/core/framework/shut_down_util.h"
#include "oneflow/core/common/shape_vec.h"
#include "oneflow/core/common/tensor_meta.h"

namespace oneflow {

namespace vm {

EagerBlobObject::EagerBlobObject(const std::shared_ptr<MemoryCase>& mem_case,
const std::shared_ptr<Shape>& shape,
const std::shared_ptr<Stride>& stride, DataType data_type,
const std::shared_ptr<TensorStorage>& tensor_storage,
const intrusive::shared_ptr<LocalDepObject>& dep_object)
EagerBlobObject::EagerBlobObject(
const std::shared_ptr<MemoryCase>& mem_case,
const Symbol<one::LocalTensorMeta>& static_local_tensor_meta,
const std::shared_ptr<const one::MutLocalTensorMeta>& dynamic_local_tensor_meta,
DataType data_type, const std::shared_ptr<TensorStorage>& tensor_storage,
const intrusive::shared_ptr<LocalDepObject>& dep_object)
: is_dynamic_(false),
mem_case_(mem_case),
data_type_(data_type),
shape_(shape),
stride_(stride),
storage_offset_(0),
tensor_storage_(tensor_storage),
mem_ptr_for_allocation_compuation_pipelining_(nullptr),
inited_mem_ptr_for_allocation_compuation_pipelining_(false),
is_non_pod_object_placement_newed_(false),
pin_memory_(false),
compute_local_dep_object_(dep_object),
blob_desc_(shape, stride, data_type) {
CHECK(static_cast<bool>(shape));
CHECK(static_cast<bool>(stride));
blob_desc_(static_cast<bool>(dynamic_local_tensor_meta)
? std::const_pointer_cast<Shape>(dynamic_local_tensor_meta->shape_ptr())
: std::const_pointer_cast<Shape>(static_local_tensor_meta->shape_ptr()),
static_cast<bool>(dynamic_local_tensor_meta)
? std::const_pointer_cast<Stride>(dynamic_local_tensor_meta->stride_ptr())
: std::const_pointer_cast<Stride>(static_local_tensor_meta->stride_ptr()),
data_type),
static_local_tensor_meta_(static_local_tensor_meta),
dynamic_local_tensor_meta_(dynamic_local_tensor_meta) {
CHECK(static_cast<bool>(tensor_storage));
}

// user_op::TensorDesc overrides
const Shape& EagerBlobObject::shape() const {
if (dynamic_local_tensor_meta_) {
return dynamic_local_tensor_meta_->shape();
} else {
return static_local_tensor_meta_->shape();
}
}
Shape* EagerBlobObject::mut_shape() {
CHECK(dynamic_local_tensor_meta_);
return std::const_pointer_cast<one::MutLocalTensorMeta>(dynamic_local_tensor_meta_)->mut_shape();
}
const Stride& EagerBlobObject::stride() const {
if (dynamic_local_tensor_meta_) {
return dynamic_local_tensor_meta_->stride();
} else {
return static_local_tensor_meta_->stride();
}
}
Stride* EagerBlobObject::mut_stride() {
CHECK(dynamic_local_tensor_meta_);
return std::const_pointer_cast<one::MutLocalTensorMeta>(dynamic_local_tensor_meta_)->mut_stride();
}

std::shared_ptr<const Shape> EagerBlobObject::shape_ptr() const {
if (dynamic_local_tensor_meta_) {
return dynamic_local_tensor_meta_->shape_ptr();
} else {
return static_local_tensor_meta_->shape_ptr();
}
}
std::shared_ptr<const Stride> EagerBlobObject::stride_ptr() const {
if (dynamic_local_tensor_meta_) {
return dynamic_local_tensor_meta_->stride_ptr();
} else {
return static_local_tensor_meta_->stride_ptr();
}
}

Blob* EagerBlobObject::blob() {
if (!blob_) {
blob_.reset(new Blob(*mem_case_, &blob_desc_, mut_header_ptr(), mut_dptr<char>()));
Expand Down
Loading