| 30 | class GenericDecoderTest : public DALISingleOpTest<ImgType> { |
| 31 | public: |
| 32 | vector<std::shared_ptr<TensorList<CPUBackend>>> Reference( |
| 33 | const vector<TensorList<CPUBackend> *> &inputs, Workspace *ws) override { |
| 34 | // single input - encoded images |
| 35 | // single output - decoded images |
| 36 | |
| 37 | TensorList<CPUBackend> out(inputs[0]->num_samples()); |
| 38 | std::vector<Tensor<CPUBackend>> tmp_out(inputs[0]->num_samples()); |
| 39 | |
| 40 | const TensorList<CPUBackend> &encoded_data = *inputs[0]; |
| 41 | |
| 42 | const int c = this->GetNumColorComp(); |
| 43 | for (int i = 0; i < encoded_data.num_samples(); ++i) { |
| 44 | auto *data = encoded_data.tensor<unsigned char>(i); |
| 45 | auto data_size = volume(encoded_data.tensor_shape(i)); |
| 46 | |
| 47 | this->DecodeImage(data, data_size, c, this->ImageType(), &tmp_out[i]); |
| 48 | } |
| 49 | |
| 50 | out.SetupLike(tmp_out[0]); |
| 51 | for (int i = 0; i < encoded_data.num_samples(); ++i) { |
| 52 | out.SetSample(i, tmp_out[i]); |
| 53 | } |
| 54 | |
| 55 | vector<std::shared_ptr<TensorList<CPUBackend>>> outputs; |
| 56 | outputs.push_back(std::make_shared<TensorList<CPUBackend>>()); |
| 57 | outputs[0]->Copy(out); |
| 58 | return outputs; |
| 59 | } |
| 60 | |
| 61 | protected: |
| 62 | virtual OpSpec DecodingOp() const { return OpSpec(); } |
nothing calls this directly
no test coverage detected