pytorch/test/cpp/jit/test_base.cpp
Song Zhou dabeff33b9 [pytorch] Fix fblearner flow compiling errors (#35902)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35902

Move operator registration to anonymous namespace to avoid collision.

Reviewed By: soumith

Differential Revision: D20822382

fbshipit-source-id: 1ab00871491668b8b85e803ac877d96477f1688b
2020-04-02 14:52:48 -07:00

30 lines
827 B
C++

#include <test/cpp/jit/test_base.h>
#include <test/cpp/jit/test_utils.h>
#include "torch/csrc/jit/runtime/custom_operator.h"
namespace torch {
namespace jit {
inline c10::AliasAnalysisKind aliasAnalysisFromSchema() {
return c10::AliasAnalysisKind::FROM_SCHEMA;
}
namespace {
RegisterOperators reg({
// This operator is intended to be used in JIT analysis and transformation
// pass unit tests in which Values with type Tensor are often required. It
// should not be used in situations in which the graph is actually executed
// because it always produces empty Tensors.
Operator(
"prim::MakeTestTensor() -> Tensor",
[](Stack& stack) {
push(stack, at::Tensor());
return 0;
},
aliasAnalysisFromSchema()),
});
}
} // namespace jit
} // namespace torch