Make fuse_optimizer_op_pass also work when the model contains sparse gradients. (#18664)
* support sparse gradients test=developDDDivano-patch-1
parent
6b78e00da4
commit
fd3aad6cb3
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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 "paddle/fluid/platform/device_memory_aligment.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace platform {
|
||||
size_t Alignment(size_t size, const platform::Place &place) {
|
||||
size_t alignment = 1024;
|
||||
if (platform::is_cpu_place(place)) {
|
||||
alignment = CpuMinChunkSize();
|
||||
} else {
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
alignment = GpuMinChunkSize();
|
||||
#else
|
||||
PADDLE_THROW("Fluid is not compiled with CUDA");
|
||||
#endif
|
||||
}
|
||||
size_t remaining = size % alignment;
|
||||
return remaining == 0 ? size : size + (alignment - remaining);
|
||||
}
|
||||
} // namespace platform
|
||||
} // namespace paddle
|
@ -0,0 +1,27 @@
|
||||
/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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. */
|
||||
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include "paddle/fluid/platform/cpu_info.h"
|
||||
#include "paddle/fluid/platform/place.h"
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
#include "paddle/fluid/platform/gpu_info.h"
|
||||
#endif
|
||||
|
||||
namespace paddle {
|
||||
namespace platform {
|
||||
size_t Alignment(size_t size, const platform::Place &place);
|
||||
} // namespace platform
|
||||
} // namespace paddle
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue