return (c)
)JIT";
+const auto detach_script_0 = R"JIT(
+ def forward(self, input: Tensor):
+ a = input.detach()
+ return input is a
+)JIT";
+
+const auto detach_script_1 = R"JIT(
+ def forward(self, input: Tensor):
+ a = input.detach()
+ return a.clone()
+)JIT";
+
const std::string embedding_bag_default = R"JIT(
def forward(self, a: Tensor, b: Tensor, c: Tensor):
return torch.embedding_bag(a, b, c)
test_to(at::ScalarType::Half, false, true, c10::MemoryFormat::ChannelsLast);
}
+TEST(StaticRuntime, IndividualOps_Detach) {
+ auto a = at::randn({4, 3, 1, 2});
+ auto b = at::randn({3, 2, 2});
+ std::vector<IValue> args{a};
+ std::vector<IValue> args2{b};
+ testStaticRuntime(detach_script_0, args);
+ testStaticRuntime(detach_script_0, args, args2);
+ testStaticRuntime(detach_script_1, args);
+ testStaticRuntime(detach_script_1, args, args2);
+}
+
TEST(StaticRuntime, IndividualOps_Full) {
auto dtype = at::ScalarType::Int;
auto cpu = at::Device(DeviceType::CPU);
});
REGISTER_NATIVE_OPERATOR_FUNCTOR(
+ aten::detach,
+ aten_detach,
+ [](Node* n) -> SROperator {
+ if (!n->matches(
+ torch::schema("aten::detach(Tensor(a) self) -> Tensor(a)"))) {
+ LogAndDumpSchema(n);
+ return nullptr;
+ }
+ return [](ProcessedNode* p_node) {
+ const auto& in0_t = p_node->Input(0).toTensor();
+ p_node->Output(0) = at::native::alias(in0_t);
+ };
+ });
+
+REGISTER_NATIVE_OPERATOR_FUNCTOR(
prim::isinstance,
prim_isinstance,
[](Node* n) -> SROperator {