Skip to content

Codegen doesn't support ops with multiple output tensors (e.g. slogdet) #3596

Open
@miladm

Description

@miladm

Codegen doesn't support ops with multiple output tensors (e.g. slogdet). Below is the codegen results as well as the error reported. This issue blocked full codegen integration of slogdet in #3576.

CC @JackCaoG @wonjoolee95 @wconstab

Issue 1:

error: no matching function for call to 'std::vector<c10::intrusive_ptr<torch_xla::XLATensor> >::push_back(torch_xla::XLATensor)'

Looks like torch_xla::XLATensor::Create(torch::lazy::Value(node, i), *common_device) creates a pointer while the vector requires torch_xla::XLATensor.

Issue 2:
Why is there a :: in front of the function return type?


In XLANativeFunctions.cpp:

    ::std::tuple<at::Tensor,at::Tensor> XLANativeFunctions::slogdet(const at::Tensor & self) {
        
        XLA_FN_COUNTER("xla::");
        auto common_device = torch_xla::bridge::GetXlaDevice(self);
        TORCH_INTERNAL_ASSERT(common_device);
        
        torch_xla::XLATensorPtr lazy_self = torch_xla::bridge::GetXlaTensorOrCreateForWrappedNumber(self, *common_device);
        torch::lazy::NodePtr node = torch::lazy::ReuseNode<Slogdet>(lazy_self->GetIrValue());
        if (!node) {
            
            auto shapes = torch::lazy::compute_shape_slogdet(self);
            TORCH_INTERNAL_ASSERT(shapes.size() == 2);
            if(torch::lazy::symbolicShapeEnabled()){
                std::vector<torch::jit::IValue> inputs = { self };
                char* schema_str = "aten::slogdet(Tensor self) -> (Tensor sign, Tensor logabsdet)";
                applySymbolicShapesOnLT(schema_str, inputs, shapes);
            }
        
            node = torch::lazy::MakeNode<Slogdet>(lazy_self->GetIrValue(), std::move(shapes));
            CacheNode(node);
        }
        
        std::vector<torch_xla::XLATensorPtr> lazy_tensors;
        for (int i = 0; i < 2; i++) {
            lazy_tensors.push_back(torch_xla::XLATensor::Create(torch::lazy::Value(node, i), *common_device));
        }
        auto result = torch::lazy::TupleAtenFromLtcTensors<2>(lazy_tensors);
        return result;
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions