codeislife99 commented on a change in pull request #7441: URL: https://github.com/apache/tvm/pull/7441#discussion_r574221285
########## File path: src/relay/op/algorithm/unique.cc ########## @@ -0,0 +1,147 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file unique.cc + * \brief The unique operator + */ +#include <dlpack/dlpack.h> +#include <tvm/relay/attrs/algorithm.h> +#include <tvm/relay/op.h> +#include <tvm/relay/op_attr_types.h> +#include <tvm/runtime/data_type.h> + +namespace tvm { +namespace relay { + +bool UniqueRel(const Array<Type>& types, int num_inputs, const Attrs& attrs, + const TypeReporter& reporter) { + // types: [data, result] + ICHECK_EQ(types.size(), 2) << "Unique: expect 2 types but " << types.size() << " provided"; + ICHECK_EQ(num_inputs, 1) << "Unique: expect 1 inputs but " << num_inputs << " provided"; + auto data = types[0].as<TensorTypeNode>(); + if (data == nullptr) { + ICHECK(types[0].as<IncompleteTypeNode>()) + << "Unique: expect input type to be TensorType but get " << types[0]; + return false; + } + std::vector<Type> fields; + fields.push_back(TensorType(data->shape, data->dtype)); Review comment: Instead of having a full tensor and then following it with strided slice , how about we make it totally dynamic itself ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
