mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary:
This is an automatic change generated by the following script:
```
#!/usr/bin/env python3
from subprocess import check_output, check_call
import os
def get_compiled_files_list():
import json
with open("build/compile_commands.json") as f:
data = json.load(f)
files = [os.path.relpath(node['file']) for node in data]
for idx, fname in enumerate(files):
if fname.startswith('build/') and fname.endswith('.DEFAULT.cpp'):
files[idx] = fname[len('build/'):-len('.DEFAULT.cpp')]
return files
def run_clang_tidy(fname):
check_call(["python3", "tools/clang_tidy.py", "-c", "build", "-x", fname,"-s"])
changes = check_output(["git", "ls-files", "-m"])
if len(changes) == 0:
return
check_call(["git", "commit","--all", "-m", f"NOLINT stubs for {fname}"])
def main():
git_files = check_output(["git", "ls-files"]).decode("ascii").split("\n")
compiled_files = get_compiled_files_list()
for idx, fname in enumerate(git_files):
if fname not in compiled_files:
continue
if fname.startswith("caffe2/contrib/aten/"):
continue
print(f"[{idx}/{len(git_files)}] Processing {fname}")
run_clang_tidy(fname)
if __name__ == "__main__":
main()
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56892
Reviewed By: H-Huang
Differential Revision: D27991944
Pulled By: malfet
fbshipit-source-id: 5415e1eb2c1b34319a4f03024bfaa087007d7179
76 lines
2.4 KiB
C++
76 lines
2.4 KiB
C++
#include "caffe2/queue/blobs_queue_db.h"
|
|
|
|
#include <algorithm>
|
|
#include <chrono>
|
|
#include <random>
|
|
#include <string>
|
|
|
|
#include "caffe2/core/context.h"
|
|
#include "caffe2/core/logging.h"
|
|
#include "caffe2/core/operator.h"
|
|
#include "caffe2/queue/blobs_queue.h"
|
|
|
|
#ifdef CAFFE2_USE_MKLDNN
|
|
#include <caffe2/ideep/operators/operator_fallback_ideep.h>
|
|
#include <caffe2/ideep/utils/ideep_operator.h>
|
|
#endif
|
|
|
|
namespace caffe2 {
|
|
namespace db {
|
|
|
|
template <class Context>
|
|
class CreateBlobsQueueDBOp : public Operator<CPUContext> {
|
|
public:
|
|
CreateBlobsQueueDBOp(const OperatorDef& operator_def, Workspace* ws)
|
|
: Operator<CPUContext>(operator_def, ws) {}
|
|
|
|
bool RunOnDevice() override {
|
|
std::unique_ptr<db::DB> db = std::make_unique<BlobsQueueDB>(
|
|
"",
|
|
db::READ,
|
|
OperatorBase::Input<std::shared_ptr<BlobsQueue>>(0),
|
|
OperatorBase::template GetSingleArgument<int>("key_blob_index", -1),
|
|
OperatorBase::template GetSingleArgument<int>("value_blob_index", 0),
|
|
OperatorBase::template GetSingleArgument<float>("timeout_secs", 0.0));
|
|
OperatorBase::Output<db::DBReader>(0)->Open(std::move(db), 1, 0);
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
C10_DISABLE_COPY_AND_ASSIGN(CreateBlobsQueueDBOp);
|
|
};
|
|
|
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
|
REGISTER_CPU_OPERATOR(CreateBlobsQueueDB, CreateBlobsQueueDBOp<CPUContext>);
|
|
|
|
#ifdef CAFFE2_USE_MKLDNN
|
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
|
REGISTER_IDEEP_OPERATOR(
|
|
CreateBlobsQueueDB,
|
|
IDEEPFallbackOp<CreateBlobsQueueDBOp<CPUContext>, SkipIndices<0>>);
|
|
#endif
|
|
|
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
|
OPERATOR_SCHEMA(CreateBlobsQueueDB)
|
|
.NumInputs(1)
|
|
.NumOutputs(1)
|
|
.Arg(
|
|
"key_blob_index",
|
|
"(default: -1 (no key)) index of blob for DB key in the BlobsQueue.")
|
|
.Arg(
|
|
"value_blob_index",
|
|
"(default: 0) index of blob for DB value in the BlobsQueue.")
|
|
.Arg(
|
|
"timeout_secs",
|
|
"(default: 0.0 (no timeout)) Timeout in seconds for reading from the "
|
|
"BlobsQueue.")
|
|
.SetDoc("Create a DBReader from a BlobsQueue")
|
|
.Input(0, "queue", "The shared pointer to a queue containing Blobs.")
|
|
.Output(0, "reader", "The DBReader for the given BlobsQueue");
|
|
|
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
|
SHOULD_NOT_DO_GRADIENT(CreateBlobsQueueDB);
|
|
|
|
} // namespace db
|
|
} // namespace caffe2
|