parent
dfa6daaa57
commit
f97e19f23f
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_CCSRC_FRONTEND_PARALLEL_CACHE_EMBEDDING_CACHE_EMBEDDING_H_
|
||||
#define MINDSPORE_CCSRC_FRONTEND_PARALLEL_CACHE_EMBEDDING_CACHE_EMBEDDING_H_
|
||||
|
||||
#include "ir/anf.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace parallel {
|
||||
// Automatically adding control depend based on effect order and side effect analysis.
|
||||
void AddCacheEmbedding(const FuncGraphPtr &graph);
|
||||
} // namespace parallel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_CACHE_EMBEDDING_CACHE_EMBEDDING_H_
|
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
|
||||
*
|
||||
* Copyright 2019-2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_CCSRC_UTIL_CACHE_EMBBEDDING_HASHMAP_STRUCT_H_
|
||||
#define MINDSPORE_CCSRC_UTIL_CACHE_EMBBEDDING_HASHMAP_STRUCT_H_
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace mindspore {
|
||||
const int64_t kNullTag = 0;
|
||||
const int64_t kInitStep = -5;
|
||||
const int64_t kEmptyRate = 4;
|
||||
const double kGoldenRatio = 0.6180339;
|
||||
template <typename T>
|
||||
struct HashmapEntry {
|
||||
T key_;
|
||||
T value_;
|
||||
T step_;
|
||||
T tag_;
|
||||
|
||||
bool IsEmpty() { return tag_ == kNullTag; }
|
||||
|
||||
bool IsUsing(const T train_step) { return step_ >= (train_step - 1); }
|
||||
|
||||
bool IsKey(const T emb_idx) { return key_ == emb_idx; }
|
||||
|
||||
void SetEmpty() { tag_ = kNullTag; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T HashFunc(const T key, const size_t m) {
|
||||
return (T)(((kGoldenRatio * key) - floor(kGoldenRatio * key)) * m);
|
||||
}
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CCSRC_UTIL_CACHE_EMBBEDDING_HASHMAP_STRUCT_H_
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue