@torch.library.custom_op("mylib::add", mutates_args=()) def add(x: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor]: return (x.clone(),) ret = add(x, x) gives:yset, *args, **kwargs) 720 def redispatch(self,
pull Fix #150472 torch.library.custom_op doesn't handle single element tuples returns #309776 Sign in to view logs Summary Jobs before-test get-label-type linux-jammy-py3.9-gcc11 linux-jammy-py3.9-gcc11-no-ops linux-jammy-py3.9-gcc11-pch linux-jammy-py3.10-clang15-asan l...
答:cpu下需要用".data<T>"的方式来获取指针所指的数据;cuda下用了 using Traits = phi::funcs::FunctionTraits<Functor>; using ArgsT = typename Traits::ArgsTuple;而且 using ArgsTuple = std::tuple<Args...>;的方法。参数包自动推理数据类型,然后利用 BroadcastDataSetter 中的 reinterpret_cast<const _...
arg ends up being the tuple instead of the first item in the tuple (as I would expected based on tuples with more than one item. I also tried: @pytest.mark.parametrize("arg,", scenarios) but that also associated the entire tuple with arg instead of the first element. I reverted bac...