1# 2# Copyright (C) 2019 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17inp = Input("input", "TENSOR_QUANT8_ASYMM_SIGNED", "{2, 3}, 2.0, 0") 18inp_data = [-127, -126, -125, 123, 122, 121] 19k = Int32Scalar("k", 2) 20out_values = Output("out_values", "TENSOR_QUANT8_ASYMM_SIGNED", "{2, 2}, 2.0, 0") 21out_values_data = [-125, -126, 123, 122] 22out_indices = Output("out_indices", "TENSOR_INT32", "{2, 2}") 23out_indices_data = [2, 1, 0, 1] 24 25model = Model().Operation("TOPK_V2", inp, k).To(out_values, out_indices) 26Example( 27 { 28 inp: inp_data, 29 out_values: out_values_data, 30 out_indices: out_indices_data 31 }, 32 model=model) 33